From 120e8a229d354ba00d5a007b495189162f46e998 Mon Sep 17 00:00:00 2001 From: notgiven688 Date: Sun, 12 Nov 2023 19:56:37 +0100 Subject: [PATCH] No need to recalculate mass properties of the child shape in TransformedShape.cs --- src/Jitter2/Collision/Shapes/TransformedShape.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Jitter2/Collision/Shapes/TransformedShape.cs b/src/Jitter2/Collision/Shapes/TransformedShape.cs index 0965e1ec..a71029ad 100644 --- a/src/Jitter2/Collision/Shapes/TransformedShape.cs +++ b/src/Jitter2/Collision/Shapes/TransformedShape.cs @@ -132,10 +132,10 @@ public override void CalculateBoundingBox(in JMatrix orientation, in JVector pos public override void CalculateMassInertia(out JMatrix inertia, out JVector com, out float mass) { - OriginalShape.CalculateMassInertia(out inertia, out com, out mass); + mass = OriginalShape.Mass; - com = JVector.Transform(com, transformation) + translation; - inertia = transformation * JMatrix.Multiply(inertia, JMatrix.Transpose(transformation)); + com = JVector.Transform(OriginalShape.GeometricCenter, transformation) + translation; + inertia = transformation * JMatrix.Multiply(OriginalShape.Inertia, JMatrix.Transpose(transformation)); JMatrix pat = mass * (JMatrix.Identity * translation.LengthSquared() - JVector.Outer(translation, translation)); inertia += pat; }