Skip to content

Commit 492d209

Browse files
authored
refactor(view): Change scripted state booleans to enum flags in W3DView (TheSuperHackers#2357)
1 parent 6287241 commit 492d209

5 files changed

Lines changed: 153 additions & 97 deletions

File tree

Core/GameEngine/Include/GameClient/View.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class View : public Snapshot
172172
virtual void zoomCamera( Real finalZoom, Int milliseconds, Real easeIn=0.0f, Real easeOut=0.0f ) {};
173173
virtual void pitchCamera( Real finalPitch, Int milliseconds, Real easeIn=0.0f, Real easeOut=0.0f ) {};
174174

175+
virtual Bool isDoingScriptedCamera() = 0;
176+
virtual void stopDoingScriptedCamera() = 0;
177+
175178
virtual void setAngle( Real radians ); ///< Rotate the view around the vertical axis to the given angle (yaw)
176179
virtual Real getAngle() { return m_angle; } ///< Return current camera angle
177180
virtual void setPitch( Real radians ); ///< Rotate the view around the horizontal axis to the given angle (pitch)

Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ typedef struct
128128
// ------------------------------------------------------------------------------------------------
129129
class W3DView : public View, public SubsystemInterface
130130
{
131+
enum Scripted
132+
{
133+
Scripted_Rotate = 1<<0, // Set when rotating the camera
134+
Scripted_Pitch = 1<<1, // Set when pitching the camera
135+
Scripted_Zoom = 1<<2, // Set when zooming the camera
136+
Scripted_CameraLock = 1<<3, // Set when following a unit via script
137+
Scripted_MoveOnWaypointPath = 1<<4, // Set when moving camera along waypoint path
138+
};
139+
typedef UnsignedInt ScriptedState;
131140

132141
public:
133142
W3DView();
@@ -157,6 +166,9 @@ class W3DView : public View, public SubsystemInterface
157166

158167
virtual void forceRedraw();
159168

169+
virtual Bool isDoingScriptedCamera();
170+
virtual void stopDoingScriptedCamera();
171+
160172
virtual void setAngle( Real radians ); ///< Rotate the view around the vertical axis to the given angle (yaw)
161173
virtual void setPitch( Real radians ); ///< Rotate the view around the horizontal axis to the given angle (pitch)
162174
virtual void setAngleToDefault(); ///< Set the view angle back to default
@@ -246,22 +258,16 @@ class W3DView : public View, public SubsystemInterface
246258
Real m_shakeIntensity; ///< the intensity of the oscillation
247259
Vector3 m_shakerAngles; //WST 11/12/2002 new multiple instance camera shaker system
248260

249-
TRotateCameraInfo m_rcInfo;
250-
Bool m_doingRotateCamera; ///< True if we are doing a camera rotate.
261+
ScriptedState m_scriptedState; ///< Flags for scripted camera movements. Use functions addScriptedState, removeScriptedState for write.
251262

263+
TRotateCameraInfo m_rcInfo;
252264
TPitchCameraInfo m_pcInfo;
253-
Bool m_doingPitchCamera;
254265
TZoomCameraInfo m_zcInfo;
255-
Bool m_doingZoomCamera;
256-
257-
Bool m_doingScriptedCameraLock; ///< True if we are following a unit via script
266+
TMoveAlongWaypointPathInfo m_mcwpInfo; ///< Move camera along waypoint path info.
267+
Bool m_CameraArrivedAtWaypointOnPathFlag;
258268

259269
Real m_FXPitch; ///< Camera effects pitch. 0 = flat, infinite = look down, 1 = normal.
260270

261-
TMoveAlongWaypointPathInfo m_mcwpInfo; ///< Move camera along waypoint path info.
262-
Bool m_doingMoveCameraOnWaypointPath; ///< If true, moving camera along waypoint path.
263-
Bool m_CameraArrivedAtWaypointOnPathFlag;
264-
265271
Bool m_freezeTimeForCameraMovement;
266272
Int m_timeMultiplier; ///< Time speedup multiplier.
267273

@@ -283,6 +289,9 @@ class W3DView : public View, public SubsystemInterface
283289
void buildCameraTransform(Matrix3D *transform); ///< calculate (but do not set) the transform matrix of m_3DCamera, based on m_pos & m_angle
284290
void calcCameraAreaConstraints(); ///< Recalculates the camera area constraints
285291
Bool isWithinCameraHeightConstraints() const;
292+
Bool hasScriptedState(ScriptedState state) const;
293+
void addScriptedState(ScriptedState state);
294+
void removeScriptedState(ScriptedState state);
286295
void moveAlongWaypointPath(Real milliseconds); ///< Move camera along path.
287296
void getPickRay(const ICoord2D *screen, Vector3 *rayStart, Vector3 *rayEnd); ///<returns a line segment (ray) originating at the given screen position
288297
void setupWaypointPath(Bool orient); ///< Calculates distances & angles for moving along a waypoint path.

0 commit comments

Comments
 (0)