Ejemplo n.º 1
0
        public virtual void CalculateLocalInertia(float mass, ref IndexedVector3 inertia)
        {
            LockChildShapes();


            inertia = IndexedVector3.Zero;

            int   i         = GetVertexCount();
            float pointmass = mass / ((float)i);

            while (i-- != 0)
            {
                IndexedVector3 pointintertia;
                GetVertex(i, out pointintertia);
                pointintertia = GImpactMassUtil.GimGetPointInertia(ref pointintertia, pointmass);
                inertia      += pointintertia;
            }

            UnlockChildShapes();
        }
Ejemplo n.º 2
0
        //! Calculates the exact inertia tensor for this shape
        public virtual void CalculateLocalInertia(float mass, ref IndexedVector3 inertia)
        {
            LockChildShapes();
            inertia = IndexedVector3.Zero;

            int   i         = GetNumChildShapes();
            float shapemass = mass / ((float)i);

            while (i-- != 0)
            {
                IndexedVector3 temp_inertia;
                m_childShapes[i].CalculateLocalInertia(shapemass, out temp_inertia);
                if (ChildrenHasTransform())
                {
                    inertia = GImpactMassUtil.GimInertiaAddTransformed(ref inertia, ref temp_inertia, ref m_childTransforms.GetRawArray()[i]);
                }
                else
                {
                    IndexedMatrix identity = IndexedMatrix.Identity;
                    inertia = GImpactMassUtil.GimInertiaAddTransformed(ref inertia, ref temp_inertia, ref identity);
                }
            }
        }