forked from perilouswithadollarsign/cstrike15_src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapatom.h
292 lines (248 loc) · 9.13 KB
/
mapatom.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef MAPATOM_H
#define MAPATOM_H
#pragma once
#include "hammer_mathlib.h"
#include "tier1/utlvector.h"
class Box3D;
class CRender2D;
class CRender3D;
enum SelectionState_t
{
SELECT_NONE = 0, // unselected
SELECT_NORMAL, // selected
SELECT_MORPH, // selected for vertex manipulation
SELECT_MULTI_PARTIAL, // partial selection in a multiselect
SELECT_MODIFY, // being modified by a tool
};
//
// Notification codes for NotifyDependents.
//
enum Notify_Dependent_t
{
Notify_Changed = 0, // The notifying object has changed.
Notify_Removed, // The notifying object is being removed from the world.
Notify_Undo,
Notify_Transform,
Notify_Rebuild,
Notify_Rebuild_Full,
Notify_Clipped_Intermediate,
Notify_Clipped
};
class CMapAtom
{
public:
int m_nObjectID;
//-----------------------------------------------------------------------------
// Purpose: Debugging hook.
//-----------------------------------------------------------------------------
virtual void Debug(void) {}
//-----------------------------------------------------------------------------
// Purpose: Returns whether this object is selected.
//-----------------------------------------------------------------------------
virtual bool IsSelected(void) const
{
return(m_eSelectionState != SELECT_NONE);
}
//-----------------------------------------------------------------------------
// Purpose: Returns the current selection state of this object.
//-----------------------------------------------------------------------------
virtual SelectionState_t GetSelectionState(void) const
{
return(m_eSelectionState);
}
//-----------------------------------------------------------------------------
// Purpose: Sets the current selection state of this object.
//-----------------------------------------------------------------------------
virtual SelectionState_t SetSelectionState(SelectionState_t eSelectionState)
{
SelectionState_t ePrevState = m_eSelectionState;
m_eSelectionState = eSelectionState;
return ePrevState;
}
//-----------------------------------------------------------------------------
// Purpose: Sets the render color of this object.
//-----------------------------------------------------------------------------
virtual void SetRenderColor(unsigned char red, unsigned char green, unsigned char blue)
{
r = red;
g = green;
b = blue;
}
//-----------------------------------------------------------------------------
// Purpose: Sets the render color of this object.
//-----------------------------------------------------------------------------
virtual void SetRenderColor(color32 rgbColor)
{
r = rgbColor.r;
g = rgbColor.g;
b = rgbColor.b;
}
//-----------------------------------------------------------------------------
// Purpose: Returns the render color of this object.
//-----------------------------------------------------------------------------
virtual void GetRenderColor(unsigned char &red, unsigned char &green, unsigned char &blue)
{
red = r;
green = g;
blue = b;
}
//-----------------------------------------------------------------------------
// Purpose: Returns the render color of this object.
//-----------------------------------------------------------------------------
virtual color32 GetRenderColor(void)
{
color32 rgbColor;
rgbColor.r = r;
rgbColor.g = g;
rgbColor.b = b;
rgbColor.a = 0;
return rgbColor;
}
//-----------------------------------------------------------------------------
// Purpose: Sets this object's parent.
// Input : pParent -
//-----------------------------------------------------------------------------
virtual void SetParent(CMapAtom *pParent)
{
m_pParent = pParent;
}
//-----------------------------------------------------------------------------
// Purpose: Returns the parent of this CMapAtom.
// Output : Parent pointer, NULL if this object has no parent.
//-----------------------------------------------------------------------------
virtual CMapAtom *GetParent(void) const
{
return(m_pParent);
}
//-----------------------------------------------------------------------------
// Purpose: Preloads any rendering info (textures, etc.). Called once per object
// from the renderer's Initialize function.
// Input : pRender - Pointer to the 3D rendering interface.
// bNewContext - True if the renderer pointed to by pRender is a new
// rendering context, false if not.
//-----------------------------------------------------------------------------
virtual bool RenderPreload(CRender3D *pRender, bool bNewContext)
{
return(true);
}
//-----------------------------------------------------------------------------
// Purpose: Renders this object into the 3D view.
// Input : pRender - Pointer to the 3D rendering interface.
//-----------------------------------------------------------------------------
virtual void Render3D(CRender3D *pRender)
{
}
//-----------------------------------------------------------------------------
// Purpose: Renders this object into the 3D view.
// Input : pRender - Pointer to the 3D rendering interface.
//-----------------------------------------------------------------------------
virtual void Render2D(CRender2D *pRender)
{
}
virtual void AddShadowingTriangles( CUtlVector<Vector> &tri_list )
{
// should add triangles representing the shadows this object would cast
// in lighting preview mode by adding 3 vector positions per triangle
}
//-----------------------------------------------------------------------------
// Purpose: Returns a coordinate frame to render in
// Input : matrix -
// Output : returns true if a new matrix is returned, false if the new matrix is bad
//-----------------------------------------------------------------------------
virtual bool GetTransformMatrix( VMatrix& matrix )
{
// try and get our parents transform matrix
CMapAtom *p = GetParent();
if ( p )
{
return p->GetTransformMatrix( matrix );
}
return false;
}
//-----------------------------------------------------------------------------
// Transformation functions.
//-----------------------------------------------------------------------------
void Transform(const VMatrix &matrix)
{
DoTransform(matrix);
PostUpdate(Notify_Transform);
}
void TransMove(const Vector &Delta)
{
VMatrix matrix;
matrix.Identity();
matrix.SetTranslation(Delta);
DoTransform(matrix);
PostUpdate(Notify_Transform);
}
void TransRotate(const Vector &RefPoint, const QAngle &Angles)
{
VMatrix matrix;
QAngle hammerAngle( -Angles.y, Angles.z, Angles.x );
matrix.SetupMatrixOrgAngles( vec3_origin, hammerAngle );
Vector vOffset;
matrix.V3Mul( RefPoint, vOffset );
vOffset = RefPoint - vOffset;
matrix.SetTranslation( vOffset );
DoTransform(matrix);
PostUpdate(Notify_Transform);
}
void TransScale(const Vector &RefPoint, const Vector &Scale)
{
VMatrix matrix;
matrix.Identity();
matrix = matrix.Scale( Scale );
Vector vOffset;
matrix.V3Mul( RefPoint, vOffset );
vOffset = RefPoint - vOffset;
matrix.SetTranslation( vOffset );
DoTransform(matrix);
PostUpdate(Notify_Transform);
}
//-----------------------------------------------------------------------------
// Must be called after modifying the object for bounds recalculation and
// dependency updates.
//-----------------------------------------------------------------------------
virtual void PostUpdate(Notify_Dependent_t eNotifyType) {}
//-----------------------------------------------------------------------------
// Override this for helpers. This indicates whether a helper provides a visual
// representation for the entity that it belongs to. Entities with no
// visual elements are given a default box so they can be seen.
//-----------------------------------------------------------------------------
virtual bool IsVisualElement(void) { return(false); }
//-----------------------------------------------------------------------------
// Override this to tell the renderer to render you last. This is useful for
// alpha blended elements such as sprites.
//-----------------------------------------------------------------------------
virtual bool ShouldRenderLast(void)
{
return(false);
}
virtual void SignalChanged(void ) // object has changed
{
}
protected:
static int s_nObjectIDCtr;
CMapAtom(void)
{
m_eSelectionState = SELECT_NONE;
m_pParent = NULL;
m_nObjectID = s_nObjectIDCtr++;
}
//-----------------------------------------------------------------------------
// DoTransform functions. Virtual, called by base Transfom functions.
//-----------------------------------------------------------------------------
virtual void DoTransform(const VMatrix &matrix) {}
CMapAtom *m_pParent; // This object's parent.
SelectionState_t m_eSelectionState; // The current selection state of this object.
unsigned char r; // Red color component.
unsigned char g; // Green color component.
unsigned char b; // Blue color component.
};
#endif // MAPATOM_H