protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_PhysicsComponentDefinitionBase;
            MassPropertiesComputation = ob.MassPropertiesComputation;
            RigidBodyFlags = ob.RigidBodyFlags;
            CollisionLayer = ob.CollisionLayer;
            LinearDamping = ob.LinearDamping;
            AngularDamping = ob.AngularDamping;
            ForceActivate = ob.ForceActivate;
            UpdateFlags = ob.UpdateFlags;
            Serialize = ob.Serialize;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_PhysicsComponentDefinitionBase;

            MassPropertiesComputation = ob.MassPropertiesComputation;
            RigidBodyFlags            = ob.RigidBodyFlags;
            CollisionLayer            = ob.CollisionLayer;
            LinearDamping             = ob.LinearDamping;
            AngularDamping            = ob.AngularDamping;
            ForceActivate             = ob.ForceActivate;
            UpdateFlags = ob.UpdateFlags;
            Serialize   = ob.Serialize;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyPhysicsBody"/> class.
        /// </summary>
        /// <param name="entity">The entity.</param>
        public MyPhysicsBody(MyEntity entity, float mass, RigidBodyFlag flags)
        {
            Debug.Assert(entity != null);

            this.m_enabled = false;
            this.Entity    = entity;

            MyPhysicsObjects physobj = AppCode.Physics.MyPhysics.physicsSystem.GetPhysicsObjects();
            MyRigidBodyDesc  rboDesc = physobj.GetRigidBodyDesc();

            rboDesc.SetToDefault();
            rboDesc.m_Mass   = mass;
            rboDesc.m_Matrix = entity.WorldMatrix;
            rboDesc.m_Flags |= flags;

            this.rigidBody            = physobj.CreateRigidBody(rboDesc);
            this.rigidBody.m_UserData = this;
        }
        /// <summary>
        /// default rigid body settings
        /// </summary>
        public void SetToDefault()
        {
            m_Matrix = Matrix.Identity;

            m_Mass = 1.0f;

            m_CenterOfMass = Vector3.Zero;

            m_Flags = 0;

            m_IterationCount = MyPhysicsConfig.DefaultIterationCount;

            m_MaxAngularVelocity = MyPhysicsConfig.DefaultMaxAngularVelocity;
            m_MaxLinearVelocity = MyPhysicsConfig.DefaultMaxLinearVelocity;
            m_SleepEnergyThreshold = MyPhysicsConfig.DefaultEnergySleepThreshold;
            m_LinearDamping = MyPhysicsConfig.DefaultLinearDamping;
            m_AngularDamping = MyPhysicsConfig.DefaultAngularDamping;
        }
        public static void InitSpherePhysics(this IMyEntity entity, MyStringHash materialType, Vector3 sphereCenter, float sphereRadius, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            mass = (rbFlag & RigidBodyFlag.RBF_STATIC) != 0 ? 0 : mass;

            var physics = new Sandbox.Engine.Physics.MyPhysicsBody(entity, rbFlag)
            {
                MaterialType = materialType,
                AngularDamping = angularDamping,
                LinearDamping = linearDamping
            };

            var massProperties = HkInertiaTensorComputer.ComputeSphereVolumeMassProperties(sphereRadius, mass);

            HkSphereShape shape = new HkSphereShape(sphereRadius);
            physics.CreateFromCollisionObject((HkShape)shape, sphereCenter, entity.PositionComp.WorldMatrix, massProperties);

            shape.Base.RemoveReference();
            entity.Physics = physics;
        }
        public static void InitBoxPhysics(this IMyEntity entity, MyStringHash materialType, Vector3 center, Vector3 size, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            System.Diagnostics.Debug.Assert(size.Length() > 0);

            mass = (rbFlag & RigidBodyFlag.RBF_STATIC) != 0 ? 0 : mass;

            var massProperties = HkInertiaTensorComputer.ComputeBoxVolumeMassProperties(size / 2, mass);

            var physics = new Sandbox.Engine.Physics.MyPhysicsBody(entity, rbFlag)
            {
                MaterialType = materialType,
                AngularDamping = angularDamping,
                LinearDamping = linearDamping
            };

            HkBoxShape shape = new HkBoxShape(size * 0.5f);
            physics.CreateFromCollisionObject((HkShape)shape, center, entity.PositionComp.WorldMatrix, massProperties);
            shape.Base.RemoveReference();

            entity.Physics = physics;
        }
        internal static void InitBoxPhysics(this IMyEntity entity, Matrix worldMatrix, MyStringHash materialType, Vector3 center, Vector3 size, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            mass = (rbFlag & RigidBodyFlag.RBF_STATIC) != 0 ? 0 : mass;

            var massProperties = HkInertiaTensorComputer.ComputeBoxVolumeMassProperties(size / 2, mass);

            var physicsBody = new Sandbox.Engine.Physics.MyPhysicsBody(null, rbFlag)
            {
                MaterialType = materialType,
                AngularDamping = angularDamping,
                LinearDamping = linearDamping
            };

            //BoxShape shape = new BoxShape(size * 0.5f);
            HkBoxShape shape = new HkBoxShape(size * 0.5f);
            physicsBody.CreateFromCollisionObject((HkShape)shape, center, worldMatrix, massProperties);
            shape.Base.RemoveReference();

            entity.Physics = physicsBody;
            //return physicsBody;
        }
