// Usually called when target velocity changes to set the current velocity and the target
 //     into the movement motor.
 public void SetVelocityAndTarget(OMV.Vector3 vel, OMV.Vector3 targ, bool inTaintTime)
 {
     m_physicsScene.TaintedObject(inTaintTime, m_controllingPrim.LocalID, "BSActorAvatarMove.setVelocityAndTarget", delegate()
     {
         if (m_velocityMotor != null)
         {
             m_velocityMotor.Reset();
             m_velocityMotor.SetTarget(targ);
             m_velocityMotor.SetCurrent(vel);
             m_velocityMotor.Enabled = true;
         }
     });
 }
Beispiel #2
0
 private void SetVelocityAndTargetInternal(OMV.Vector3 vel, OMV.Vector3 targ, bool inTaintTime, int targetValueDecayTimeScale)
 {
     m_physicsScene.TaintedObject(inTaintTime, "BSActorAvatarMove.setVelocityAndTarget", delegate()
     {
         if (m_velocityMotor != null)
         {
             m_velocityMotor.Reset();
             m_velocityMotor.SetTarget(targ);
             m_velocityMotor.SetCurrent(vel);
             m_velocityMotor.TargetValueDecayTimeScale = targetValueDecayTimeScale;
             m_velocityMotor.Enabled = true;
         }
     });
 }
Beispiel #3
0
        // Usually called when target velocity changes to set the current velocity and the target
        //     into the movement motor.
        public void SetVelocityAndTarget(OMV.Vector3 vel, OMV.Vector3 targ, bool inTaintTime)
        {
            m_physicsScene.TaintedObject(inTaintTime, m_controllingPrim.LocalID, "BSActorAvatarMove.setVelocityAndTarget", delegate()
            {
                if (m_velocityMotor != null)
                {
//                    if (targ == OMV.Vector3.Zero)
//                        Util.PrintCallStack();
//
//                    Console.WriteLine("SetVelocityAndTarget, {0} {1}", vel, targ);
                    m_velocityMotor.Reset();
                    m_velocityMotor.SetTarget(targ);
                    m_velocityMotor.SetCurrent(vel);
                    m_velocityMotor.Enabled = true;
                }
            });
        }
Beispiel #4
0
        private void SetPhysicalProperties()
        {
            PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody);

            ZeroMotion(true);
            ForcePosition = _position;

            // Set the velocity and compute the proper friction
            _velocityMotor.Reset();
            _velocityMotor.SetTarget(_velocity);
            _velocityMotor.SetCurrent(_velocity);
            ForceVelocity = _velocity;

            // This will enable or disable the flying buoyancy of the avatar.
            // Needs to be reset especially when an avatar is recreated after crossing a region boundry.
            Flying = _flying;

            PhysicsScene.PE.SetRestitution(PhysBody, BSParam.AvatarRestitution);
            PhysicsScene.PE.SetMargin(PhysShape, PhysicsScene.Params.collisionMargin);
            PhysicsScene.PE.SetLocalScaling(PhysShape, Scale);
            PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
            if (BSParam.CcdMotionThreshold > 0f)
            {
                PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
                PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
            }

            UpdatePhysicalMassProperties(RawMass, false);

            // Make so capsule does not fall over
            PhysicsScene.PE.SetAngularFactorV(PhysBody, OMV.Vector3.Zero);

            PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT);

            PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody);

            // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
            PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION);
            PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody);

            // Do this after the object has been added to the world
            PhysBody.collisionType = CollisionType.Avatar;
            PhysBody.ApplyCollisionMask(PhysicsScene);
        }