Space.Update(delta)

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
preen
Posts: 16
Joined: Sun Feb 20, 2011 6:10 pm

Space.Update(delta)

Post by preen »

I've tried two ways of updating the Space, with delta being the last frame length.

Space.Update(delta);

and

PhysicsSpace.TimeStepSettings.TimeStepDuration = delta;
PhysicsSpace.Update();


The latter -seems- to be smoother and give subtly more consistant vehicle behavior.

I'm wondering if there really is any difference between these two ways of updating?
Fe_Yoshi
Posts: 397
Joined: Tue Jul 04, 2006 5:05 pm
Location: New Tower!

Re: Space.Update(delta)

Post by Fe_Yoshi »

One has less code than the other.
It's simple, just take the hydraulic phase ship emulator and attach it to the photon particle emitter, BAM, new tower!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Space.Update(delta)

Post by Norbo »

The Update that takes a time parameter will attempt to simulate that far using fixed time steps of length TimeStepSettings.TimeStepDuration. If there's some time left over at the end of a frame, it sticks around and is added to the next frame.

The parameterless Update performs a single step of length TimeStepDuration. However, changing the TimeStepDuration every frame will cause worse stability sometimes; the engine likes having a fixed timestep.

The extra 'smoothness' you observe may be related to the system taking smaller timesteps, or possibly due to the fact that sometimes the fixed-timestep version is taking 0, 1, or 2 updates in a single frame, leading to slight variations in the perceived speed of simulation. If it's the former, you can reduce the fixed timestep duration. If it's the latter, you should use the interpolated properties of the entities for rendering. Interpolated states take into account the time remaining after a call to Update(float), blending frames to maintain smooth motion. You can access these through the entity's BufferedStates property.

However, you'll also need to enable interpolated states. By default, they are off to avoid overhead and they just fall through to the normal states. To enable them, set Space.BufferedStates.InterpolatedStates.Enabled = true.

This area still needs testing, so don't be surprised if you encounter an explosion or two :)
One has less code than the other.
Technically correct, the best kind of correct :wink:
Post Reply