Beispiel #8
0
        public static bool InitModelPhysics(this IMyEntity entity, RigidBodyFlag rbFlags = 2, int collisionLayers = 0x11)
        {
            MyEntity entity2 = entity as MyEntity;

            if (entity2.Closed)
            {
                return(false);
            }
            if ((entity2.ModelCollision.HavokCollisionShapes == null) || (entity2.ModelCollision.HavokCollisionShapes.Length == 0))
            {
                return(false);
            }
            List <HkShape> list  = entity2.ModelCollision.HavokCollisionShapes.ToList <HkShape>();
            HkListShape    shape = new HkListShape(list.GetInternalArray <HkShape>(), list.Count, HkReferencePolicy.None);

            entity2.Physics           = new MyPhysicsBody(entity2, rbFlags);
            entity2.Physics.IsPhantom = false;
            HkMassProperties?massProperties = null;

            (entity2.Physics as MyPhysicsBody).CreateFromCollisionObject((HkShape)shape, (Vector3)Vector3D.Zero, entity2.WorldMatrix, massProperties, collisionLayers);
            entity2.Physics.Enabled = true;
            shape.Base.RemoveReference();
            return(true);
        }
 protected void GetInfoFromFlags(HkRigidBodyCinfo rbInfo, RigidBodyFlag flags)
 {
     if ((int)(flags & RigidBodyFlag.RBF_STATIC) > 0)
     {
         rbInfo.MotionType = HkMotionType.Fixed;
         rbInfo.QualityType = HkCollidableQualityType.Fixed;
     }
     else if ((int)(flags & RigidBodyFlag.RBF_BULLET) > 0)
     {
         rbInfo.MotionType = HkMotionType.Dynamic;
         rbInfo.QualityType = HkCollidableQualityType.Bullet;
     }
     else if ((int)(flags & RigidBodyFlag.RBF_KINEMATIC) > 0)
     {
         rbInfo.MotionType = HkMotionType.Keyframed;
         rbInfo.QualityType = HkCollidableQualityType.Keyframed;
     }
     else if ((int)(flags & RigidBodyFlag.RBF_DOUBLED_KINEMATIC) > 0)
     {
         rbInfo.MotionType = HkMotionType.Dynamic;
         rbInfo.QualityType = HkCollidableQualityType.Moving;
     }
     else if ((int)(flags & RigidBodyFlag.RBF_DISABLE_COLLISION_RESPONSE) > 0)
     {
         rbInfo.MotionType = HkMotionType.Fixed;
         rbInfo.QualityType = HkCollidableQualityType.Fixed;
         //rbInfo.CollisionResponse = HkResponseType.None;
     }
     else if ((int)(flags & RigidBodyFlag.RBF_DEBRIS) > 0)
     {
         rbInfo.MotionType = HkMotionType.Dynamic;
         rbInfo.QualityType = HkCollidableQualityType.Debris;
     }
     else if ((int)(flags & RigidBodyFlag.RBF_KEYFRAMED_REPORTING) > 0)
     {
         rbInfo.MotionType = HkMotionType.Keyframed;
         rbInfo.QualityType = HkCollidableQualityType.KeyframedReporting;
     }
     else
     {
         rbInfo.MotionType = HkMotionType.Dynamic;
         rbInfo.QualityType = HkCollidableQualityType.Moving;
     }
 }
Beispiel #10
0
 public MyDebrisPhysics(IMyEntity Entity1, RigidBodyFlag rigidBodyFlag) 
    : base(Entity1, rigidBodyFlag)
 {
 }
Beispiel #11
0
        public static void InitCapsulePhysics(this IMyEntity entity, MyStringHash materialType, Vector3 vertexA, Vector3 vertexB, float radius, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            float single1 = mass;

            mass = ((rbFlag & RigidBodyFlag.RBF_STATIC) != RigidBodyFlag.RBF_DEFAULT) ? 0f : single1;
            MyPhysicsBody body1 = new MyPhysicsBody(entity, rbFlag);

            body1.MaterialType   = materialType;
            body1.AngularDamping = angularDamping;
            body1.LinearDamping  = linearDamping;
            MyPhysicsBody    body       = body1;
            HkMassProperties properties = HkInertiaTensorComputer.ComputeSphereVolumeMassProperties(radius, mass);

            body.ReportAllContacts = true;
            HkCapsuleShape shape = new HkCapsuleShape(vertexA, vertexB, radius);

            body.CreateFromCollisionObject((HkShape)shape, (vertexA + vertexB) / 2f, entity.PositionComp.WorldMatrix, new HkMassProperties?(properties), 15);
            shape.Base.RemoveReference();
            entity.Physics = body;
        }
 public MyDebrisVoxelPhysics(ModAPI.IMyEntity Entity1, RigidBodyFlag rigidBodyFlag) : base(Entity1, rigidBodyFlag)
 {
 }
