Skip to content

Commit a2760dd

Browse files
committed
tweak(fps): Decouple scripted camera movement time step from render update (#1451)
1 parent a091a51 commit a2760dd

File tree

2 files changed

+10
-7
lines changed
  • GeneralsMD/Code/GameEngineDevice

2 files changed

+10
-7
lines changed

GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ typedef struct
6161
Real cameraAngle[MAX_WAYPOINTS+2]; // Camera Angle;
6262
Int timeMultiplier[MAX_WAYPOINTS+2]; // Time speedup factor.
6363
Real groundHeight[MAX_WAYPOINTS+1]; // Ground height.
64-
Int totalTimeMilliseconds; // Num of ms to do this movement.
65-
Int elapsedTimeMilliseconds; // Time since start.
64+
Real totalTimeMilliseconds; // Num of ms to do this movement.
65+
Real elapsedTimeMilliseconds; // Time since start.
6666
Real totalDistance; // Total length of paths.
6767
Real curSegDistance; // How far we are along the current seg.
6868
Int shutter;
@@ -284,7 +284,7 @@ class W3DView : public View, public SubsystemInterface
284284
void setCameraTransform( void ); ///< set the transform matrix of m_3DCamera, based on m_pos & m_angle
285285
void buildCameraTransform( Matrix3D *transform ) ; ///< calculate (but do not set) the transform matrix of m_3DCamera, based on m_pos & m_angle
286286
void calcCameraConstraints() ; ///< recalc m_cameraConstraint
287-
void moveAlongWaypointPath(Int milliseconds); ///< Move camera along path.
287+
void moveAlongWaypointPath(Real milliseconds); ///< Move camera along path.
288288
void getPickRay(const ICoord2D *screen, Vector3 *rayStart, Vector3 *rayEnd); ///<returns a line segment (ray) originating at the given screen position
289289
void setupWaypointPath(Bool orient); ///< Calculates distances & angles for moving along a waypoint path.
290290
void rotateCameraOneFrame(void); ///< Do one frame of a rotate camera movement.
@@ -301,6 +301,6 @@ class W3DView : public View, public SubsystemInterface
301301
}; // end class W3DView
302302

303303
// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
304-
extern Int TheW3DFrameLengthInMsec; // default is 33msec/frame == 30fps. but we may change it depending on sys config.
304+
extern Real TheW3DFrameLengthInMsec;
305305

306306
#endif // end __W3DVIEW_H_

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
// USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
4040
#include "Common/BuildAssistant.h"
41+
#include "Common/GameEngine.h"
4142
#include "Common/GlobalData.h"
4243
#include "Common/Module.h"
4344
#include "Common/RandomValue.h"
@@ -100,7 +101,7 @@
100101

101102

102103
// 30 fps
103-
Int TheW3DFrameLengthInMsec = 1000/LOGICFRAMES_PER_SECOND; // default is 33msec/frame == 30fps. but we may change it depending on sys config.
104+
Real TheW3DFrameLengthInMsec = MSEC_PER_LOGICFRAME_REAL; // default is 33msec/frame == 30fps. but we may change it depending on sys config.
104105
static const Int MAX_REQUEST_CACHE_SIZE = 40; // Any size larger than 10, or examine code below for changes. jkmcd.
105106
static const Real DRAWABLE_OVERSCAN = 75.0f; ///< 3D world coords of how much to overscan in the 3D screen region
106107

@@ -1053,7 +1054,9 @@ Bool W3DView::updateCameraMovements()
10531054
didUpdate = true;
10541055
} else if (m_doingMoveCameraOnWaypointPath) {
10551056
m_previousLookAtPosition = *getPosition();
1056-
moveAlongWaypointPath(TheW3DFrameLengthInMsec);
1057+
// TheSuperHackers @tweak The scripted camera movement is now decoupled from the render update.
1058+
const Real logicTimeScaleOverFpsRatio = TheGameEngine->getActualLogicTimeScaleOverFpsRatio();
1059+
moveAlongWaypointPath(TheW3DFrameLengthInMsec * logicTimeScaleOverFpsRatio);
10571060
didUpdate = true;
10581061
}
10591062
if (m_doingScriptedCameraLock)
@@ -3092,7 +3095,7 @@ void W3DView::pitchCameraOneFrame(void)
30923095

30933096
// ------------------------------------------------------------------------------------------------
30943097
// ------------------------------------------------------------------------------------------------
3095-
void W3DView::moveAlongWaypointPath(Int milliseconds)
3098+
void W3DView::moveAlongWaypointPath(Real milliseconds)
30963099
{
30973100
m_mcwpInfo.elapsedTimeMilliseconds += milliseconds;
30983101
if (TheGlobalData->m_disableCameraMovement) {

0 commit comments

Comments
 (0)