Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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:

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!

Edit: I'm not allowed to answer my question right now for some reason so I'll post the answer here before I've forgotten it: In Box2D, the order of placement of vertices seems to play an important role, since I was able to avoid the crash with the "problematic" triangle in my example from my question just by placing the first vertex between the second and the third one. Maybe I'll repost the answer when I'm able to provide more information (and am also allowed to do so)

share|improve this question
2  
Since LOVE is still fairly unknown, you'd probably get a better answer either on their website's forums or on their Bitbucket repository. –  mkosler Mar 4 '12 at 0:16
    
yes, but the error occurs in Box2D code but thanks, I'll ask on their site too –  c0f33.alex Mar 4 '12 at 0:30

1 Answer 1

up vote 3 down vote accepted

You have to create polygons with a counter clockwise winding in box2d. Have a look at the box2d manual, section 4.4 http://www.box2d.org/manual.html#_Toc258082970

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.