Beispiel #13
0
 public static void InitSpherePhysics(this IMyEntity entity, MyStringHash materialType, MyModel model, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
 {
     Debug.Assert(model != null);
     entity.InitSpherePhysics(materialType, model.BoundingSphere.Center, model.BoundingSphere.Radius, mass, linearDamping, angularDamping, collisionLayer, rbFlag);
 }
Beispiel #14
0
        public static void InitCharacterPhysics(this IMyEntity entity, MyStringHash materialType, Vector3 center, float characterWidth, float characterHeight, float crouchHeight, float ladderHeight, float headSize, float headHeight, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag, float mass, bool isOnlyVertical, float maxSlope, bool networkProxy)
        {
            var physics = new Sandbox.Engine.Physics.MyPhysicsBody(entity, rbFlag)
            {
                MaterialType   = materialType,
                AngularDamping = angularDamping,
                LinearDamping  = linearDamping
            };

            //BoxShape shape = new BoxShape(SharpDXHelper.ToSharpDX(size * 0.5f));
            //this.m_physics.CreateFromCollisionObject(shape, center, WorldMatrix);
            physics.CreateCharacterCollision(center, characterWidth, characterHeight, crouchHeight, ladderHeight, headSize, headHeight, entity.PositionComp.WorldMatrix, mass, collisionLayer, isOnlyVertical, maxSlope, networkProxy);
            entity.Physics = physics;
        }
Beispiel #15
0
 public MyDebrisVoxelPhysics(IMyEntity entity, RigidBodyFlag rigidBodyFlag) : base(entity, rigidBodyFlag)
 {
 }
Beispiel #16
0
        public void InitBoxPhysics(MyMaterialType materialType, Vector3 center, Vector3 size, float mass, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            UseKinematicPhysics = (rbFlag & RigidBodyFlag.RBF_KINEMATIC) != 0;

            MyPhysicsObjects physobj = MyPhysics.physicsSystem.GetPhysicsObjects();

            MyRBBoxElementDesc boxDesc = physobj.GetRBBoxElementDesc();
            boxDesc.SetToDefault();
            boxDesc.m_RBMaterial = MyMaterialsConstants.GetMaterialProperties(materialType).PhysicsMaterial;
            boxDesc.m_Size = size;
            boxDesc.m_Matrix.Translation = center;
            boxDesc.m_CollisionLayer = collisionLayer;

            MyRBBoxElement boxEl = (MyRBBoxElement)physobj.CreateRBElement(boxDesc);
            System.Diagnostics.Debug.Assert(boxEl != null);
            if (boxEl != null)
            {
                //System.Diagnostics.Debug.Assert(Physics == null || !Physics.Enabled);
                // Remove object from physics
                if (Physics != null && Physics.Enabled)
                {                    
                    Physics.Enabled = false;
                    Physics.RemoveAllElements();
                    Physics.Close();
                    Physics = null;
                }

                // Create new physics
                this.Physics = new MinerWars.AppCode.Game.Physics.MyPhysicsBody(this, mass, rbFlag)
                {
                    MaterialType = materialType,
                    AngularDamping = angularDamping
                };                

                this.Physics.AddElement(boxEl, true);
            }
        }
Beispiel #17
0
 public void InitSpherePhysics(MyMaterialType materialType, MyModel model, float mass, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
 {
     Debug.Assert(model != null);
     InitSpherePhysics(materialType, model.BoundingSphere.Center, model.BoundingSphere.Radius, mass, angularDamping, collisionLayer, rbFlag);
 }
Beispiel #18
0
 protected override MyPhysicsComponentBase GetPhysics(RigidBodyFlag rigidBodyFlag)
 {
     return(new MyDebrisVoxelPhysics(Container.Entity, rigidBodyFlag));
 }
Beispiel #19
0
 protected virtual MyPhysicsComponentBase GetPhysics(RigidBodyFlag rigidBodyFlag) =>
 new MyDebrisBase.MyDebrisPhysics(base.Container.Entity, rigidBodyFlag);
Beispiel #20
0
        public static void InitCharacterPhysics(this IMyEntity entity, MyStringHash materialType, Vector3 center, float characterWidth, float characterHeight, float crouchHeight, float ladderHeight, float headSize, float headHeight, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag, float mass, bool isOnlyVertical, float maxSlope, float maxImpulse, float maxSpeedRelativeToShip, bool networkProxy, float?maxForce)
        {
            MyPhysicsBody body1 = new MyPhysicsBody(entity, rbFlag);

            body1.MaterialType   = materialType;
            body1.AngularDamping = angularDamping;
            body1.LinearDamping  = linearDamping;
            MyPhysicsBody body = body1;

            body.CreateCharacterCollision(center, characterWidth, characterHeight, crouchHeight, ladderHeight, headSize, headHeight, entity.PositionComp.WorldMatrix, mass, collisionLayer, isOnlyVertical, maxSlope, maxImpulse, maxSpeedRelativeToShip, networkProxy, maxForce);
            entity.Physics = body;
        }
        public static void InitCapsulePhysics(this IMyEntity entity, MyStringId materialType, Vector3 vertexA, Vector3 vertexB, float radius, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            mass = (rbFlag & RigidBodyFlag.RBF_STATIC) != 0 ? 0 : mass;

            var physics = new Sandbox.Engine.Physics.MyPhysicsBody(entity, rbFlag)
            {
                MaterialType = materialType,
                AngularDamping = angularDamping,
                LinearDamping = linearDamping
            };

            var massProperties = HkInertiaTensorComputer.ComputeSphereVolumeMassProperties(radius, mass);

            physics.ReportAllContacts = true;
            HkCapsuleShape shape = new HkCapsuleShape(vertexA, vertexB, radius);
            physics.CreateFromCollisionObject((HkShape)shape, (vertexA + vertexB) / 2, entity.PositionComp.WorldMatrix, massProperties);
            shape.Base.RemoveReference();
            entity.Physics = physics;
        }
Beispiel #22
0
 protected override MyPhysicsComponentBase GetPhysics(RigidBodyFlag rigidBodyFlag) =>
 new MyDebrisVoxel.MyDebrisVoxelPhysics(base.Container.Entity, rigidBodyFlag);
Beispiel #23
0
 public void InitBoxPhysics(MyMaterialType materialType, MyModel model, float mass, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
 {
     Debug.Assert(model != null);
     var center = model.BoundingBox.GetCenter();
     var size = model.BoundingBoxSize;
     InitBoxPhysics(materialType, center, size, mass, angularDamping, collisionLayer, rbFlag);
 }
Beispiel #24
0
        public static void InitBoxPhysics(this IMyEntity entity, MyStringHash materialType, MyModel model, float mass, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            Vector3 center = model.BoundingBox.Center;

            entity.InitBoxPhysics(materialType, center, model.BoundingBoxSize, mass, 0f, angularDamping, collisionLayer, rbFlag);
        }
 public static void InitSpherePhysics(this IMyEntity entity, MyStringHash materialType, MyModel model, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
 {
     Debug.Assert(model != null);
     entity.InitSpherePhysics(materialType, model.BoundingSphere.Center, model.BoundingSphere.Radius, mass, linearDamping, angularDamping, collisionLayer, rbFlag);
 }
Beispiel #26
0
        public static void InitSpherePhysics(this IMyEntity entity, MyStringHash materialType, Vector3 sphereCenter, float sphereRadius, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            mass = (rbFlag & RigidBodyFlag.RBF_STATIC) != 0 ? 0 : mass;

            var physics = new Sandbox.Engine.Physics.MyPhysicsBody(entity, rbFlag)
            {
                MaterialType   = materialType,
                AngularDamping = angularDamping,
                LinearDamping  = linearDamping
            };

            var massProperties = HkInertiaTensorComputer.ComputeSphereVolumeMassProperties(sphereRadius, mass);

            HkSphereShape shape = new HkSphereShape(sphereRadius);

            physics.CreateFromCollisionObject((HkShape)shape, sphereCenter, entity.PositionComp.WorldMatrix, massProperties);

            shape.Base.RemoveReference();
            entity.Physics = physics;
        }
        public static void InitCharacterPhysics(this IMyEntity entity, MyStringHash materialType, Vector3 center, float characterWidth, float characterHeight, float crouchHeight, float ladderHeight, float headSize, float headHeight, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag, float mass, bool isOnlyVertical, float maxSlope, bool networkProxy)
        {
            var physics = new Sandbox.Engine.Physics.MyPhysicsBody(entity, rbFlag)
            {
                MaterialType = materialType,
                AngularDamping = angularDamping,
                LinearDamping = linearDamping
            };

            //BoxShape shape = new BoxShape(SharpDXHelper.ToSharpDX(size * 0.5f));
            //this.m_physics.CreateFromCollisionObject(shape, center, WorldMatrix);
            physics.CreateCharacterCollision(center, characterWidth, characterHeight, crouchHeight, ladderHeight, headSize, headHeight, entity.PositionComp.WorldMatrix, mass, collisionLayer, isOnlyVertical, maxSlope, networkProxy);
            entity.Physics = physics;
        }
Beispiel #28
0
 public MyDebrisTreePhysics(IMyEntity entity, RigidBodyFlag rigidBodyFlags) : base(entity, rigidBodyFlags)
 {
 }
        public override void Init(MyComponentDefinitionBase definition)
        {
            base.Init(definition);

            Definition = definition as MyPhysicsComponentDefinitionBase;
            Debug.Assert(Definition != null);
            if (Definition != null)
            {
                Flags = Definition.RigidBodyFlags;

                if (Definition.LinearDamping != null)
                    LinearDamping = Definition.LinearDamping.Value;

                if (Definition.AngularDamping != null)
                    AngularDamping = Definition.AngularDamping.Value;
            }
        }
Beispiel #30
0
        public static void InitCapsulePhysics(this IMyEntity entity, MyStringId materialType, Vector3 vertexA, Vector3 vertexB, float radius, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            mass = (rbFlag & RigidBodyFlag.RBF_STATIC) != 0 ? 0 : mass;

            var physics = new Sandbox.Engine.Physics.MyPhysicsBody(entity, rbFlag)
            {
                MaterialType   = materialType,
                AngularDamping = angularDamping,
                LinearDamping  = linearDamping
            };

            var massProperties = HkInertiaTensorComputer.ComputeSphereVolumeMassProperties(radius, mass);

            physics.ReportAllContacts = true;
            HkCapsuleShape shape = new HkCapsuleShape(vertexA, vertexB, radius);

            physics.CreateFromCollisionObject((HkShape)shape, (vertexA + vertexB) / 2, entity.PositionComp.WorldMatrix, massProperties);
            shape.Base.RemoveReference();
            entity.Physics = physics;
        }
Beispiel #31
0
        internal static void InitBoxPhysics(this IMyEntity entity, Matrix worldMatrix, MyStringHash materialType, Vector3 center, Vector3 size, float mass, float linearDamping, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
        {
            float single1 = mass;

            mass = ((rbFlag & RigidBodyFlag.RBF_STATIC) != RigidBodyFlag.RBF_DEFAULT) ? 0f : single1;
            HkMassProperties properties = HkInertiaTensorComputer.ComputeBoxVolumeMassProperties(size / 2f, mass);
            MyPhysicsBody    body1      = new MyPhysicsBody(null, rbFlag);

            body1.MaterialType   = materialType;
            body1.AngularDamping = angularDamping;
            body1.LinearDamping  = linearDamping;
            MyPhysicsBody body  = body1;
            HkBoxShape    shape = new HkBoxShape(size * 0.5f);

            body.CreateFromCollisionObject((HkShape)shape, center, worldMatrix, new HkMassProperties?(properties), 15);
            shape.Base.RemoveReference();
            entity.Physics = body;
        }
Beispiel #32
0
        public void RaiseFlag(RigidBodyFlag flag)
        {
            if ((flag & RigidBodyFlag.RBF_ACTIVE) > 0)
                m_DeactivationTimer = GLOBAL_DEACTIVATION_TIMER;

            m_Flags |= flag;
        }
Beispiel #33
0
 public bool ReadFlag(RigidBodyFlag flags) { return (flags & m_Flags) != 0; }
 public static void InitBoxPhysics(this IMyEntity entity, MyStringHash materialType, MyModel model, float mass, float angularDamping, ushort collisionLayer, RigidBodyFlag rbFlag)
 {
     Debug.Assert(model != null);
     var center = model.BoundingBox.Center;
     var size = model.BoundingBoxSize;
     entity.InitBoxPhysics(materialType, center, size, mass, 0, angularDamping, collisionLayer, rbFlag);
 }
Beispiel #35
0
 public void ClearFlag(RigidBodyFlag flag)
 {
     m_Flags &= ~flag;
 }
Beispiel #36
0
 protected override MyPhysicsComponentBase GetPhysics(RigidBodyFlag rigidBodyFlag)
 {
     return new MyDebrisVoxelPhysics(Container.Entity, rigidBodyFlag);
 }
Beispiel #37
0
 private void SetInitialFlags(RigidBodyFlag flags)
 {
     m_Flags = flags;
 }
Beispiel #38
0
 protected virtual MyPhysicsComponentBase GetPhysics(RigidBodyFlag rigidBodyFlag)
 {
     return new MyDebrisPhysics(Container.Entity, rigidBodyFlag);
 }
Beispiel #39
0
        /// <summary>
        /// Internal set, calculation of kinematic speed is handled in public property set.
        /// </summary>
        /// <param name="matrix">The matrix.</param>
        internal void SetMatrix(Matrix matrix)
        {
            m_Matrix = matrix;

            foreach (var el in GetRBElementList())
            {
                el.Flags |= MyElementFlag.EF_AABB_DIRTY;
                MyPhysics.physicsSystem.GetRigidBodyModule().GetBroadphase().MoveVolumeFast(el);
            }

            if (IsStatic()) //We dont want to update static object (performance)
            {
                return;
            }

            m_Flags |= RigidBodyFlag.RBF_DIRTY;
            WakeUp();
        }
Beispiel #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MyPhysicsBody"/> class.
 /// </summary>
 /// <param name="entity">The entity.</param>
 public MyPhysicsBody(IMyEntity entity, RigidBodyFlag flags)
 {
     //Debug.Assert(entity != null);           
     this.m_enabled = false;
     this.Entity = entity;
     this.Flags = flags;
 }
 public MyControlledPhysicsBody(IMyEntity entity, RigidBodyFlag flags) 
     : base(entity, flags) 
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MyPhysicsBody"/> class.
 /// </summary>
 /// <param name="entity">The entity.</param>
 public MyPhysicsBody(Sandbox.ModAPI.IMyEntity entity, RigidBodyFlag flags)
 {
     //Debug.Assert(entity != null);
     this.IsRagdollModeActive = false;
     this.m_enabled = false;
     this.Entity = entity;
     this.Flags = flags;
 }
Beispiel #43
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyPhysicsBody"/> class.
        /// </summary>
        /// <param name="entity">The entity.</param>
        public MyPhysicsBody(MyEntity entity, float mass, RigidBodyFlag flags)
        {
            Debug.Assert(entity != null);

            this.m_enabled = false;
            this.Entity = entity;

            MyPhysicsObjects physobj = AppCode.Physics.MyPhysics.physicsSystem.GetPhysicsObjects();
            MyRigidBodyDesc rboDesc = physobj.GetRigidBodyDesc();

            rboDesc.SetToDefault();
            rboDesc.m_Mass = mass;
            rboDesc.m_Matrix = entity.WorldMatrix;
            rboDesc.m_Flags |= flags;

            this.rigidBody = physobj.CreateRigidBody(rboDesc);
            this.rigidBody.m_UserData = this;
        }