public void Dispose()
        {
            if (CharacterProxy != null)
            {
                CharacterProxy.Dispose();
                CharacterProxy = null;
            }

            if (CharacterPhantom != null)
            {
                CharacterPhantom.Dispose();
                CharacterPhantom = null;
            }

            if (CharacterRigidBody != null)
            {
                if (CharacterRigidBody.GetRigidBody() != null)
                {
                    CharacterRigidBody.GetRigidBody().ContactPointCallback -= RigidBody_ContactPointCallback;
                }
                CharacterRigidBody.Dispose();
                CharacterRigidBody = null;
            }

            m_characterShape.RemoveReference();
            m_characterCollisionShape.RemoveReference();
            m_crouchShape.RemoveReference();
        }
Пример #2
0
 public void Dispose()
 {
     if (this.CharacterProxy != null)
     {
         this.CharacterProxy.Dispose();
         this.CharacterProxy = null;
     }
     if (this.CharacterPhantom != null)
     {
         this.CharacterPhantom.Dispose();
         this.CharacterPhantom = null;
     }
     if (this.CharacterRigidBody != null)
     {
         if (this.CharacterRigidBody.GetRigidBody() != null)
         {
             this.CharacterRigidBody.GetRigidBody().ContactPointCallback -= new ContactPointEventHandler(this.RigidBody_ContactPointCallback);
         }
         this.CharacterRigidBody.Dispose();
         this.CharacterRigidBody = null;
     }
     this.m_characterShape.RemoveReference();
     this.m_characterCollisionShape.RemoveReference();
     this.m_crouchShape.RemoveReference();
 }
Пример #3
0
        public void Dispose()
        {
            if (CharacterProxy != null)
            {
                CharacterProxy.Dispose();
                CharacterProxy = null;
            }

            if (CharacterPhantom != null)
            {
                CharacterPhantom.Dispose();
                CharacterPhantom = null;
            }

            if (CharacterRigidBody != null)
            {
                CharacterRigidBody.Dispose();
                CharacterRigidBody = null;
            }

            m_characterShape.RemoveReference();
            m_characterCollisionShape.RemoveReference();
            m_crouchShape.RemoveReference();
        }
