/
sidedef.h
191 lines (164 loc) · 6.05 KB
/
sidedef.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/** @file sidedef.h Map SideDef.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef LIBDENG_MAP_SIDEDEF
#define LIBDENG_MAP_SIDEDEF
#include <de/Error>
#include "resource/r_data.h"
#include "map/p_dmu.h"
#include "map/surface.h"
#include "MapElement"
class LineDef;
/*
* Helper macros for accessing sidedef top/middle/bottom section data elements:
*/
/// @addtogroup map
///@{
#define SW_surface(n) sections[(n)]
#define SW_surfaceflags(n) SW_surface(n).flags
#define SW_surfaceinflags(n) SW_surface(n).inFlags
#define SW_surfacematerial(n) SW_surface(n).material
#define SW_surfacetangent(n) SW_surface(n).tangent
#define SW_surfacebitangent(n) SW_surface(n).bitangent
#define SW_surfacenormal(n) SW_surface(n).normal
#define SW_surfaceoffset(n) SW_surface(n).offset
#define SW_surfacevisoffset(n) SW_surface(n).visOffset
#define SW_surfacergba(n) SW_surface(n).rgba
#define SW_surfaceblendmode(n) SW_surface(n).blendMode
#define SW_middlesurface SW_surface(SS_MIDDLE)
#define SW_middleflags SW_surfaceflags(SS_MIDDLE)
#define SW_middleinflags SW_surfaceinflags(SS_MIDDLE)
#define SW_middlematerial SW_surfacematerial(SS_MIDDLE)
#define SW_middletangent SW_surfacetangent(SS_MIDDLE)
#define SW_middlebitangent SW_surfacebitangent(SS_MIDDLE)
#define SW_middlenormal SW_surfacenormal(SS_MIDDLE)
#define SW_middletexmove SW_surfacetexmove(SS_MIDDLE)
#define SW_middleoffset SW_surfaceoffset(SS_MIDDLE)
#define SW_middlevisoffset SW_surfacevisoffset(SS_MIDDLE)
#define SW_middlergba SW_surfacergba(SS_MIDDLE)
#define SW_middleblendmode SW_surfaceblendmode(SS_MIDDLE)
#define SW_topsurface SW_surface(SS_TOP)
#define SW_topflags SW_surfaceflags(SS_TOP)
#define SW_topinflags SW_surfaceinflags(SS_TOP)
#define SW_topmaterial SW_surfacematerial(SS_TOP)
#define SW_toptangent SW_surfacetangent(SS_TOP)
#define SW_topbitangent SW_surfacebitangent(SS_TOP)
#define SW_topnormal SW_surfacenormal(SS_TOP)
#define SW_toptexmove SW_surfacetexmove(SS_TOP)
#define SW_topoffset SW_surfaceoffset(SS_TOP)
#define SW_topvisoffset SW_surfacevisoffset(SS_TOP)
#define SW_toprgba SW_surfacergba(SS_TOP)
#define SW_bottomsurface SW_surface(SS_BOTTOM)
#define SW_bottomflags SW_surfaceflags(SS_BOTTOM)
#define SW_bottominflags SW_surfaceinflags(SS_BOTTOM)
#define SW_bottommaterial SW_surfacematerial(SS_BOTTOM)
#define SW_bottomtangent SW_surfacetangent(SS_BOTTOM)
#define SW_bottombitangent SW_surfacebitangent(SS_BOTTOM)
#define SW_bottomnormal SW_surfacenormal(SS_BOTTOM)
#define SW_bottomtexmove SW_surfacetexmove(SS_BOTTOM)
#define SW_bottomoffset SW_surfaceoffset(SS_BOTTOM)
#define SW_bottomvisoffset SW_surfacevisoffset(SS_BOTTOM)
#define SW_bottomrgba SW_surfacergba(SS_BOTTOM)
///@}
/**
* FakeRadio shadow data.
* @ingroup map
*/
struct shadowcorner_t
{
float corner;
Sector *proximity;
float pOffset;
float pHeight;
};
/**
* @ingroup map
*/
struct edgespan_t
{
float length;
float shift;
};
/**
* @ingroup map
*/
struct msidedef_t
{
// Sidedef index. Always valid after loading & pruning.
int index;
int refCount;
};
/**
* @attention SideDef is in the process of being replaced by lineside_t. All
* data/values which concern the geometry of surfaces should be relocated to
* lineside_t. There is no need to model the side of map's line as an object
* in Doomsday when a flag would suffice. -ds
*
* @ingroup map
*/
class SideDef : public de::MapElement
{
public:
/// The referenced property does not exist. @ingroup errors
DENG2_ERROR(UnknownPropertyError);
/// The referenced property is not writeable. @ingroup errors
DENG2_ERROR(WritePropertyError);
public:
Surface sections[3];
LineDef *line;
short flags;
msidedef_t buildData;
/// Frame number of last update
int fakeRadioUpdateCount;
shadowcorner_t topCorners[2];
shadowcorner_t bottomCorners[2];
shadowcorner_t sideCorners[2];
/// [left, right]
edgespan_t spans[2];
public:
SideDef();
~SideDef();
/**
* Update the side's map space surface base origins according to the points
* defined by the associated LineDef's vertices and the plane heights of the
* Sector on this side. If no LineDef is presently associated this is a no-op.
*/
void updateBaseOrigins();
/**
* Update the side's map space surface tangents according to the points
* defined by the associated LineDef's vertices. If no LineDef is presently
* associated this is a no-op.
*/
void updateSurfaceTangents();
/**
* Get a property value, selected by DMU_* name.
*
* @param args Property arguments.
* @return Always @c 0 (can be used as an iterator).
*/
int property(setargs_t &args) const;
/**
* Update a property value, selected by DMU_* name.
*
* @param args Property arguments.
* @return Always @c 0 (can be used as an iterator).
*/
int setProperty(setargs_t const &args);
};
#endif // LIBDENG_MAP_SIDEDEF