Game Development Community

Integration Fix for T2D alpha 3b

by Ray Gebhardt · in Torque Game Builder · 01/29/2006 (10:54 am) · 2 replies

I had some problems with the onUpdateScene callbacks not getting called once per interation. This made it so some of the actions I had to do per interation, were getting called per frame instead. Here is what I changed to make it so that onUpdateScene is called per iteration:

t2dSceneGraph.cc Line - 2768
Remove:
// Expose a kind of main-loop to scripts.
   Con::executef( this, 1, "onUpdateScene" );

t2dSceneGraph.cc Line - 2686
Change:
mCurrentInactiveFrameCount = 0;
}
To:
mCurrentInactiveFrameCount = 0;

   // Expose a kind of main-loop to scripts.
   Con::executef( this, 1, "onUpdateScene" );
}

t2dSceneGraph.cc Line - 2717
Change:
mLastInactiveFrameCount = mCurrentInactiveFrameCount = 0;
}
To:
mLastInactiveFrameCount = mCurrentInactiveFrameCount = 0;

   // Expose a kind of main-loop to scripts.
   Con::executef( this, 1, "onUpdateScene" );
}

t2dSceneGraph.cc Line - 2740
Change:
// Do the iterations.
for ( U32 n = 1; n < iterations; n++ )
   subUpdateScene(targetFPSTime, &pDummyDebugStats);

// Do the Final Iteration with a valid debug-stats.
subUpdateScene(targetFPSTime, &mDebugStats);

// Set Physics Metrics.
To:
// Do the iterations.
for ( U32 n = 1; n < iterations; n++ )
{
   subUpdateScene(targetFPSTime, &pDummyDebugStats);

   // Expose a kind of main-loop to scripts.
   Con::executef( this, 1, "onUpdateScene" );
}

// Do the Final Iteration with a valid debug-stats.
subUpdateScene(targetFPSTime, &mDebugStats);
Con::executef( this, 1, "onUpdateScene" );

// Set Physics Metrics.

#1
01/29/2006 (11:02 am)
You will also have to do something like the following, to setup the scenegraph so that it will integrate the physics in such a way that it works the same on all machines:
t2dScene.setScenePhysicsFPSActive(true);
t2dScene.setScenePhysicsLimitFPS(60);
t2dScene.setScenePhysicsTargetFPS(60);
t2dScene.setScenePhysicsMaxIterations(5);
#2
01/29/2006 (11:33 am)
Just a little note. You should only need to use this fix if you do things that are physics based in onUpdateScene update. Otherwise everything should work correctly without it. You will still have to setup the scenegraph something like how I noted in the last post though.