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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions servers/physics/shape_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ Vector3 CapsuleShapeSW::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 CapsuleShapeSW::_setup(real_t p_height, real_t p_radius) {
Expand Down Expand Up @@ -874,7 +874,7 @@ Vector3 CylinderShapeSW::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 CylinderShapeSW::_setup(real_t p_height, real_t p_radius) {
Expand Down Expand Up @@ -1144,7 +1144,7 @@ Vector3 ConvexPolygonShapeSW::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 ConvexPolygonShapeSW::_setup(const Vector<Vector3> &p_vertices) {
Expand Down Expand Up @@ -1535,7 +1535,7 @@ Vector3 ConcavePolygonShapeSW::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 @@ -1798,7 +1798,7 @@ Vector3 HeightMapShapeSW::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 HeightMapShapeSW::_setup(PoolVector<real_t> p_heights, int p_width, int p_depth, real_t p_cell_size) {
Expand Down