public MyRigidBody CreateRigidBody(MyRigidBodyDesc desc)
        {
            if (!desc.IsValid())
            {
                // invalid desc
                MyCommonDebugUtils.AssertDebug(false);
                return(null);
            }

            MyRigidBody rbo = m_RigidsPool.Allocate();

            MyCommonDebugUtils.AssertDebug(rbo != null);

            rbo.LoadFromDesc(desc);

            return(rbo);
        }
        public MyRigidBody CreateRigidBody(MyRigidBodyDesc desc)
        {
            if (!desc.IsValid())
            {
                // invalid desc
                MyCommonDebugUtils.AssertDebug(false);
                return null;
            }

            MyRigidBody rbo = m_RigidsPool.Allocate();

            MyCommonDebugUtils.AssertDebug(rbo != null);

            rbo.LoadFromDesc(desc);

            return rbo;
        }
        /// <summary>
        /// Loads properties of rbo from descriptor
        /// </summary>
        public bool LoadFromDesc(MyRigidBodyDesc desc)
        {
            if ((m_Flags & RigidBodyFlag.RBF_INSERTED) > 0)
            {
                return(false);
            }

            if (!desc.IsValid())
            {
                return(false);
            }

            m_Mass        = desc.m_Mass;
            m_OneOverMass = 1.0f / m_Mass;
            m_Matrix      = desc.m_Matrix;

            m_IterationCount = desc.m_IterationCount;
            m_Type           = desc.m_Type;

            m_MaxLinearVelocity    = desc.m_MaxLinearVelocity;
            m_MaxAngularVelocity   = desc.m_MaxAngularVelocity;
            m_SleepEnergyThreshold = desc.m_SleepEnergyThreshold;
            m_LinearDamping        = desc.m_LinearDamping;
            m_AngularDamping       = desc.m_AngularDamping;

            SetInitialFlags(desc.m_Flags);

            m_InvertInertiaTensor.M11 = MyPhysicsUtils.FLT_MAX;
            m_InvertInertiaTensor.M22 = MyPhysicsUtils.FLT_MAX;
            m_InvertInertiaTensor.M33 = MyPhysicsUtils.FLT_MAX;

            m_Guid = GUID_COUNTER;
            if (GUID_COUNTER > 65000)
            {
                GUID_COUNTER = 0;
            }

            GUID_COUNTER++;

            return(true);
        }
Exemple #4
0
        /// <summary>
        /// Loads properties of rbo from descriptor
        /// </summary>
        public bool LoadFromDesc(MyRigidBodyDesc desc)
        {
            if ((m_Flags & RigidBodyFlag.RBF_INSERTED) > 0)
                return false;

            if (!desc.IsValid())
                return false;

            m_Mass = desc.m_Mass;
            m_OneOverMass = 1.0f / m_Mass;
            m_Matrix = desc.m_Matrix;

            m_IterationCount = desc.m_IterationCount;
            m_Type = desc.m_Type;

            m_MaxLinearVelocity = desc.m_MaxLinearVelocity;
            m_MaxAngularVelocity = desc.m_MaxAngularVelocity;
            m_SleepEnergyThreshold = desc.m_SleepEnergyThreshold;
            m_LinearDamping = desc.m_LinearDamping;
            m_AngularDamping = desc.m_AngularDamping;

            SetInitialFlags(desc.m_Flags);

            m_InvertInertiaTensor.M11 = MyPhysicsUtils.FLT_MAX;
            m_InvertInertiaTensor.M22 = MyPhysicsUtils.FLT_MAX;
            m_InvertInertiaTensor.M33 = MyPhysicsUtils.FLT_MAX;

            m_Guid = GUID_COUNTER;
            if (GUID_COUNTER > 65000)
            {
                GUID_COUNTER = 0;
            }

            GUID_COUNTER++;

            return true;
        }