Box2D (Assertion fail with polygon meshes)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
c0ff33.alex
Prole
Posts: 2
Joined: Sun Mar 04, 2012 12:33 am

Box2D (Assertion fail with polygon meshes)

Post by c0ff33.alex »

When I try to create a triangle collider for my game it sometimes leads to an assertion fail. I use the physics engine that comes with love2d (Box2D). That's the error message that appears when the assertion fails:

Code: Select all

love: modules/physics/box2d/Source/Collision/Shapes/b2PolygonShape.cpp:85: b2Vec2 ComputeCentroid(const b2Vec2*, int32): Assertion `area > 1.19209289550781250000e-7F' failed.
Here's an example of a triangle that doesn't cause the error (represented by a table with 3 points): {{258,451},{740,767},{284,597}}

And this one leads to a crash: {{258,450},{222,569},{306,723}}

The bodies of both shapes lie at {0, 0} (upper-left corner of the screen)

Does anyone know a possible reason and/or solution for the problem?

Many thanks in advance!
c0ff33.alex
Prole
Posts: 2
Joined: Sun Mar 04, 2012 12:33 am

Re: Box2D (Assertion fail with polygon meshes)

Post by c0ff33.alex »

Hi,
now I know what I was doing wrong. Some polygons were created in clockwise winding. These didn't work, while the ones I created in counterclockwise winding worked perfectly. Here's a manual page on this topic: http://www.box2d.org/manual.html#_Toc258082970
(thanks to Cato112 from gamedev.stackexchange.com)
Post Reply

Who is online

Users browsing this forum: No registered users and 259 guests