Пример #4
0
        public MyCharacterProxy(bool isDynamic, bool isCapsule, float characterWidth, float characterHeight,
                                float crouchHeight, float ladderHeight, float headSize, float headHeight,
                                Vector3 position, Vector3 up, Vector3 forward,
                                float mass, MyPhysicsBody body, bool isOnlyVertical, float maxSlope, float maxImpulse, float maxSpeedRelativeToShip, float?maxForce = null, HkRagdoll ragDoll = null)
        {
            m_isDynamic              = isDynamic;
            m_physicsBody            = body;
            m_mass                   = mass;
            m_maxImpulse             = maxImpulse;
            m_maxSpeedRelativeToShip = maxSpeedRelativeToShip;

            if (isCapsule)
            {
                m_characterShape          = CreateCharacterShape(characterHeight, characterWidth, characterHeight + headHeight, headSize, 0, 0);
                m_characterCollisionShape = CreateCharacterShape(characterHeight * 0.9f, characterWidth * 0.9f, characterHeight * 0.9f + headHeight, headSize * 0.9f, 0, 0);
                m_crouchShape             = CreateCharacterShape(characterHeight, characterWidth, characterHeight + headHeight, headSize, 0.0f, 1.0f);

                if (!m_isDynamic)
                {
                    CharacterPhantom = new HkSimpleShapePhantom(m_characterShape, MyPhysics.CollisionLayers.CharacterCollisionLayer);
                }
            }
            else
            {
                HkBoxShape box = new HkBoxShape(new Vector3(characterWidth / 2.0f, characterHeight / 2.0f, characterWidth / 2.0f));
                if (!m_isDynamic)
                {
                    CharacterPhantom = new HkSimpleShapePhantom((HkShape)box, MyPhysics.CollisionLayers.CharacterCollisionLayer);
                }
                m_characterShape = box;
            }

            if (!m_isDynamic)
            {
                HkCharacterProxyCinfo characterProxyInfo = new HkCharacterProxyCinfo();
                characterProxyInfo.StaticFriction          = 1;
                characterProxyInfo.DynamicFriction         = 1;
                characterProxyInfo.ExtraDownStaticFriction = 1000;
                //characterProxyInfo.ContactAngleSensitivity = 20;
                //characterProxyInfo.KeepContactTolerance = 1f;
                characterProxyInfo.MaxCharacterSpeedForSolver    = 10000;
                characterProxyInfo.RefreshManifoldInCheckSupport = true;
                characterProxyInfo.Up                = up;
                characterProxyInfo.Forward           = forward;
                characterProxyInfo.UserPlanes        = 4;
                characterProxyInfo.MaxSlope          = MathHelper.ToRadians(maxSlope);
                characterProxyInfo.Position          = position;
                characterProxyInfo.CharacterMass     = mass;
                characterProxyInfo.CharacterStrength = 100;
                characterProxyInfo.ShapePhantom      = CharacterPhantom;

                CharacterProxy = new HkCharacterProxy(characterProxyInfo);

                characterProxyInfo.Dispose();
            }
            else
            {
                HkCharacterRigidBodyCinfo characterRBCInfo = new HkCharacterRigidBodyCinfo();
                characterRBCInfo.Shape               = m_characterShape;
                characterRBCInfo.CrouchShape         = m_crouchShape;
                characterRBCInfo.Friction            = 0;
                characterRBCInfo.MaxSlope            = MathHelper.ToRadians(maxSlope);
                characterRBCInfo.Up                  = up;
                characterRBCInfo.Mass                = mass;
                characterRBCInfo.CollisionFilterInfo = MyPhysics.CollisionLayers.CharacterCollisionLayer;
                //characterRBCInfo.UnweldingHeightOffsetFactor = 100;
                characterRBCInfo.MaxLinearVelocity       = 1000000;
                characterRBCInfo.MaxForce                = maxForce.HasValue ? maxForce.Value : 100000;
                characterRBCInfo.AllowedPenetrationDepth = MyFakes.ENABLE_LIMITED_CHARACTER_BODY ? 0.3f : 0.1f;
                characterRBCInfo.JumpHeight              = 0.8f;

                bool  shouldLimitSpeed  = Sync.IsServer;
                float maxCharacterSpeed = shouldLimitSpeed ? (MyGridPhysics.ShipMaxLinearVelocity() + m_maxSpeedRelativeToShip) : MyGridPhysics.MAX_SHIP_SPEED;
                CharacterRigidBody = new HkCharacterRigidBody(characterRBCInfo, maxCharacterSpeed, body, isOnlyVertical);

                CharacterRigidBody.GetRigidBody().ContactPointCallbackEnabled = true;
                CharacterRigidBody.GetRigidBody().ContactPointCallback       += RigidBody_ContactPointCallback;
                CharacterRigidBody.GetRigidBody().ContactPointCallbackDelay   = 0;

                //CharacterRigidBody.GetHitRigidBody().ContactPointCallbackEnabled = true;
                //CharacterRigidBody.GetHitRigidBody().ContactPointCallback += RigidBody_ContactPointCallback;
                //CharacterRigidBody.GetHitRigidBody().ContactPointCallbackDelay = 0;

                //CharacterRigidBody.SetSupportDistance(10);
                //CharacterRigidBody.SetHardSupportDistance(10);

                characterRBCInfo.Dispose();
            }
        }
