Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] [Godot Physics]: Correct typo in moment of inertia calculations. #47286

Merged
merged 1 commit into from
Mar 23, 2021

Conversation

DarkKilauea
Copy link
Contributor

3.x version of #47284

The moment of inertia calculation for BoxShape is:

```
Vector3(
    (p_mass / 3.0) * (ly * ly + lz * lz), 
    (p_mass / 3.0) * (lx * lx + lz * lz), 
    (p_mass / 3.0) * (lx * lx + ly * ly));
```

where the final line includes both the x and y extents.

However, for CapsuleShape3D, CylinderShape3D, ConvexPolygonShape3D, ConcavePolygonShape3D, and HeightMapShape3D, the final line read `(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y)`.  I believe this is a mistake, considering the comment in each case mentions using an AABB approximation, which should follow the same approach as BoxShape.

This change corrects the final line to include both the x and y components of the shape's extent.
@DarkKilauea DarkKilauea requested a review from a team as a code owner March 23, 2021 03:26
@akien-mga akien-mga added this to the 3.3 milestone Mar 23, 2021
@akien-mga akien-mga merged commit 7c82092 into godotengine:3.x Mar 23, 2021
@akien-mga
Copy link
Member

Thanks!

@DarkKilauea DarkKilauea deleted the fix-moment-of-inertia-3.x branch March 26, 2021 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants