Esempio n. 1
0
    // Applying a force just adds this to the total force on the object.
    // This added force will only last the next simulation tick.
    public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
        // for an object, doesn't matter if force is a pushforce or not
        if (force.IsFinite())
        {
            float magnitude = force.Length();
            if (magnitude > 20000f)
            {
                // Force has a limit
                force = force / magnitude * 20000f;
            }

            OMV.Vector3 addForce = force;
            DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce);

            PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate()
            {
                // Bullet adds this central force to the total force for this tick
                DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
                if (PhysBody.HasPhysicalBody)
                {
                    BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce);
                    ActivateIfPhysical(false);
                }
            });
        }
        else
        {
            m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID);
            return;
        }
    }
Esempio n. 2
0
    private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
        if (force.IsFinite())
        {
            float magnitude = force.Length();
            if (magnitude > BSParam.MaxAddForceMagnitude)
            {
                // Force has a limit
                force = force / magnitude * BSParam.MaxAddForceMagnitude;
            }

            OMV.Vector3 addForce = force;
            // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce);

            PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate()
            {
                // Bullet adds this central force to the total force for this tick
                // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);
                if (PhysBody.HasPhysicalBody)
                {
                    PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce);
                }
            });
        }
        else
        {
            m_log.WarnFormat("{0}: Got a NaN force applied to a character. LocalID={1}", LogHeader, LocalID);
            return;
        }
    }
Esempio n. 3
0
 // For the moment, create only one animation for an entity and that is the angular rotation.
 private void ProcessEntityAnimation(IEntity ent, ref UpdateCodes updateFlags, OMV.Vector3 angularVelocity)
 {
     try {
     // if  there is an angular velocity and this is not an avatar, pass the information
     // along as an animation (llTargetOmega)
     // we convert the information into a standard form
     IEntityAvatar av;
     if (angularVelocity != OMV.Vector3.Zero) {
         if (!ent.TryGet<IEntityAvatar>(out av)) {
             float rotPerSec = angularVelocity.Length() / Constants.TWOPI;
             OMV.Vector3 axis = angularVelocity;
             axis.Normalize();
             IAnimation anim;
             if (!ent.TryGet<IAnimation>(out anim)) {
                 anim = new LLAnimation();
                 ent.RegisterInterface<IAnimation>(anim);
                 m_log.Log(LogLevel.DUPDATEDETAIL, "Created prim animation on {0}", ent.Name);
             }
             if (rotPerSec != anim.StaticRotationRotPerSec || axis != anim.StaticRotationAxis) {
                 anim.AngularVelocity = angularVelocity;   // legacy. Remove when other part plumbed
                 anim.StaticRotationAxis = axis;
                 anim.StaticRotationRotPerSec = rotPerSec;
                 anim.DoStaticRotation = true;
                 updateFlags |= UpdateCodes.Animation;
                 m_log.Log(LogLevel.DUPDATEDETAIL, "Updating prim animation on {0}", ent.Name);
             }
         }
     }
     }
     catch (Exception e) {
     m_log.Log(LogLevel.DBADERROR, "FAILED ProcessEntityAnimation: " + e.ToString());
     }
 }