Radegast.Rendering.SceneObject.Step C# (CSharp) Method

Step() public method

Perform per frame tasks
public Step ( float time ) : void
time float Time since the last call (last frame time in seconds)
return void
        public virtual void Step(float time)
        {
            if (BasePrim == null) return;

            // Don't interpolate when parent changes (sit/stand link/unlink)
            if (previousParent != BasePrim.ParentID)
            {
                previousParent = BasePrim.ParentID;
                InterpolatedPosition = BasePrim.Position;
                InterpolatedRotation = BasePrim.Rotation;
                return;
            }

            // Linear velocity and acceleration
            if (BasePrim.Velocity != Vector3.Zero)
            {
                BasePrim.Position = InterpolatedPosition = BasePrim.Position + BasePrim.Velocity * time
                    * 0.98f * Login.Client.Network.CurrentSim.Stats.Dilation;	//hack: replace RadegastInstance
                BasePrim.Velocity += BasePrim.Acceleration * time;
            }
            else if (InterpolatedPosition != BasePrim.Position)
            {
                InterpolatedPosition = RHelp.Smoothed1stOrder(InterpolatedPosition, BasePrim.Position, time);
            }

            // Angular velocity (target omega)
            if (BasePrim.AngularVelocity != Vector3.Zero)
            {
                Vector3 angVel = BasePrim.AngularVelocity;
                float angle = time * angVel.Length();
                Quaternion dQ = Quaternion.CreateFromAxisAngle(angVel, angle);
                InterpolatedRotation = dQ * InterpolatedRotation;
            }
            else if (InterpolatedRotation != BasePrim.Rotation && !(this is RenderAvatar))
            {
                InterpolatedRotation = Quaternion.Slerp(InterpolatedRotation, BasePrim.Rotation, time * 10f);
                if (1f - Math.Abs(Quaternion.Dot(InterpolatedRotation, BasePrim.Rotation)) < 0.0001)
                    InterpolatedRotation = BasePrim.Rotation;
            }
            else
            {
                InterpolatedRotation = BasePrim.Rotation;
            }
        }