Пример #5
0
        public MyCharacterProxy(bool isDynamic, bool isCapsule, float characterWidth, float characterHeight,
            float crouchHeight, float ladderHeight, float headSize, float headHeight,
            Vector3 position, Vector3 up, Vector3 forward,
            float mass, MyPhysicsBody body, bool isOnlyVertical, float maxSlope, float maxImpulse, HkRagdoll ragDoll = null)
        {
            m_isDynamic = isDynamic;
            m_physicsBody = body;
            m_mass =  mass;
            m_maxImpulse = maxImpulse;

            if (isCapsule)
            {
                m_characterShape = CreateCharacterShape(characterHeight, characterWidth, characterHeight + headHeight, headSize, 0, 0);
                m_characterCollisionShape = CreateCharacterShape(characterHeight * 0.9f, characterWidth * 0.9f, characterHeight * 0.9f + headHeight, headSize * 0.9f, 0, 0);
                m_crouchShape = CreateCharacterShape(characterHeight, characterWidth, characterHeight + headHeight, headSize, 0.0f, 1.0f);

                if (!m_isDynamic)
                    CharacterPhantom = new HkSimpleShapePhantom(m_characterShape, MyPhysics.CharacterCollisionLayer);
            }
            else
            {
                HkBoxShape box = new HkBoxShape(new Vector3(characterWidth / 2.0f, characterHeight / 2.0f, characterWidth / 2.0f));
                if (!m_isDynamic)
                    CharacterPhantom = new HkSimpleShapePhantom((HkShape)box, MyPhysics.CharacterCollisionLayer);
                m_characterShape = box;
            }

            if (!m_isDynamic)
            {
                HkCharacterProxyCinfo characterProxyInfo = new HkCharacterProxyCinfo();
                characterProxyInfo.StaticFriction = 1;
                characterProxyInfo.DynamicFriction = 1;
                characterProxyInfo.ExtraDownStaticFriction = 1000;
                //characterProxyInfo.ContactAngleSensitivity = 20;
                //characterProxyInfo.KeepContactTolerance = 1f;
                characterProxyInfo.MaxCharacterSpeedForSolver = 10000;
                characterProxyInfo.RefreshManifoldInCheckSupport = true;
                characterProxyInfo.Up = up;
                characterProxyInfo.Forward = forward;
                characterProxyInfo.UserPlanes = 4;
                characterProxyInfo.MaxSlope = MathHelper.ToRadians(maxSlope);
                characterProxyInfo.Position = position;
                characterProxyInfo.CharacterMass = mass;
                characterProxyInfo.CharacterStrength = 100;
                characterProxyInfo.ShapePhantom = CharacterPhantom;

                CharacterProxy = new HkCharacterProxy(characterProxyInfo);

                characterProxyInfo.Dispose();          
            }
            else
            {
                HkCharacterRigidBodyCinfo characterRBCInfo = new HkCharacterRigidBodyCinfo();
                characterRBCInfo.Shape = m_characterShape;
                characterRBCInfo.CrouchShape = m_crouchShape;
                characterRBCInfo.Friction = 0;
                characterRBCInfo.MaxSlope = MathHelper.ToRadians(maxSlope);
                characterRBCInfo.Up = up;
                characterRBCInfo.Mass = mass;
                characterRBCInfo.CollisionFilterInfo = MyPhysics.CharacterCollisionLayer;
                //characterRBCInfo.UnweldingHeightOffsetFactor = 100;
                characterRBCInfo.MaxLinearVelocity = 1000000;
                characterRBCInfo.MaxForce = 100000;
                characterRBCInfo.AllowedPenetrationDepth = 0.1f;
                characterRBCInfo.JumpHeight = 0.8f;


                CharacterRigidBody = new HkCharacterRigidBody(characterRBCInfo, MyGridPhysics.ShipMaxLinearVelocity(), body, isOnlyVertical);

                CharacterRigidBody.GetRigidBody().ContactPointCallbackEnabled = true;
                CharacterRigidBody.GetRigidBody().ContactPointCallback += RigidBody_ContactPointCallback;
                CharacterRigidBody.GetRigidBody().ContactPointCallbackDelay = 0;

                //CharacterRigidBody.GetHitRigidBody().ContactPointCallbackEnabled = true;
                //CharacterRigidBody.GetHitRigidBody().ContactPointCallback += RigidBody_ContactPointCallback;
                //CharacterRigidBody.GetHitRigidBody().ContactPointCallbackDelay = 0;

                //CharacterRigidBody.SetSupportDistance(10);
                //CharacterRigidBody.SetHardSupportDistance(10);

                characterRBCInfo.Dispose();
            }            
        }
Пример #6
0
        public void Dispose()
        {
            if (CharacterProxy != null)
            {
                CharacterProxy.Dispose();
                CharacterProxy = null;
            }

            if (CharacterPhantom != null)
            {
                CharacterPhantom.Dispose();
                CharacterPhantom = null;
            }

            if (CharacterRigidBody != null)
            {
                CharacterRigidBody.Dispose();
                CharacterRigidBody = null;
            }

            m_characterShape.RemoveReference();
            m_characterCollisionShape.RemoveReference();
            m_crouchShape.RemoveReference();
        }
Пример #7
0
        public void Dispose()
        {
            if (CharacterProxy != null)
            {
                CharacterProxy.Dispose();
                CharacterProxy = null;
            }

            if (CharacterPhantom != null)
            {
                CharacterPhantom.Dispose();
                CharacterPhantom = null;
            }

            if (CharacterRigidBody != null)
            {
                if (CharacterRigidBody.GetRigidBody() != null)
                {
                    CharacterRigidBody.GetRigidBody().ContactPointCallback -= RigidBody_ContactPointCallback;
                }
                CharacterRigidBody.Dispose();
                CharacterRigidBody = null;
            }

            m_characterShape.RemoveReference();
            m_characterCollisionShape.RemoveReference();
            m_crouchShape.RemoveReference();
        }
