You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Polycode c3c534c with minor patches. I've got some code that looks like:
ScreenMesh *s = new ScreenMesh(Mesh::TRIFAN_MESH);
Mesh *m = s->getMesh();
Polygon *p = new Polygon();
for(vcvi b = points.begin(); b != points.end(); b++) {
p->addVertex(b->x,b->y,0);
}
m->addPolygon(p);
physics()->addPhysicsChild(s, physicsType, isStatic, friction, density, restitution, isSensor, fixedRotation);
If "points" contains 8 points, this code works fine.
If "points" contains 9 points, this code crashes inside Box2D.
I've seen the crash happen in different places, I've seen it in
#0 0x100161c73 in b2PolygonShape::Set at basic_string.tcc:685 #1 0x1001422e1 in Polycode::PhysicsScreenEntity::PhysicsScreenEntity at basic_string.tcc:685 #2 0x10013f848 in Polycode::PhysicsScreen::addPhysicsChild at basic_string.tcc:685
And also deep inside the render() call, inside something like calculatepolygoncollision(). The top of the stack where the crash occurs always seems to be inside Box2D code.
If there is an unavoidable limitation that Box2D can only go up to 8 vertices, it might be helpful for either the addPhysicsChild to detect we are about to add a too-many-vertices object and fail; or, at least, for this limitation to be documented in the PhysicsScreen documentation.
The text was updated successfully, but these errors were encountered:
This issue can be resolved by having multiple fixtures per body that stick to a Max of 8 per polygon. This iss an important issue for people using physics as at the moment you are limited to 8 vertices per object full stop. I have emailed Ivan my fix as if I submit it here (cut and paste) there is some strange tabbing problem and the code looks bad
Using Polycode c3c534c with minor patches. I've got some code that looks like:
If "points" contains 8 points, this code works fine.
If "points" contains 9 points, this code crashes inside Box2D.
I've seen the crash happen in different places, I've seen it in
#0 0x100161c73 in b2PolygonShape::Set at basic_string.tcc:685
#1 0x1001422e1 in Polycode::PhysicsScreenEntity::PhysicsScreenEntity at basic_string.tcc:685
#2 0x10013f848 in Polycode::PhysicsScreen::addPhysicsChild at basic_string.tcc:685
And also deep inside the render() call, inside something like calculatepolygoncollision(). The top of the stack where the crash occurs always seems to be inside Box2D code.
If there is an unavoidable limitation that Box2D can only go up to 8 vertices, it might be helpful for either the addPhysicsChild to detect we are about to add a too-many-vertices object and fail; or, at least, for this limitation to be documented in the PhysicsScreen documentation.
The text was updated successfully, but these errors were encountered: