[ODE] Framerate problem *again*

skjold@cistron.nl skjold at cistron.nl
Wed Feb 12 13:23:01 2003


Hi Marco,

Nice to hear it works, I still don't understand why it doesn't work for me. Actually I meant the opposite of what you are doing, here is the code for what I meant:

static double lElapsedSimTime = 0;    // Keeps track of time
static double lSimTimestep    = 0.01; // 10ms resolution
static int lFrameSubdivision  = 4;

{...}

// Sim loop:
int i;
dSpaceCollide(aSpaceID, 0, &proximityCallback); // Start of frame: Interaction between bodies

for(i = 0; i < lFrameSubdivision; i++) { // Multiple smaller steps to resolve dynamics

    dWorldStep(aWorldID, lSimTimestep / lFrameSubdivision);

}

dJointGroupEmpty(contactgroup); // End of frame
lElapsedSimTime += lSimTimestep; // Update time


I tried the above, but it resulted in erratic behaviour. But I also tried your solution, and it resulted in similarly erratic behaviour. My sim loop looks like this when using your solution:

// Sim loop:
int i;
dSpaceCollide(aSpaceID, 0, &proximityCallback); // Start of frame: Interaction between bodies

for(i = 0; i < lFrameSubdivision; i++) { // Multiple smaller steps to resolve dynamics

    dWorldStep(aWorldID, lSimTimestep / lFrameSubdivision);

    if(i == 0) { // If this is the 1st inner loop...

        dJointGroupEmpty(contactgroup); // End of first subdivision

        // NOTE: This means the contacts exist only during
        // the first portion of the entire 10ms time frame!
        // That is why it seems incorrect to me.
    }
}
lElapsedSimTime += lSimTimestep; // End of frame, update time


Notice the difference? Anyway, it doesn't work right for me either way. The effects get worse as I increase lFrameSubdivision, which tells me the approach just isn't correct for some reason (because the idea was that lFrameSubdivisions increased accuracy of the dynamics).

Anyway, thanks for the info.
Greets,
Mark


> Hi Mark!
> 
> > I'm interested if you get it working, because I only got erratic results.
> 
> Ok, I tried. I call dJointGroupEmpty() (after dWorldStep()) only if
> I also called dSpaceCollide() in the same frame. Here it is:
> 
> if ("it's time to check collision") {
> 	dSpaceCollide();
> 	bCollisionChecked=true;
> }
> else
> 	bCollisionChecked=false;
> 
> while ("pushing to realtime")
> 	dWorldStep();
> 
> if (bCollisionChecked==true)
> 	dJointGroupEmpty();
> 
> Hope it's what you did mean.
> I can say that it works very well, even better than before! Bounces
> look more natural. So maybe your reasoning is really right, but there's
> a bug in your code!
> 
> 	Bye Bye
> 	Marco
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
>