box2d
box2d copied to clipboard
Crash in b2UpdateBodyMassData because of missing increment of loop variable
Hi,
while trying to update to the latest box2d commit, my game started crashing here, because the inertia was NaN: https://github.com/erincatto/box2d/blob/3a4f0da8374af61293a03021c9a0b3ebcfe67948/src/body.c#L626
This happens because this code doesn't increment shapeIndex before continuing, which causes the same shape mass data to be overwritten with 0 over and over, leaving garbage data in the remaining ones.
https://github.com/erincatto/box2d/blob/3a4f0da8374af61293a03021c9a0b3ebcfe67948/src/body.c#L589-L590
Adding shapeIndex += 1; fixes the crash
Easy solve, stop using 0 density. :)
Thanks for the report. Fixed in #1022