Пример #8
0
 public MyCharacterProxy(bool isDynamic, bool isCapsule, float characterWidth, float characterHeight, float crouchHeight, float ladderHeight, float headSize, float headHeight, Vector3 position, Vector3 up, Vector3 forward, float mass, MyPhysicsBody body, bool isOnlyVertical, float maxSlope, float maxImpulse, float maxSpeedRelativeToShip, float?maxForce = new float?(), HkRagdoll ragDoll = null)
 {
     this.m_isDynamic              = isDynamic;
     this.m_physicsBody            = body;
     this.m_mass                   = mass;
     this.m_maxImpulse             = maxImpulse;
     this.m_maxSpeedRelativeToShip = maxSpeedRelativeToShip;
     if (!isCapsule)
     {
         HkBoxShape shape = new HkBoxShape(new Vector3(characterWidth / 2f, characterHeight / 2f, characterWidth / 2f));
         if (!this.m_isDynamic)
         {
             this.CharacterPhantom = new HkSimpleShapePhantom((HkShape)shape, 0x12);
         }
         this.m_characterShape = (HkShape)shape;
     }
     else
     {
         this.m_characterShape          = CreateCharacterShape(characterHeight, characterWidth, characterHeight + headHeight, headSize, 0f, 0f, false);
         this.m_characterCollisionShape = CreateCharacterShape(characterHeight * 0.9f, characterWidth * 0.9f, (characterHeight * 0.9f) + headHeight, headSize * 0.9f, 0f, 0f, false);
         this.m_crouchShape             = CreateCharacterShape(characterHeight, characterWidth, characterHeight + headHeight, headSize, 0f, 1f, false);
         if (!this.m_isDynamic)
         {
             this.CharacterPhantom = new HkSimpleShapePhantom(this.m_characterShape, 0x12);
         }
     }
     if (!this.m_isDynamic)
     {
         HkCharacterProxyCinfo characterProxyCinfo = new HkCharacterProxyCinfo {
             StaticFriction                = 1f,
             DynamicFriction               = 1f,
             ExtraDownStaticFriction       = 1000f,
             MaxCharacterSpeedForSolver    = 10000f,
             RefreshManifoldInCheckSupport = true,
             Up                = up,
             Forward           = forward,
             UserPlanes        = 4,
             MaxSlope          = MathHelper.ToRadians(maxSlope),
             Position          = position,
             CharacterMass     = mass,
             CharacterStrength = 100f,
             ShapePhantom      = this.CharacterPhantom
         };
         this.CharacterProxy = new HkCharacterProxy(characterProxyCinfo);
         characterProxyCinfo.Dispose();
     }
     else
     {
         HkCharacterRigidBodyCinfo characterRigidBodyCinfo = new HkCharacterRigidBodyCinfo {
             Shape                   = this.m_characterShape,
             CrouchShape             = this.m_crouchShape,
             Friction                = 0f,
             MaxSlope                = MathHelper.ToRadians(maxSlope),
             Up                      = up,
             Mass                    = mass,
             CollisionFilterInfo     = 0x12,
             MaxLinearVelocity       = 1000000f,
             MaxForce                = (maxForce != null) ? maxForce.Value : 100000f,
             AllowedPenetrationDepth = MyFakes.ENABLE_LIMITED_CHARACTER_BODY ? 0.3f : 0.1f,
             JumpHeight              = 0.8f
         };
         float maxCharacterSpeed = MyGridPhysics.ShipMaxLinearVelocity() + this.m_maxSpeedRelativeToShip;
         this.CharacterRigidBody    = new HkCharacterRigidBody(characterRigidBodyCinfo, maxCharacterSpeed, body);
         this.m_maxCharacterSpeedSq = maxCharacterSpeed * maxCharacterSpeed;
         this.CharacterRigidBody.GetRigidBody().ContactPointCallbackEnabled = true;
         this.CharacterRigidBody.GetRigidBody().ContactPointCallback       -= new ContactPointEventHandler(this.RigidBody_ContactPointCallback);
         this.CharacterRigidBody.GetRigidBody().ContactPointCallback       += new ContactPointEventHandler(this.RigidBody_ContactPointCallback);
         this.CharacterRigidBody.GetRigidBody().ContactPointCallbackDelay   = 0;
         Matrix inertiaTensor = this.CharacterRigidBody.GetHitRigidBody().InertiaTensor;
         inertiaTensor.M11 = 1000f;
         inertiaTensor.M22 = 1000f;
         inertiaTensor.M33 = 1000f;
         this.CharacterRigidBody.GetHitRigidBody().InertiaTensor = inertiaTensor;
         characterRigidBodyCinfo.Dispose();
     }
 }