Different Outcomes with same simulation

Post Reply
jay721
Posts: 2
Joined: Tue May 22, 2018 7:59 pm

Different Outcomes with same simulation

Post by jay721 » Tue May 22, 2018 8:01 pm

I'm really confused at the moment, I'm simulating a few cubes falling in the exact same and I get different results every time.

Should this be happening? Is there a way to fix this?

User avatar
drleviathan
Posts: 554
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Different Outcomes with same simulation

Post by drleviathan » Thu May 24, 2018 3:46 pm

The first question that comes to mind: Are you using fixed size substeps? This is Bullet's default behavior so unless you specifically disabled it then the answer is "yes". If the answer is "no" then I would recommend you re-enable this behavior to obtain more repeatability.

The second question: The default value for the maxSubSteps argument to btDiscreteDynamicsWorld::stepSimulation() is 1. You should set this to at least 2. At a value of 1 it is possible to loose a substep or two even though your main game loop is trying to step at 60Hz. In fixed substep mode Bullet will accumulate excess time from the timeStep argument and will make multiple substeps when possible up to maxSubSteps many of them... or it will "lose time" when it needs to drop a substep.

The third set of questions: How big are your differences and how do you measure them? When you compare simulations are they from a cold start of the executable? Or are you resetting the simulation with a hot btCollisionWorld and subparts?

jay721
Posts: 2
Joined: Tue May 22, 2018 7:59 pm

Re: Different Outcomes with same simulation

Post by jay721 » Sat May 26, 2018 6:41 pm

drleviathan wrote:
Thu May 24, 2018 3:46 pm
The first question that comes to mind: Are you using fixed size substeps? This is Bullet's default behavior so unless you specifically disabled it then the answer is "yes". If the answer is "no" then I would recommend you re-enable this behavior to obtain more repeatability.

The second question: The default value for the maxSubSteps argument to btDiscreteDynamicsWorld::stepSimulation() is 1. You should set this to at least 2. At a value of 1 it is possible to loose a substep or two even though your main game loop is trying to step at 60Hz. In fixed substep mode Bullet will accumulate excess time from the timeStep argument and will make multiple substeps when possible up to maxSubSteps many of them... or it will "lose time" when it needs to drop a substep.

The third set of questions: How big are your differences and how do you measure them? When you compare simulations are they from a cold start of the executable? Or are you resetting the simulation with a hot btCollisionWorld and subparts?
Thanks for your reply :)

I havn't disabled fixed size substeps.
I've been using 10 as the value of maxSubSteps.

I'm measuring the differences by dropping several cubes (about 40-50) from a height and seeing where they land. The cubes have a fixed colour so it is easy to compare the position after each run. The simulations are not being reset. The difference seems to be very substantial, cubes are landing in complete different positions each time.

Post Reply