Interpolated state update on using Space.Update()

Post and discuss features you'd like to see in the BEPUphysics library.
Post Reply
Posts: 6
Joined: Thu Apr 25, 2013 12:20 pm

Interpolated state update on using Space.Update()

Post by trick » Thu Apr 25, 2013 12:29 pm

Since there is no interpolated state update done using the parameterless update method of the Space class, you could maybe add something like the code below to the Space class?
It is needed if you do the time-stepping on your own (since other parts of your engine depend on it as well) and want to call the physics engine every time step on your own but still need smooth movements of the entities if (and in general it does!) the render frame rate differs from the physics frame rate (which is fixed).

Code: Select all

        /// <summary>
        /// Updates the interpolated states with a given blend amount factor. Use it together with the parameterless Update method to get a frame rate independent smooth motion of the entities even that the physics engine uses discrete time steps.
        /// </summary>
        /// <param name="blendAmount">Blend factor describing how far the current frame lies between the last two physics frames. Needs to be in range 0.0 - 1.0f.</param>
        public void UpdateInterpolatedStates(float blendAmount)
            if ((blendAmount < 0.0f) || (blendAmount > 1.0f))
                throw new ArgumentOutOfRangeException("blendAmount", "blendAmount needs to be in the range of 0.0f and 1.0f");

            BufferedStates.InterpolatedStates.BlendAmount = blendAmount;

Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Interpolated state update on using Space.Update()

Post by Norbo » Thu Apr 25, 2013 7:25 pm

I would recommend using the property and update directly:

Code: Select all

            Space.BufferedStates.InterpolatedStates.BlendAmount = blendAmount;
I am hesitant to include another way to do the same thing but in one line instead of two; it doesn't appear that the convenience is worth the potential API confusion introduced by redundant functionality.

Post Reply