I'm using the Box2D physics engine. And there's a type of shape for box2D called b2PolygonShape.
In this class, you can create polygons. There is also a Set() function that takes an array of points and a vertex count.
Box2D has an example like this:
// This defines a triangle in CCW order.
b2Vec2 vertices[3];
vertices[0].Set(0.0f, 0.0f);
vertices[1].Set(1.0f, 0.0f);
vertices[2].Set(0.0f, 1.0f);
int32 count = 3;
b2PolygonShape polygon;
polygon.Set(vertices, count);
This works. Yet when I tried to practice and mess with this function, I did this:
b2Vec2 vertices[4];
vertices[0].Set(0, 0);
vertices[1].Set(0,10);
vertices[2].Set(10,10);
vertices[3].Set(10,0);
int32 count = 4;
b2PolygonShape polygon;
polygon.Set(vertices, count);
When I compiled and ran this, it crashed after the Set() function. Wouldn't this create a square?
Also in the console I got this:
Assertion failed: s > 0.0f
What did I do wrong?