Commit f22b913 1 parent 85d75b4 commit f22b913 Copy full SHA for f22b913
File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class RigidBody final : public Component {
38
38
}
39
39
40
40
void update (float deltaTime) override {
41
- if (!transform) {
41
+ if (!transform || ! isEnabled () ) {
42
42
return ;
43
43
}
44
44
@@ -87,14 +87,18 @@ class RigidBody final : public Component {
87
87
88
88
89
89
void addGravitationalSource (const RigidBody &source) {
90
+ if (!isEnabled () || !source.isEnabled ()) {
91
+ return ;
92
+ }
93
+
90
94
static const float G = 6.67430e-11 ; // Gravitational constant
91
95
92
96
glm::vec4 r = source.getPos () - getPos ();
93
97
float distance = math::norm (r);
94
98
glm::vec4 direction = math::normalize (r);
95
99
96
100
glm::vec4 force = G * (mass * source.mass ) / (distance * distance) * direction;
97
- forceAccumulator += force;
101
+ applyForce ( force) ;
98
102
}
99
103
100
104
private:
You can’t perform that action at this time.
0 commit comments