Jump to content
  • Advertisement
Sign in to follow this  
NickGravelyn

ODE Stepsize

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Perhaps the second parameter dWorldStep takes an integer type and 0.05f gets rounded to 0?

Share this post


Link to post
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 this post


Link to post
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 time
deltaTicks = currentTicks - lastTick;
lastTick = currentTicks; // update the last tick marker

dWorldStep(world, 0.1f * deltaTicks); // 0.1 is speed modifier

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
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 step

dReal stepSize = 0.1f * deltaTicks;
#define MAX_STEP_SIZE 0.05f //makes it a little easier to change
if (stepSize > MAX_STEP_SIZE) stepSize = MAX_STEP_SIZE;
#undef MAX_STEP_SIZE

//now we make the step
dWorldStep(world,stepSize);

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!