Merge pull request #849 from benelot/3D-NN-walkers-example

Improvements to 3DNNWalkers example
This commit is contained in:
erwincoumans
2017-06-05 13:31:07 -07:00
committed by GitHub
5 changed files with 866 additions and 451 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -208,7 +208,8 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
CommonRigidBodyBase(helper),
mPhysicsStepsPerSecondUpdated(false),
mFramesPerSecondUpdated(false),
mSolverIterationsUpdated(false) {
mSolverIterationsUpdated(false),
mIsHeadless(false){
// main frame timer initialization
mApplicationStart = mLoopTimer.getTimeMilliseconds(); /**!< Initialize when the application started running */
@@ -519,7 +520,7 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
m_collisionConfiguration);
}
changeERPCFM(); // set appropriate ERP/CFM values according to the string and damper properties of the constraint
changeERPCFM(); // set appropriate ERP/CFM values according to the spring and damper properties of the constraint
if (useSplitImpulse) { // If you experience strong repulsion forces in your constraints, it might help to enable the split impulse feature
m_dynamicsWorld->getSolverInfo().m_splitImpulse = 1; //enable split impulse feature
@@ -536,7 +537,7 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
m_dynamicsWorld->getSolverInfo().m_numIterations = gSolverIterations; // set the number of solver iterations for iteration based solvers
m_dynamicsWorld->setGravity(btVector3(0, -9.81f, 0)); // set gravity to -9.81
m_dynamicsWorld->setGravity(btVector3(0, btScalar(-9.81f), 0)); // set gravity to -9.81
}
@@ -551,7 +552,7 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
void timeWarpSimulation(float deltaTime) // Override this
virtual void performModelUpdate(float deltaTime) // Override this
{
}
@@ -559,7 +560,7 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
void stepSimulation(float deltaTime){ // customly step the simulation
do{
// // settings
// settings
if(mPhysicsStepsPerSecondUpdated){
changePhysicsStepsPerSecond(gPhysicsStepsPerSecond);
mPhysicsStepsPerSecondUpdated = false;
@@ -590,10 +591,10 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
//#############
// model update - here you perform updates of your model, be it the physics model, the game or simulation state or anything not related to graphics and input
timeWarpSimulation(deltaTime);
performModelUpdate(deltaTime);
if(mLoopTimer.getTimeSeconds() - speedUpPrintTimeStamp > 1){
// on reset, we calculate the performed speed up
//double speedUp = ((double)performedTime*1000.0)/((double)(mLoopTimer.getTimeMilliseconds()-performanceTimestamp));
double speedUp = ((double)performedTime*1000.0)/((double)(mLoopTimer.getTimeMilliseconds()-performanceTimestamp));
// b3Printf("Avg Effective speedup: %f",speedUp);
performedTime = 0;
performanceTimestamp = mLoopTimer.getTimeMilliseconds();
@@ -612,7 +613,7 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
mModelStart = mLoopTimer.getTimeMilliseconds(); /**!< Begin with the model update (in Milliseconds)*/
mLastGraphicsTick = mModelStart - mGraphicsStart; /**!< Update graphics timer (in Milliseconds) */
if (gMaximumSpeed /** If maximum speed is enabled*/) {
if (gMaximumSpeed) { /** If maximum speed is enabled*/
performMaxStep();
} else { /**!< This mode tries to progress as much time as it is expected from the game loop*/
performSpeedStep();
@@ -627,8 +628,8 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
mInputDt = mThisModelIteration - mInputClock;
if (mInputDt >= gApplicationTick) {
mInputClock = mThisModelIteration;
// mInputHandler.injectInput(); /**!< Inject input into handlers */
// mInputHandler.update(mInputClock); /**!< update elements that work on the current input state */
//mInputHandler.injectInput(); /**!< Inject input into handlers */
//mInputHandler.update(mInputClock); /**!< update elements that work on the current input state */
}
mGraphicsStart = mLoopTimer.getTimeMilliseconds(); /**!< Start the graphics update */
@@ -650,7 +651,7 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
}
virtual bool keyboardCallback(int key, int state)
virtual bool keyboardCallback(int key, int state)
{
switch(key)
{
@@ -752,10 +753,9 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
for (int i = 0; i < subSteps; i++) { /**!< Perform the number of substeps to reach the timestep*/
if (timeStep && m_dynamicsWorld) {
// since we want to perform all proper steps, we perform no interpolated substeps
int subSteps = 1;
int subSteps = 1; // since we want to perform all proper steps, we perform no interpolated substeps
m_dynamicsWorld->stepSimulation(btScalar(timeStep),
m_dynamicsWorld->stepSimulation(btScalar(fixedPhysicsStepSizeSec),
btScalar(subSteps), btScalar(fixedPhysicsStepSizeSec));
}
}