Skip to content

Commit

Permalink
Merge pull request #42 from notgiven688/TransformedShape_fix
Browse files Browse the repository at this point in the history
No need to recalculate mass properties of the child shape in TransformedShape.cs
  • Loading branch information
notgiven688 authored Nov 12, 2023
2 parents 3035f9c + 120e8a2 commit db78d12
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Jitter2/Collision/Shapes/TransformedShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit db78d12

Please sign in to comment.