Handmade Hero»Forums»Code
Benjamin Pedersen
41 posts
Mathematician
Integration error in bob code
Edited by Benjamin Pedersen on Reason: More detail
Line 959 should say
1
Entity->tBob += 0.5*ddtBob*dt*dt + Entity->dtBob*dt;

instead of
1
Entity->tBob += ddtBob*dt*dt + Entity->dtBob*dt;

since f(x)=ax integrates to F(x)=(a/2)x^2.

Also, polynomial expressions are often calculated in the form (...(a_n x + a_{n-1})x ... + a_1)x + a_0 for efficiency. Though it isn't much, maybe the line should say
1
Entity->tBob += (0.5*ddtBob*dt + Entity->dtBob)*dt;
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Integration error in bob code
This is already covered here:

https://hero.handmade.network/forums/code-discussion/t/1163

- Casey