@@ -131,20 +131,19 @@ describe('gravity example', () => {
131131 let dt = (time_1.passed * time_1.multiplier);
132132 let currentId = input.gid.x;
133133 var current = CelestialBody_4(inState_3[currentId].destroyed, inState_3[currentId].position, inState_3[currentId].velocity, inState_3[currentId].mass, inState_3[currentId].radiusMultiplier, inState_3[currentId].collisionBehavior, inState_3[currentId].textureIndex, inState_3[currentId].ambientLightFactor);
134- if ((current.destroyed == 1)) {
135- return;
136- }
137- for (var i = 0; (i < celestialBodiesCount_5); i++) {
138- let other = (&inState_3[i]);
139- if (((u32(i) == input.gid.x) || ((*other).destroyed == 1))) {
140- continue;
134+ if ((current.destroyed == 0)) {
135+ for (var i = 0; (i < celestialBodiesCount_5); i++) {
136+ let other = (&inState_3[i]);
137+ if (((u32(i) == input.gid.x) || ((*other).destroyed == 1))) {
138+ continue;
139+ }
140+ let dist = max((radiusOf_6(current) + radiusOf_6((*other))), distance(current.position, (*other).position));
141+ let gravityForce = (((current.mass * (*other).mass) / dist) / dist);
142+ var direction = normalize(((*other).position - current.position));
143+ current.velocity = (current.velocity + (direction * ((gravityForce / current.mass) * dt)));
141144 }
142- let dist = max((radiusOf_6(current) + radiusOf_6((*other))), distance(current.position, (*other).position));
143- let gravityForce = (((current.mass * (*other).mass) / dist) / dist);
144- var direction = normalize(((*other).position - current.position));
145- current.velocity = (current.velocity + (direction * ((gravityForce / current.mass) * dt)));
145+ current.position = (current.position + (current.velocity * dt));
146146 }
147- current.position = (current.position + (current.velocity * dt));
148147 outState_7[input.gid.x] = current;
149148 }
150149
0 commit comments