stepSimulation seems to be slacking

Ipredlol
Posts: 8
Joined: Fri Mar 11, 2011 6:23 pm

stepSimulation seems to be slacking

Post by Ipredlol »

Hi folks!

I recently discovered that stepSimulation is going into sleep almost every other frame.

Code: Select all

cout << "Position1: " << ...
stepSimulation(timeSinceLastFrame,10)
cout << "Position2: " << ...
And I just keep getting the result:
Position1: 0 0 0
Position2: 0 0 1 // First one is working
Position1: 0 0 1
Position2: 0 0 1 // Sleepmode
Position1: 0 0 1
Position2: 0 0 2 // working
Position1: 0 0 2
Position2: 0 0 3 // working
Position1: 0 0 3
Position2: 0 0 3 // Sleepmode
Position1: 0 0 3
Position2: 0 0 4 // Working
Position1: 0 0 4
Position2: 0 0 5 // Working
Position1: 0 0 5
Position2: 0 0 5 // Sleepmode
Position1: 0 0 5
Position2: 0 0 6 // Working
....


Does anyone have any idea about why this is happening?
Thank you!

Cheers,
Allan
marios
Posts: 52
Joined: Mon Jul 19, 2010 3:11 am

Re: stepSimulation seems to be slacking

Post by marios »

what are you exactly displaying by cout<<... ? It looks like integer value and bullet is working in floats, are you casting it?
Ipredlol
Posts: 8
Joined: Fri Mar 11, 2011 6:23 pm

Re: stepSimulation seems to be slacking

Post by Ipredlol »

Thank you for your reply.
They are the vehicle's positions, I wanted to make it easier for you guys to understand my problem so I used that kind of format. Basically I just wanted to show that the position cout repeats every other frame.
Kanttori
Posts: 38
Joined: Thu Jul 08, 2010 12:52 am

Re: stepSimulation seems to be slacking

Post by Kanttori »

I'd guess you're directly accessing rigidbody transforms and only getting non-interpolated per tick positions instead of using motionstates to get interpolated ones. If bullettime += timesincelastframe isn't enough to push bullet over the next tick boundary you get the same positions as before running stepsimulation.

http://bulletphysics.org/mediawiki-1.5. ... tionStates