Skip to content

Commit

Permalink
Merge pull request #47284 from DarkKilauea/fix-moment-of-inertia
Browse files Browse the repository at this point in the history
[Godot Physics]: Correct typo in moment of inertia calculations.
  • Loading branch information
akien-mga committed Mar 23, 2021
2 parents 0339200 + 9aadd0c commit f7a92ee
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions servers/physics_3d/shape_3d_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ Vector3 CapsuleShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(
(p_mass / 3.0) * (extents.y * extents.y + extents.z * extents.z),
(p_mass / 3.0) * (extents.x * extents.x + extents.z * extents.z),
(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y));
(p_mass / 3.0) * (extents.x * extents.x + extents.y * extents.y));
}

void CapsuleShape3DSW::_setup(real_t p_height, real_t p_radius) {
Expand Down Expand Up @@ -807,7 +807,7 @@ Vector3 CylinderShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(
(p_mass / 3.0) * (extents.y * extents.y + extents.z * extents.z),
(p_mass / 3.0) * (extents.x * extents.x + extents.z * extents.z),
(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y));
(p_mass / 3.0) * (extents.x * extents.x + extents.y * extents.y));
}

void CylinderShape3DSW::_setup(real_t p_height, real_t p_radius) {
Expand Down Expand Up @@ -1064,7 +1064,7 @@ Vector3 ConvexPolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(
(p_mass / 3.0) * (extents.y * extents.y + extents.z * extents.z),
(p_mass / 3.0) * (extents.x * extents.x + extents.z * extents.z),
(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y));
(p_mass / 3.0) * (extents.x * extents.x + extents.y * extents.y));
}

void ConvexPolygonShape3DSW::_setup(const Vector<Vector3> &p_vertices) {
Expand Down Expand Up @@ -1424,7 +1424,7 @@ Vector3 ConcavePolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(
(p_mass / 3.0) * (extents.y * extents.y + extents.z * extents.z),
(p_mass / 3.0) * (extents.x * extents.x + extents.z * extents.z),
(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y));
(p_mass / 3.0) * (extents.x * extents.x + extents.y * extents.y));
}

struct _VolumeSW_BVH_Element {
Expand Down Expand Up @@ -1662,7 +1662,7 @@ Vector3 HeightMapShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(
(p_mass / 3.0) * (extents.y * extents.y + extents.z * extents.z),
(p_mass / 3.0) * (extents.x * extents.x + extents.z * extents.z),
(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y));
(p_mass / 3.0) * (extents.x * extents.x + extents.y * extents.y));
}

void HeightMapShape3DSW::_setup(Vector<real_t> p_heights, int p_width, int p_depth, real_t p_cell_size) {
Expand Down

0 comments on commit f7a92ee

Please sign in to comment.