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(); }
//! 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); } } }