Somes troubles with bullet update

Post Reply
Ilovechocolat
Posts: 2
Joined: Tue Jul 26, 2011 1:16 am

Somes troubles with bullet update

Post by Ilovechocolat »

Hello World !

First, sorry for my bad english.

I'm a begginer with bullet and I have some problem with my bullet update, i update bullet with this line :

Code: Select all

bulletWorld->stepSimulation(timeSinceLastFrame);//timeSinceLastFrame is in second (example : 1.547)
And this is how i declare my bullet world :

Code: Select all

btDefaultCollisionConstructionInfo collisionConfig;
bulletCollisionConfiguration = new btDefaultCollisionConfiguration(collisionConfig);
bulletDispatcher = new btCollisionDispatcher(bulletCollisionConfiguration);
bulletBroadphase = new btDbvtBroadphase();
bulletSequentialImpulseConstraintSolver = new btSequentialImpulseConstraintSolver;
bulletWorld = new btDiscreteDynamicsWorld(bulletDispatcher, m_bulletBroadphase, bulletSequentialImpulseConstraintSolver, bulletCollisionConfiguration);
bulletWorld->getPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
bulletWorld->setGravity(btVector3(0, -10.0, 0));
In my program i use btCollisionObject for non dynamic object and btKinematicCharacterController for the characters.

I have two problems during the bullet update :
- My update depend of framerate (my character are moving faster sometimes)
- Sometimes, some characters are falling over the floor (wich is a simple btCollisionObject with trimesh).

I searched in this forum but i did'nt find anything to fix my problem.
User avatar
EddieBytes
Posts: 22
Joined: Sun Jul 24, 2011 5:07 pm
Contact:

Re: Somes troubles with bullet update

Post by EddieBytes »

I believe low framerate is the cause for both your issues, since your simulation depends on the framerate. It shouldn't. I think your stepSimulation parameters are not correct.
Read this article and adjust your maxSubsteps and fixedTimeStep parameters in your stepSimulation call:
http://bulletphysics.org/mediawiki-1.5. ... _The_World
Ilovechocolat
Posts: 2
Joined: Tue Jul 26, 2011 1:16 am

Re: Somes troubles with bullet update

Post by Ilovechocolat »

I looked at your link but I dont managed to make my update independant of framerate, i tried a lot of solution but my personnages are still framerate dependant.

I tried those codes :

Code: Select all

m_bulletWorld->stepSimulation(timeSinceLastFrame, 0, 0);
m_bulletWorld->stepSimulation(timeSinceLastFrame, 1);
m_bulletWorld->stepSimulation(timeSinceLastFrame, 0);
m_bulletWorld->stepSimulation(timeSinceLastFrame, 1, 1 / timeSinceLastFrame);
m_bulletWorld->stepSimulation(timeSinceLastFrame, 0, 1 / timeSinceLastFrame);
But it stille dont work, is there a simple solution to make the bullet update framerate independant ?
User avatar
EddieBytes
Posts: 22
Joined: Sun Jul 24, 2011 5:07 pm
Contact:

Re: Somes troubles with bullet update

Post by EddieBytes »

Here is my call, it may or may not work for you:

Code: Select all

mDynamicsWorld->stepSimulation(timeSinceLastTime / 1000., 7, (btScalar)1./120);
make sure your fractions evaluate to a floating point number by making one of the fraction's terms float. Otherwise they will truncate to zero.
Ilovechocolat wrote:I looked at your link but I dont managed to make my update independant of framerate, i tried a lot of solution but my personnages are still framerate dependant.

I tried those codes :

Code: Select all

m_bulletWorld->stepSimulation(timeSinceLastFrame, 0, 0);
m_bulletWorld->stepSimulation(timeSinceLastFrame, 1);
m_bulletWorld->stepSimulation(timeSinceLastFrame, 0);
m_bulletWorld->stepSimulation(timeSinceLastFrame, 1, 1 / timeSinceLastFrame);
m_bulletWorld->stepSimulation(timeSinceLastFrame, 0, 1 / timeSinceLastFrame);
But it stille dont work, is there a simple solution to make the bullet update framerate independant ?
Post Reply