I need to create some polygons with large numbers of vertices (potentially hundreds - tracing the edges of objects provided by another library). Instead of of upping the maximum number of vertices allowed in b2Settings.h, I thought I'd see what LoopShape could do.
I can create a loop with around 20 points, without a problem. When I tried to create one with 25, I get the following assertion error.
I managed to get around it by adding larger block sizes to the allocator, but I don't think this is a good solution.
This is pretty much the code I am using just for testing.
So, am I doing something horribly wrong? Is there a better solution for what I want to do? (Should I just increase b2_maxPolygonVertices?)
Thanks.
I can create a loop with around 20 points, without a problem. When I tried to create one with 25, I get the following assertion error.
Quote:
Assertion failed: 0 < size && size <= b2_maxBlockSize, file C:\Box2D\Common\b2BlockAllocator.cpp, line 104
I managed to get around it by adding larger block sizes to the allocator, but I don't think this is a good solution.
This is pretty much the code I am using just for testing.
Code:
b2BodyDef bd;
bd.position.Set(0.0f, 0.0f);
m_body = m_world->CreateBody(&bd);
int numVerts = vertices.size();
m_vertices = new b2Vec2[numVerts];
for(int i=0; i<numVerts; i++) {
m_vertices[i].Set(vertices[i].x/BOX2D_RATIO, vertices[i].y/BOX2D_RATIO);
}
b2LoopShape loop;
loop.m_vertices = m_vertices;
loop.m_count = numVerts;
b2FixtureDef fd;
fd.shape = &loop;
fd.density = 0.0f;
fd.restitution = 0.0f;
fd.friction = 0.0f;
m_body->CreateFixture(&fd);
bd.position.Set(0.0f, 0.0f);
m_body = m_world->CreateBody(&bd);
int numVerts = vertices.size();
m_vertices = new b2Vec2[numVerts];
for(int i=0; i<numVerts; i++) {
m_vertices[i].Set(vertices[i].x/BOX2D_RATIO, vertices[i].y/BOX2D_RATIO);
}
b2LoopShape loop;
loop.m_vertices = m_vertices;
loop.m_count = numVerts;
b2FixtureDef fd;
fd.shape = &loop;
fd.density = 0.0f;
fd.restitution = 0.0f;
fd.friction = 0.0f;
m_body->CreateFixture(&fd);
So, am I doing something horribly wrong? Is there a better solution for what I want to do? (Should I just increase b2_maxPolygonVertices?)
Thanks.