erincatto / box2d

Box2D is a 2D physics engine for games
https://box2d.org
MIT License
7.44k stars 1.47k forks source link

ResetMassData asserts and crashes client application #756

Open simonvanbernem opened 8 months ago

simonvanbernem commented 8 months ago

Box2d triggers the assert b2Assert(m_I > 0.0f); at b2_body.cpp:337 when creating a b2Body with a single fixture with density 1 and the b2PolygonShape with the following 3 vertices (given as hex for exact reproducibility):

x0: 0xc28e8d90 //-71.27 y0: 0x42100000 //36.00 x1: 0xc28eb4be //-71.35 y1: 0x42104e5f //36.07 x2: 0xc28ebf3e //-71.37 y2: 0x42100000 //36.00

These vertices seem to survive the vertex welding done by b2PolygonShape::Set just fine, but probably cause rounding errors in exactly the right way to trigger the assert.