Skip to content

Commit 40331f5

Browse files
committed
Remove sensors from mass calculation + default mass/inertia = 1 for now
1 parent 8e02a41 commit 40331f5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

blobs/src/collider.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ impl Collider {
4242
inertia + mass * d.powi(2)
4343
}
4444

45+
pub fn is_sensor(&self) -> bool {
46+
self.flags.is_sensor
47+
}
48+
4549
pub fn absolute_translation(&self) -> Vec2 {
4650
self.absolute_transform.translation
4751
}

blobs/src/rigid_body.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ impl RigidBody {
9595

9696
for col_handle in self.colliders.iter() {
9797
if let Some(collider) = &col_set.get(*col_handle) {
98+
if collider.is_sensor() {
99+
continue;
100+
}
101+
98102
let mass = collider.mass();
99103

100104
self.calculated_mass += mass;
@@ -106,6 +110,14 @@ impl RigidBody {
106110
}
107111
}
108112

113+
if self.calculated_mass == 0.0 {
114+
self.calculated_mass = 1.0;
115+
}
116+
117+
if self.inertia == 0.0 {
118+
self.inertia = 1.0;
119+
}
120+
109121
self.center_of_mass = weighted_centers / self.calculated_mass;
110122
}
111123

0 commit comments

Comments
 (0)