Today an amazing thing happened to me. I was following along with episode 72 and in this one, Casey Muratori adds a maximum velocity for entities in the sim region. Then he adds an assert to ensure nothing is going to exceed this velocity and hence the logic for gathering entities into the sim_region will not skip any fastmoving/big entities.
This assert immediately fires. Now, for the first time ever I predicted the exact line he wrote next to fix the issue before he said it 😀. Because I had seen in the debugger that it was just the z-component that was exceeding each time. So I just went and zeroed out the velocity after the collision loop, which he did right afterwards too. It was an awesome feeling 😀 when he did the same later.
But also, this makes me think that really that z acceleration shouldn't even be there. Its not like any object on the ground always has that acceleration, it has a force acting downward due to gravity and then a normal reaction force from the ground, making the total acceleration 0. Now, I know this is throw away code and he is probably going to correct it anyways. I still had to post this though, because of me guessing that one line of code haha.
One thing I do wonder is if later on in the solid simulation code there would be forces or whether it would just be accelerations. Off the top of my head, the only way to compute the vertical acceleration of the objects when there is gravity would be to include the normal force equations as well. But then one would need to maintain some other kind of state which would say whether or not an entity is touching the ground or not.... I'm getting ahead of myself though.