Page 1 of 1

TimeStepSettings in v.15

Posted: Sat Mar 19, 2011 1:31 am
by RyanGadz
in v.14.3 i was using
space.SimulationSettings.TimeStep.TimeStepDuration = 1 / 120f;
space.SimulationSettings.TimeStep.UseInternalTimeStepping = true;
i dont know if that is wrong or what but it worked how i wanted it to on the windows phone. i had it this way to prevent the golf ball from passing though other geometry while still providing accuracy and speed at the maxium velocity of the ball.

now im playing with settings again and I cant seem to make it work the same in v.15

any advice?

Re: TimeStepSettings in v.15

Posted: Sat Mar 19, 2011 1:55 am
by Norbo
The equivalent of the space.SimulationSettings.TimeStep.TimeStepDuration = 1 / 120f; line is:

Code: Select all

Space.TimeStepSettings.TimeStepDuration = 1/120f;
To enable internal time stepping, all you have to do is pass the elapsed time to the Space.Update method. It will use internal timesteps automatically.

Another difference you will note is that the entity properties are no longer buffered/interpolated. If you want to access interpolated states, you can access the Entity.BufferedStates.InterpolatedStates versions of the properties. To use those, you'll also have to set Space.BufferedStates.Enabled = true. The entity's buffered states properties just refer back to the space's buffered states manager.

Re: TimeStepSettings in v.15

Posted: Sat Mar 19, 2011 1:57 am
by RyanGadz
i was just looking at the note on internal timstepping in the demo as you wrote this

Re: TimeStepSettings in v.15

Posted: Sat Mar 19, 2011 2:10 am
by RyanGadz
Norbo wrote: Another difference you will note is that the entity properties are no longer buffered/interpolated. If you want to access interpolated states, you can access the Entity.BufferedStates.InterpolatedStates versions of the properties. To use those, you'll also have to set Space.BufferedStates.Enabled = true. The entity's buffered states properties just refer back to the space's buffered states manager.
you lost me a little bit here.. is this why the golf ball sometimes never reaches my magic '<.01 velocity' and telling the user its time to putt? that is what im messing with now.

Re: TimeStepSettings in v.15

Posted: Sat Mar 19, 2011 2:24 am
by Norbo
No, that paragraph is just referring to how interpolated properties are stored in a different spot in the API now, instead of directly visible on the Entity.

I suspect that what you're seeing is related to the new way the deactivation system works. It's very slightly different- it's possible for an entity go to sleep with nonzero velocity. Instead of using a linear velocity threshold, you could check if the entity is deactivated (entity.IsActive == false). There are also events on the entity for deactivation.

The change was made so that entities waking up from slumber wouldn't 'jump' ever so slightly due to constraints having a bad initial guess from pre-deactivation.

Re: TimeStepSettings in v.15

Posted: Sat Mar 19, 2011 2:31 am
by RyanGadz
oh sweet thanks!

it seems to be going in and out of IsActive.. might have something to do with me turing gravity on and off thoughout the putting action

yeah that worked however what im also trying to avoid is having the ball roll down the hill at a very slow speed for 2 minutes. i tried playing with the ball properties before like angular momentum but in the end the velocity threshold proved best.. is there a way to make entities slow down faster?

Re: TimeStepSettings in v.15

Posted: Sat Mar 19, 2011 2:54 am
by Norbo
You could increase LinearDamping or AngularDamping, or increase the Space.DeactivationManager.VelocityLowerLimit.

Re: TimeStepSettings in v.15

Posted: Sat Mar 19, 2011 2:55 am
by RyanGadz
For the effect I believe you're looking for, which is essentially slowing the linear velocity of the ball, you have a few options. The quickest and most straightforward would be damping the sphere's linear velocity using (Entity).linearDamping. Perfect spheres tend to enjoy wandering around a bit (both naturally and due to some floating point issues), so it might take some tweaking to make it look exactly like you want.

Another option would allow you to use the sliding friction instead of damping, and the ball will definitely not wander. You can restrict the rotation of an entity by altering its localInertiaTensorInverse, each row corresponding to a local axis of rotation. If you set every element in the matrix to zero, it cannot rotate. This means, instead of rolling, it will slide- allowing your friction coefficients to slow its motion down. This is what I use for the character controller to keep it upright; you can see it being used in the DynamicCharacterControllerInput constructor. There are also some upright constraints, but they are less directly applicable to your situation.
you answered this earlier sorry