Different physics result in my debug and release app.

anileci

10-04-2007 11:11:18

I embed PhysX into my game by nxOgre. At the begin, I only work under debug mode, physX works good. But when I bulid a release version app for testting the performance these days, I found that they are quite different.

In my game, a [actor] will pick up a [box] then throw it to others for attacking. The different between d & r is the speed of actor and box. Suppose the speed in debug for actor and box is 5 and 10 units/sec. In release app, I found the actor runs very slow, maybe 2~3 units/sec. but if I pick up a box, then the actor moves faster(8~9), I'm sure I didn't modify it's speed value. And after throw out the box, the box flying speed is about 5~6 units/sec. So in release, my actor can catch up a flying box if he pick up a box :)


The actor is a NxCapsuleController and the box is a NxActor with NxBoxShapeDesc.

Some Init values like this:
-----------------------------------------------
pd.SetToDefault();
pd.setGravity( true );
pd.setSlopeLimit( 60 );
pd.setStep( 100 );
pd.setShapeAsCapsule( 40.0f, 40.f );
pd.setMesh( "ninja.mesh" );
pd.setWalkSpeed(70);
pd.setRunSpeed(500);
pd.setGravity(-1000);

-------------------------------------------
[box]NxActor :
m_pBody = pPhyScene->createBody(
m_Desc.name, // Name of the body
m_Desc.meshName, // Mesh to use
new nxOgre::cubeShape( desc.cubeShapeSize ),
m_Desc.density, // Density
m_Desc.recurPose
);

-------------------------------------------
Launch box:(throw it)
m_pBody->setIgnoreGravity( true );
m_pBody->setLinearVelocity( Ogre::Vector3::ZERO, 0.0f );
m_pBody->addForce( 3*150000000000.0f * dir );
-------------------------------------------
Move box with actor's skeleton animation in each frame

m_pBody->freezeAll();
m_pBody->moveTo( nxOgre::pose(pos, qua));

-------------------------------------------

FPS debug : 8~12
FPS release: 40~60

I have tried to set
//mScene->setTiming(_time / 4.0f, 4, NX_TIMESTEP_FIXED);
mScene->setTiming(_time / 4.0f, 4, NX_TIMESTEP_VARIABLE);

but it's no different.

If need, I can try to REC the game video for you.

SW version:
AGEIA PhysX SDK 2.6.2 without HW.
XPSP2 VS2003 OGRE1.25 NxOGRE0.4RC3
P4 3.0GHz 1GRAM

Can anybody give me some clue to solve this problem?
Thanks in advance!

betajaen

10-04-2007 12:16:38

In theory it shouldn't do that. The character controller movement is based on deltaTime (time since last frame).

Since you've tried fixed timing, I wonder what would happen if you manually set the deltaTime for the character to "1.0f/60.0f" the scene timing to fixed "1.0/60.0f" and the Ogre rendersystem's vsync to true.

Also, have to tried the 0.6 SVN with your code? It may make a difference.

anileci

10-04-2007 18:16:30


Since you've tried fixed timing, I wonder what would happen if you manually set the deltaTime for the character to "1.0f/60.0f" the scene timing to fixed "1.0/60.0f"

I cann't notice the different from these settings. 1.0/60.0 or _time / 4.0f. At the beginning of my app startup, It looks ok. but after a while, my notebook's video card and cpu get hot, or the cpu reach a high usage, the fps will have a big chage. from 8 to 45.


and the Ogre rendersystem's vsync to true.

This helps me most! The effect is much better than before! the actor runs very smooth!


Also, have to tried the 0.6 SVN with your code? It may make a difference.

I'll try this later. My actor's code based on the Ageia PhysX's Trainning 605(2.62). I have tried your code from 0.4RC3, but the shaky puzzled me a long time. The most different between Tranning 605 and your Tutorial 605 is you have the FALLING state. I think it make the actor shaky. After I remove simulateFalling() it really works well.

BUT I confused with another problem. Sometimes my actor will sink half height of the capsule controller under the ground. And can't move. Then I can "jump" back to the ground. Or sometimes the actor may sink direct out of the whole level. My level is constructed by some mesh model.

This only happens sometime. So I really don't know how to solve it.

Thank you betajaen!! Thank you very much for you suggestions!