File tree 2 files changed +16
-0
lines changed 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ impl Collider {
42
42
inertia + mass * d. powi ( 2 )
43
43
}
44
44
45
+ pub fn is_sensor ( & self ) -> bool {
46
+ self . flags . is_sensor
47
+ }
48
+
45
49
pub fn absolute_translation ( & self ) -> Vec2 {
46
50
self . absolute_transform . translation
47
51
}
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ impl RigidBody {
95
95
96
96
for col_handle in self . colliders . iter ( ) {
97
97
if let Some ( collider) = & col_set. get ( * col_handle) {
98
+ if collider. is_sensor ( ) {
99
+ continue ;
100
+ }
101
+
98
102
let mass = collider. mass ( ) ;
99
103
100
104
self . calculated_mass += mass;
@@ -106,6 +110,14 @@ impl RigidBody {
106
110
}
107
111
}
108
112
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
+
109
121
self . center_of_mass = weighted_centers / self . calculated_mass ;
110
122
}
111
123
You can’t perform that action at this time.
0 commit comments