Skip to content

Commit d829145

Browse files
committed
tweak(fps): Decouple drawable time step from render update (#1451)
1 parent 01fec0c commit d829145

File tree

7 files changed

+32
-8
lines changed

7 files changed

+32
-8
lines changed

GeneralsMD/Code/GameEngine/Include/GameClient/Display.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class Display : public SubsystemInterface
109109

110110
virtual void drawViews( void ); ///< Render all views of the world
111111
virtual void updateViews ( void ); ///< Updates state of world views
112+
virtual void stepViews(); ///< Update views for every fixed time step
112113

113114
virtual VideoBuffer* createVideoBuffer( void ) = 0; ///< Create a video buffer that can be used for this display
114115

GeneralsMD/Code/GameEngine/Include/GameClient/View.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class View : public Snapshot
211211

212212
virtual void drawView( void ) = 0; ///< Render the world visible in this view.
213213
virtual void updateView(void) = 0; ///<called once per frame to determine the final camera and object transforms
214+
virtual void stepView() = 0; ///< Update view for every fixed time step
214215

215216

216217

GeneralsMD/Code/GameEngine/Source/GameClient/Display.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ void Display::updateViews( void )
131131

132132
}
133133

134+
void Display::stepViews( void )
135+
{
136+
137+
for( View *v = m_viewList; v; v = v->getNextView() )
138+
v->stepView();
139+
140+
}
141+
134142
/// Redraw the entire display
135143
void Display::draw( void )
136144
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class W3DView : public View, public SubsystemInterface
140140
virtual void reset( void );
141141
virtual void drawView( void ); ///< draw this view
142142
virtual void updateView(void); ///<called once per frame to determine the final camera and object transforms
143+
virtual void stepView(); ///< Update view for every fixed time step
143144

144145
virtual void draw( ); ///< draw this view
145146
virtual void update( ); ///<called once per frame to determine the final camera and object transforms

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,8 @@ void W3DDisplay::step()
17261726
}
17271727

17281728
WW3D::Sync( syncTime );
1729+
1730+
stepViews();
17291731
}
17301732

17311733
//DECLARE_PERF_TIMER(BigAssRenderLoop)

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,24 @@ void W3DView::updateView(void)
10801080
UPDATE();
10811081
}
10821082

1083+
// TheSuperHackers @tweak xezon 12/08/2025 The drawable update is no longer tied to the
1084+
// render update, but it advanced separately for every fixed time step. This ensures that
1085+
// things like vehicle wheels no longer spin too fast on high frame rates or keep spinning
1086+
// on game pause.
1087+
void W3DView::stepView()
1088+
{
1089+
if (TheScriptEngine->isTimeFast()) {
1090+
return; // don't draw - makes it faster :) jba.
1091+
}
1092+
1093+
Region3D axisAlignedRegion;
1094+
getAxisAlignedViewRegion(axisAlignedRegion);
1095+
1096+
// render all of the visible Drawables
1097+
/// @todo this needs to use a real region partition or something
1098+
TheGameClient->iterateDrawablesInRegion( &axisAlignedRegion, drawDrawable, this );
1099+
}
1100+
10831101
//DECLARE_PERF_TIMER(W3DView_updateView)
10841102
void W3DView::update(void)
10851103
{
@@ -1383,14 +1401,6 @@ void W3DView::update(void)
13831401
// Give the terrain a chance to refresh animaing (Seismic) regions, if any.
13841402
TheTerrainVisual->updateSeismicSimulations();
13851403
#endif
1386-
1387-
Region3D axisAlignedRegion;
1388-
getAxisAlignedViewRegion(axisAlignedRegion);
1389-
1390-
// render all of the visible Drawables
1391-
/// @todo this needs to use a real region partition or something
1392-
if (WW3D::Get_Frame_Time()) //make sure some time actually elapsed
1393-
TheGameClient->iterateDrawablesInRegion( &axisAlignedRegion, drawDrawable, this );
13941404
}
13951405

13961406
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class PlaceholderView : public View
183183

184184
virtual void drawView( void ) {}; ///< Render the world visible in this view.
185185
virtual void updateView( void ) {}; ///< Render the world visible in this view.
186+
virtual void stepView() {}; ///< Update view for every fixed time step
186187

187188
virtual void setZoomLimited( Bool limit ) {} ///< limit the zoom height
188189
virtual Bool isZoomLimited( void ) { return TRUE; } ///< get status of zoom limit

0 commit comments

Comments
 (0)