3 ms·
Small suggestion: this should be an `Object` method: ``` obj->Force += obj->Mass * m_gravity; // apply a force obj->Velocity += obj->Force / obj->Mass * dt; o
by BenFrantzDale 6y ago
Small suggestion: this should be an `Object` method:
```
obj->Force += obj->Mass * m_gravity; // apply a force
obj->Velocity += obj->Force / obj->Mass * dt;
obj->Position += obj->Velocity * dt;
obj->Force = vector3(0, 0, 0); // reset net force at the end
```
As in
```
void Object::Step(double dt_s, const vector3& g_mps2) {
Force += Mass * g_mps2; // apply a force
Velocity += Force / Mass * dt_s;
Position += Velocity * dt_s;
Force = vector3(0, 0, 0); // reset net force at the end
}
```
- rurban 6y agoSo that it cannot be inlined and be 20x slower? Not so a good idea for a physics loop.