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;
        }
        public MyPhysicsObjects()
        {
            m_RigidBodyDesc        = new MyRigidBodyDesc();
            m_SensorDesc           = new MySensorDesc();
            m_RBSphereElementDesc  = new MyRBSphereElementDesc();
            m_RBBoxElementDesc     = new MyRBBoxElementDesc();
            m_RBCapsuleElementDesc = new MyRBCapsuleElementDesc();
            m_RBTriangleMeshDesc   = new MyRBTriangleMeshElementDesc();
            m_RBVoxelElementDesc   = new MyRBVoxelElementDesc();

            m_SensorsPool             = new MyObjectsPool <MySensor>(128);
            m_SphereSensorElementPool = new MyObjectsPool <MySphereSensorElement>(128);

            m_RigidsPool                = new MyObjectsPool <MyRigidBody>(24576);
            m_RBSphereElementPool       = new MyObjectsPool <MyRBSphereElement>(16384);
            m_RBBoxElementPool          = new MyObjectsPool <MyRBBoxElement>(16384);
            m_RBCapsuleElementPool      = new MyObjectsPool <MyRBCapsuleElement>(16);
            m_RBTriangleMeshElementPool = new MyObjectsPool <MyRBTriangleMeshElement>(16384);//value from Ales - 64
            m_RBVoxelElementPool        = new MyObjectsPool <MyRBVoxelElement>(512);
        }
        public MyPhysicsObjects()
        {
            m_RigidBodyDesc = new MyRigidBodyDesc();
            m_SensorDesc = new MySensorDesc();
            m_RBSphereElementDesc = new MyRBSphereElementDesc();
            m_RBBoxElementDesc = new MyRBBoxElementDesc();
            m_RBCapsuleElementDesc = new MyRBCapsuleElementDesc();
            m_RBTriangleMeshDesc = new MyRBTriangleMeshElementDesc();
            m_RBVoxelElementDesc = new MyRBVoxelElementDesc();

            m_SensorsPool = new MyObjectsPool<MySensor>(128);
            m_SphereSensorElementPool = new MyObjectsPool<MySphereSensorElement>(128);

            m_RigidsPool = new MyObjectsPool<MyRigidBody>(24576);
            m_RBSphereElementPool = new MyObjectsPool<MyRBSphereElement>(16384);
            m_RBBoxElementPool = new MyObjectsPool<MyRBBoxElement>(16384);
            m_RBCapsuleElementPool = new MyObjectsPool<MyRBCapsuleElement>(16);
            m_RBTriangleMeshElementPool = new MyObjectsPool<MyRBTriangleMeshElement>(16384);//value from Ales - 64
            m_RBVoxelElementPool = new MyObjectsPool<MyRBVoxelElement>(512);
        }
Beispiel #5
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);
        }
Beispiel #6
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;
        }