• 13
• 12
• 9
• 10
• 13

# ODE Stepsize

This topic is 4319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
Perhaps the second parameter dWorldStep takes an integer type and 0.05f gets rounded to 0?

##### Share on other sites
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.

##### Share on other sites
Check out the end of this thread. You may be linking against the wrong version of the ODE library.

##### Share on other sites
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

##### Share on other sites
Quote:
 Original post by Jack SotacCheck 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...

##### Share on other sites
BTW, it would be well worth your time to implement a fixed timestep system.

##### Share on other sites
Quote:
 Original post by BradDaBugBTW, it would be well worth your time to implement a fixed timestep system.

##### Share on other sites
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);