ODE Stepsize

Started by
10 comments, last by Gorax 17 years, 11 months ago
I just put a few lines of ODE code into my project to begin using it, but I'm getting a weird error window when I run the project. It says that my stepsize must be greater than 0. I'm using 0.05f as a stepsize like this:

dWorldStep(world, 0.05f);
Any ideas why it's claiming I have a 0 timestep?
Advertisement
Perhaps the second parameter dWorldStep takes an integer type and 0.05f gets rounded to 0?
The function declaration is this:
void dWorldStep (dWorldID, dReal stepsize);

The demo apps for ODE use 0.05f as a stepsize, so I'm figuring that it's not getting rounded.
Check out the end of this thread. You may be linking against the wrong version of the ODE library.
0xa0000000
Since you arn't controlling how fast your application runs, you need to pass in the difference of time to the step side. This means you're going to have to implement a timer to check how many milliseconds have passed since last update. It will end up being something like this:

static uint deltaTicks = 0; static uint lastTick = 0;uint currentTicks = GetTime(); // whatever you use for getting the timedeltaTicks = currentTicks - lastTick; lastTick = currentTicks; // update the last tick markerdWorldStep(world, 0.1f * deltaTicks); // 0.1 is speed modifier
Rob Loach [Website] [Projects] [Contact]
Quote:Original post by Jack Sotac
Check out the end of this thread. You may be linking against the wrong version of the ODE library.


That turns out to be right. When I start using the binary version of ODE, it works fine. Now I just have to find a nice way to combine ODE and DirectX meshes...
BTW, it would be well worth your time to implement a fixed timestep system.
I like the DARK layout!
Quote:Original post by BradDaBug
BTW, it would be well worth your time to implement a fixed timestep system.


How do you suggest I go about this?
I think BradDaBug meant you should limit the maximum step size, that way things don't end up in walls (this happens in NFS-MW) or pass through things (this happens in NFSU2). If you've ever used Newton, you might have noticed this happening, since it's built-in, but in ODE, you have to do it yourself. It's not hard to do, all you have to do is get the time as you normally would, check to see if it's greater than the maximum value you've set, and if it is, set it to the maximum value instead, and then pass it off normally. Using Rob Loach's example, you'd do something like this:

...//everything before the stepdReal stepSize = 0.1f * deltaTicks;#define MAX_STEP_SIZE 0.05f //makes it a little easier to changeif (stepSize > MAX_STEP_SIZE) stepSize = MAX_STEP_SIZE;#undef MAX_STEP_SIZE//now we make the stepdWorldStep(world,stepSize);
I put that in but now my box just keeps bouncing higher and higher and spinning faster and faster. Is there something else I can do to stop this?

This topic is closed to new replies.

Advertisement