[ODE] Framerate problem *again*

Marco Bancale F104 at softhome.net
Tue Feb 11 09:23:02 2003


Hi!

Thank you all have answered my questions! :)

Now I understand that one of my mistakes was the "else" block. I tried
to delete the block and now it seems to work much better even at
different refresh rates and different PCs.

But now here is the true story:
Before posting the question I was ALREADY using the method you
suggested, but I decided to add the "else block" because I had weird
behaviors with ODE collision detection and the NearCallback.
Logging all the calls and info to a file I could see this:

START FRAME 1
NEARCALLBACK INVOKED
BODY1 and BODY2 Collided (bouncing)
END FRAME 1
START FRAME 2
NEARCALLBACK INVOKED
END FRAME 2
START FRAME 3
NEARCALLBACK INVOKED
BODY1 and BODY2 Collided (bouncing)
END FRAME 3

and so on.

As you can see, the weird thing is that when my ball bounces against
the wall the following happens:
the first frame the NearCallback is invoked with Body1 and Body2
colliding (and that's right);
the next frame NearCallback is invoked again (and that's right again
because Body1 and Body2 are still close), but with no collision
detected (it should be right);
the third frame NearCallback is invoked again (ok), but DETECTING
AGAIN a collision between Body1 and Body2!!!

I figured out this when I added sounds to the game. When the bouncing
occurs the sample is played many times (everytime the collision is
detected). But it's not an audio-related problem. I DON'T WANT the
collision to be detected two or more times per bouncing!

Why does this happen?

I thought something about timing and so I changed the ODE loop adding
the "else block", but as you suggested it's not a good idea.

Now the simulation, as I told you, runs fine on different machines, but
I have this big problem about collision detection.

Ah... I call dSpaceCollide() every 20 msec, not every frame nor
before every dWorldStep(). Maybe this could be a problem... ???

Please help again :)

Thank you all!

	Bye Bye
	Marco