/
MapSector.h
147 lines (124 loc) · 3.74 KB
/
MapSector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef __MAPSECTOR_H__
#define __MAPSECTOR_H__
#include "MapObject.h"
#include "Polygon2D.h"
class MapSide;
class MapLine;
class MapVertex;
struct doomsector_t
{
short f_height;
short c_height;
char f_tex[8];
char c_tex[8];
short light;
short special;
short tag;
};
struct doom64sector_t
{
short f_height;
short c_height;
uint16_t f_tex;
uint16_t c_tex;
uint16_t color[5];
short special;
short tag;
uint16_t flags;
};
enum PlaneType
{
FLOOR_PLANE,
CEILING_PLANE,
};
class MapSector : public MapObject
{
friend class SLADEMap;
friend class MapSide;
private:
// Basic data
string f_tex;
string c_tex;
short f_height;
short c_height;
short light;
short special;
short tag;
// Internal info
vector<MapSide*> connected_sides;
bbox_t bbox;
Polygon2D polygon;
bool poly_needsupdate;
long geometry_updated;
fpoint2_t text_point;
plane_t plane_floor;
plane_t plane_ceiling;
void setGeometryUpdated();
public:
MapSector(SLADEMap* parent = NULL);
MapSector(string f_tex, string c_tex, SLADEMap* parent = NULL);
~MapSector();
void copy(MapObject* copy);
string getFloorTex() { return f_tex; }
string getCeilingTex() { return c_tex; }
short getFloorHeight() { return f_height; }
short getCeilingHeight() { return c_height; }
short getLightLevel() { return light; }
short getSpecial() { return special; }
short getTag() { return tag; }
plane_t getFloorPlane() { return plane_floor; }
plane_t getCeilingPlane() { return plane_ceiling; }
double floorHeightAt(double x, double y);
double ceilingHeightAt(double x, double y);
string stringProperty(string key);
int intProperty(string key);
void setStringProperty(string key, string value);
void setFloatProperty(string key, double value);
void setIntProperty(string key, int value);
void setFloorHeight(short height);
void setCeilingHeight(short height);
void setFloorPlane(plane_t p) {
if (plane_floor != p)
setGeometryUpdated();
plane_floor = p;
}
void setCeilingPlane(plane_t p) {
if (plane_ceiling != p)
setGeometryUpdated();
plane_ceiling = p;
}
template<PlaneType p> short getPlaneHeight();
template<PlaneType p>
plane_t getPlane();
template<PlaneType p>
void setPlane(plane_t plane);
fpoint2_t getPoint(uint8_t point);
void resetBBox() { bbox.reset(); }
bbox_t boundingBox();
vector<MapSide*>& connectedSides() { return connected_sides; }
void resetPolygon() { poly_needsupdate = true; }
Polygon2D* getPolygon();
bool isWithin(double x, double y);
double distanceTo(double x, double y, double maxdist = -1);
bool getLines(vector<MapLine*>& list);
bool getVertices(vector<MapVertex*>& list);
bool getVertices(vector<MapObject*>& list);
uint8_t getLight(int where = 0);
void changeLight(int amount, int where = 0);
rgba_t getColour(int where = 0, bool fullbright = false);
rgba_t getFogColour();
long geometryUpdatedTime() { return geometry_updated; }
void connectSide(MapSide* side);
void disconnectSide(MapSide* side);
void updateBBox();
void writeBackup(mobj_backup_t* backup);
void readBackup(mobj_backup_t* backup);
};
// Note: these MUST be inline, or the linker will complain
template<> inline short MapSector::getPlaneHeight<FLOOR_PLANE>() { return getFloorHeight(); }
template<> inline short MapSector::getPlaneHeight<CEILING_PLANE>() { return getCeilingHeight(); }
template<> inline plane_t MapSector::getPlane<FLOOR_PLANE>() { return getFloorPlane(); }
template<> inline plane_t MapSector::getPlane<CEILING_PLANE>() { return getCeilingPlane(); }
template<> inline void MapSector::setPlane<FLOOR_PLANE>(plane_t plane) { setFloorPlane(plane); }
template<> inline void MapSector::setPlane<CEILING_PLANE>(plane_t plane) { setCeilingPlane(plane); }
#endif //__MAPSECTOR_H__