Ignore disabled shapes for mass property calculations
This commit is contained in:
parent
6b98f0b615
commit
c3107349a4
2 changed files with 12 additions and 0 deletions
|
@ -59,6 +59,10 @@ void BodySW::update_inertias() {
|
||||||
real_t total_area = 0;
|
real_t total_area = 0;
|
||||||
|
|
||||||
for (int i = 0; i < get_shape_count(); i++) {
|
for (int i = 0; i < get_shape_count(); i++) {
|
||||||
|
if (is_shape_disabled(i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
total_area += get_shape_area(i);
|
total_area += get_shape_area(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +71,10 @@ void BodySW::update_inertias() {
|
||||||
|
|
||||||
if (total_area != 0.0) {
|
if (total_area != 0.0) {
|
||||||
for (int i = 0; i < get_shape_count(); i++) {
|
for (int i = 0; i < get_shape_count(); i++) {
|
||||||
|
if (is_shape_disabled(i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
real_t area = get_shape_area(i);
|
real_t area = get_shape_area(i);
|
||||||
|
|
||||||
real_t mass = area * this->mass / total_area;
|
real_t mass = area * this->mass / total_area;
|
||||||
|
|
|
@ -52,6 +52,10 @@ void Body2DSW::update_inertias() {
|
||||||
real_t total_area = 0;
|
real_t total_area = 0;
|
||||||
|
|
||||||
for (int i = 0; i < get_shape_count(); i++) {
|
for (int i = 0; i < get_shape_count(); i++) {
|
||||||
|
if (is_shape_disabled(i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
total_area += get_shape_aabb(i).get_area();
|
total_area += get_shape_aabb(i).get_area();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue