mirror of
https://github.com/godotengine/godot.git
synced 2024-09-20 14:32:42 +00:00
Ignore disabled shapes for mass property calculations
(cherry picked from commit c3107349a4
)
This commit is contained in:
parent
5c36619bdd
commit
6c7d52164a
|
@ -63,6 +63,9 @@ void BodySW::update_inertias() {
|
|||
real_t total_area = 0;
|
||||
|
||||
for (int i = 0; i < get_shape_count(); i++) {
|
||||
if (is_shape_disabled(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
total_area += get_shape_area(i);
|
||||
}
|
||||
|
@ -72,6 +75,10 @@ void BodySW::update_inertias() {
|
|||
|
||||
if (total_area != 0.0) {
|
||||
for (int i = 0; i < get_shape_count(); i++) {
|
||||
if (is_shape_disabled(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
real_t area = get_shape_area(i);
|
||||
|
||||
real_t mass = area * this->mass / total_area;
|
||||
|
|
|
@ -55,6 +55,9 @@ void Body2DSW::update_inertias() {
|
|||
real_t total_area = 0;
|
||||
|
||||
for (int i = 0; i < get_shape_count(); i++) {
|
||||
if (is_shape_disabled(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
total_area += get_shape_aabb(i).get_area();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user