Exemplo n.º 1
0
 public void Step(float time)
 {
     if (RenderPosition != Position)
     {
         RenderPosition = RHelp.Smoothed1stOrder(RenderPosition, Position, time);
         Modified       = true;
     }
     if (RenderFocalPoint != FocalPoint)
     {
         RenderFocalPoint = RHelp.Smoothed1stOrder(RenderFocalPoint, FocalPoint, time);
         Modified         = true;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Perform per frame tasks
        /// </summary>
        /// <param name="time">Time since the last call (last frame time in seconds)</param>
        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 * METAboltInstance.GlobalInstance.Client.Network.CurrentSim.Stats.Dilation;
                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;
            }
        }