I've tried both:
Code: Select all
// Variable time step
m_dynamicsWorld->stepSimulation( m_frameTimer.getDeltaTime() );
// and Fixed time step
m_dynamicsWorld->stepSimulation( 1.0f/60.0f, 0 );
Code: Select all
// Variable time step
m_dynamicsWorld->stepSimulation( m_frameTimer.getDeltaTime() );
// and Fixed time step
m_dynamicsWorld->stepSimulation( 1.0f/60.0f, 0 );
Code: Select all
m_dynamicsWorld->stepSimulation( m_frameTimer.getDeltaTime() );
Code: Select all
m_dynamicsWorld->stepSimulation(m_frameTimer.getDeltaTime(), 10);
or
m_dynamicsWorld->stepSimulation(m_frameTimer.getDeltaTime(), 100);
or
m_dynamicsWorld->stepSimulation(m_frameTimer.getDeltaTime(), 1000);
Code: Select all
m_dynamicsWorld->stepSimulation(m_frameTimer.getDeltaTime(), 0);
Code: Select all
//during idle mode, just run 1 simulation step maximum
int maxSimSubSteps = m_idle ? 1 : 1;
if (m_idle)
dt = 1.0/420.f;
int numSimSteps = 0;
numSimSteps = m_dynamicsWorld->stepSimulation(dt,maxSimSubSteps);
Code: Select all
m_dynamicsWorld->stepSimulation(dt, 0);
but it seems determinism is broken with maxSubsteps > 1 as well, at least "maxSubSteps == 0" seem to be independent of computer speed, eg. physics simulation does not slow down or speed upmaxSubSteps == 0 ?
If you pass maxSubSteps=0 to the function, then it will assume a variable tick rate. Every tick, it will move the simulation along by exactly the timeStep you pass, in a single tick, instead of a number of ticks equal to fixedTimeStep.
This is not officially supported, and the death of determinism and framerate independance. Don't do it.
Code: Select all
// Physics handling part of the loop
/* This, like the rendering, ticks every time around.
Bullet does the interpolation for us. */
time_physics_curr = getMilliseconds();
// Tick the bullet world. Keep in mind that bullet takes seconds, and we measure time in milliseconds.
mWorld->stepSimulation(((float)(time_physics_curr - time_physics_prev))/1000.0, 10);
Code: Select all
PhysicsWorld::PhysicsWorld() {
setInternalStep(1/60.f); // not actually needed since it is the default
}
PhysicsWorld::pump () {
while (...) {
internalStep();
// application-specific internal step code
}
clearForces();
bool left_over_time = ...; // if desired, can integrate once more with any "left over" time
motionCallbacks(left_over_time); // if motion callbacks actually used
}
Code: Select all
while (!quit) {
// game loop
// graphics
stepSimulation(time-last_time);
}
You should be passing time to bullet measured in seconds, and not milliseconds.m_frameTimer.getDeltaTime()
Code: Select all
m_dynamicsWorld->stepSimulation(m_frameTimer.getDeltaTime(), 10);
or
m_dynamicsWorld->stepSimulation(m_frameTimer.getDeltaTime(), 100);
or
m_dynamicsWorld->stepSimulation(m_frameTimer.getDeltaTime(), 1000);
Code: Select all
((float)m_frameTimer.getDeltaTime)/1000.0f
You seek the EXTRACT_ALL parameter in your Doxyfile.By the way, no luck with Doxygen. Can you help with all details and Doxyfile (which version of doxygen?) that documents the btCollisionObject class etc.?
sorry, what are you referring to? ...where/who suggests that it is required for last parameter to be supplied and to what effect was that all about?The last parameter does not need to be supplied every frame, and requiring it to be supplied gives the wrong impression - that modifying it each frame is a good idea.
i dont agree... do have a look:The difference between the first and last parameter is rather subtle, and the middle parameter is not important...
Code: Select all
I'd rather have an API...
This would be similar to clamping to 2 or 3 internal substeps, as second argument. Let's increase the default value of the second argument to 3 to use a more relaxed clamping value.make sure that you clamp the deltaTime passed in from the timer to some maximum value like 0.25 seconds
And when maxSubSteps>1, I think?Interpolation is automatically supported when using the motion state to synchronizing the world transforms.
Code: Select all
Assuming you're passing time in milliseconds instead of seconds...
..then there is conversation about some bug being fixed, you comment how everything is ok, but your last set of graphs are still curved lines - whats the conclusion: is there or is there not "Frame Rate Independence" ?Your ideal graphs should all be dead flat lines, indicating that no matter how you futzed the numbers, the body fell the same distance... Welcome to computers. The lines are always flat for a certain distance, then suddenly change
Code: Select all
stepSimulation(1/frequency);
stepSimulation(1/frequency, 0);
stepSimulation(1/frequency, 0, 1/frequency);
stepSimulation(1/frequency, 1);
stepSimulation(1/frequency, 1, 1/frequency);
Code: Select all
stepSimulation(1./frequency, 0);
It should be more specific: "passing in a variable timestep in combination with 0 as second argument is not supported". If you manage your simulation loop yourself, it will be your responsibility to pass in a fixed timestep, and not a variable time step as first argument, in combination with 0 as second argument. In other words: just keep in mind that Bullet doesn't support variable-size internal simulation steps. Therefore avoid a changing/variable timestep as first argument in combination with 0 as second argument."This is not officially supported, and the death of determinism and framerate independance. Don't do it.".
So try it. Divide your first parameter to stepSimulation by 1000.0f.but seriously, you might be right for all i know,
I could. And in fact, you've already seen it, since I also wrote the Canonical Game Loop page on the wiki. The code you see there is directly ripped from my engine, that I wrote and am working on. [that I wrote after reading that gaffer-on-games article you see linked there]you agree with "my" definition here of "Frame Rate Independence", BUT you actually can make everything work all right, so you, in effect, could practically tell us, in several lines of code, how exactly you use your timer loop and call stepSimulation()?
There *is* framerate independance, and I prove it, but you need to make sure that you're passing appropriate parameters to stepSimulation. Parameters such that the inequality listed at the top of the Stepping the World wiki page is met. If you are passing milliseconds to the function, then you aren't meeting that inequality unless you pass 19000 as maxSubSteps.so, you start by kind of proving that indeed there is NO "Frame Rate Independence" [...]
is there or is there not "Frame Rate Independence" ?
This is the most important thing, and I believe the only thing a new user needs to know about. Since this is one of the first functions they ever call, it has to be simple. On the other hand, for everyone else it has to be powerful and this conflict of interest is causing the problem.Erwin Coumans wrote:
- The first argument is always the deltaTime in seconds.
I've had no success at all with 60hz, I think a large number of people will need to use 100hz or more. When you have worked on commercial games, how many have used bullet for dynamics (not just collisions) and what have they clocked the simulation to?Erwin Coumans wrote:
- The third argument is the internal fixed timestep. It is optional, and it is best to leave it at 60 hertz...
And also by just changing the 3rd parameter. If variable timestep isn't supported, I think it would be better set outside of the function with a setTimeStep(1/60.f) call. People who want to change it still can.
- Variable timestep is unsupported, although the interface allows it, when passing 0 as second argument.
Sometimes, depending on how you call stepSimulationErwin Coumans wrote:
- Interpolation is automatically supported when using the motion state to synchronizing the world transforms.
Code: Select all
stepSimulation(recorded_time, 100, 0.01);
Code: Select all
stepSimulation(0.01*floor(recorded_time/0.01), 100, 0.01);
Code: Select all
stepSimulation(0.01, 100, 0.01);
I would prefer a different interface entirely because this is not a simple thing and attempting to "encode" it into a single call does not make it simple. In fact I think it does more damage than exposing a more broken-down API. I'm happy to put a patch together sometime in the next few weeks. There are also some issues to do with interpolation and btMotionState in the tracker, I could fix them at the same time. I already have hacked workarounds in my own copy of the tree. I believe it will be be less buggy, faster, more intuitive, more newbie-friendly, more powerful, and backwards compatibleErwin Coumans wrote: What suggestions do you have to document this interface better?
Code: Select all
If a computer is too slow to compute all required simulation time steps in real-time, I suggest to either buy a faster CPU, improve the physics simulation performance or simplify the simulation.
Code: Select all
//*** fixing fps at 60, knowing we will always have time to spare
while( dTime < 1/60 )
getDeltaTime( dTime ) // dTime = time in seconds since last frame was rendered
stepSimulation(1/60, 1);
or even maybe
stepSimulation(dTime, 5); // note that dTime is not exactly 1/60
Code: Select all
//*** fixing fps at 10, knowing we will always have time to spare
while( dTime < 1/10 )
getDeltaTime( dTime ) // dTime = time in seconds since last frame was rendered
stepSimulation(1/10, 10);
Code: Select all
getDeltaTime( dTime ) // dTime = time in seconds since last frame was rendered
stepSimulation(dTime, 100);
i think everything is pretty clear here: "Stepping The World"What suggestions do you have to document this interface better?