Ok, I'm not quite sure exactly what triggers it, but it seems like one polygon can suddenly be thrown through another. As I have seem it, it happens only when the are slightly askew to each other, and only when one is static and the non-static is traveling in either a positive X or positive Y direction.
This small program reproduces the problem om my machine (using Box2D 1.4.2) - Not sure whether the same effect happens elsewhere yet. It should create a dynamic box at y = 27.65 [could be less, but this limits the output] and a larger static box at y = 30. The static box should be wide enough so the dynamic one should hit it...
Just for completeness, the interesting part of the output is attached below the program.
#include <Box2D.h>
#include <cstdlib>
b2Body* create_movable(b2World& world)
{
b2PolyDef box;
box.vertexCount = 4;
box.vertices[0].Set(2.0, 1.2);
box.vertices[1].Set(-2.0, 1.2);
box.vertices[2].Set(-2.0, -1.2);
box.vertices[3].Set(2.0, -1.2);
box.density = 1;
box.friction = 0.15f;
box.restitution = 0.6;
b2BodyDef body;
body.position.Set(45, 27.65);
body.allowSleep = false;
body.rotation = 330.0f / 180.0f * M_PI;
body.AddShape(&box);
return world.CreateBody(&body);
}
b2Body* create_static(b2World& world)
{
b2PolyDef box;
box.vertexCount = 4;
box.vertices[0].Set(20.1, 0.22);
box.vertices[1].Set(-20.03, 0.23);
box.vertices[2].Set(-20.05, -0.21);
box.vertices[3].Set(20.01, -0.23);
box.density = 0;
box.friction = 0.5;
box.restitution = 0.5;
b2BodyDef body;
body.position.Set(32, 30);
body.AddShape(&box);
return world.CreateBody(&body);
}
int main ( int argc, char** argv )
{
b2AABB worldAABB = {b2Vec2(0, 0), b2Vec2(64, 48)};
b2World world(worldAABB, b2Vec2(0.0f, 0.005f), false);
b2Body* mov = create_movable(world);
b2Body* stat = create_static(world);
bool done = false;
while (!done)
{
if (mov->GetCenterPosition().y > 31.5) exit(0);
printf("(%f, %f, %f)\n", mov->GetCenterPosition().x, mov->GetCenterPosition().y, mov->GetRotation());
world.Step(0.01, 10);
}
return 0;
}
// interesting part of the output
// x, y, angle
// probably more than a hundre lines above this
(45.000000, 27.729099, 5.759587)
(45.000000, 27.729382, 5.759587)
(45.000000, 27.729664, 5.759587)
(45.000000, 27.729946, 5.759587)
(45.000114, 28.064529, 5.775726)
(45.000191, 28.393602, 5.792654)
(45.000267, 28.717144, 5.810221)
(45.000343, 29.035154, 5.828268)
(45.000420, 29.347729, 5.846627)
(45.000496, 29.655041, 5.865135)
(45.000572, 29.957279, 5.883638)
(45.000648, 30.254730, 5.901997)
(45.000717, 30.538118, 5.932713)
(45.000755, 30.771885, 6.022929)
(45.000793, 30.981495, 6.117511)
(45.000832, 31.175991, 6.207919)
(45.000866, 31.342186, 6.279333)
(45.000866, 31.398182, 6.283381)
(45.000866, 31.412209, 6.283097)
(45.000866, 31.415705, 6.282977)
(45.000866, 31.416576, 6.282943)
(45.000866, 31.416868, 6.282943)
(45.000866, 31.417160, 6.282943)
(45.000866, 31.417452, 6.282943)
This small program reproduces the problem om my machine (using Box2D 1.4.2) - Not sure whether the same effect happens elsewhere yet. It should create a dynamic box at y = 27.65 [could be less, but this limits the output] and a larger static box at y = 30. The static box should be wide enough so the dynamic one should hit it...
Just for completeness, the interesting part of the output is attached below the program.
#include <Box2D.h>
#include <cstdlib>
b2Body* create_movable(b2World& world)
{
b2PolyDef box;
box.vertexCount = 4;
box.vertices[0].Set(2.0, 1.2);
box.vertices[1].Set(-2.0, 1.2);
box.vertices[2].Set(-2.0, -1.2);
box.vertices[3].Set(2.0, -1.2);
box.density = 1;
box.friction = 0.15f;
box.restitution = 0.6;
b2BodyDef body;
body.position.Set(45, 27.65);
body.allowSleep = false;
body.rotation = 330.0f / 180.0f * M_PI;
body.AddShape(&box);
return world.CreateBody(&body);
}
b2Body* create_static(b2World& world)
{
b2PolyDef box;
box.vertexCount = 4;
box.vertices[0].Set(20.1, 0.22);
box.vertices[1].Set(-20.03, 0.23);
box.vertices[2].Set(-20.05, -0.21);
box.vertices[3].Set(20.01, -0.23);
box.density = 0;
box.friction = 0.5;
box.restitution = 0.5;
b2BodyDef body;
body.position.Set(32, 30);
body.AddShape(&box);
return world.CreateBody(&body);
}
int main ( int argc, char** argv )
{
b2AABB worldAABB = {b2Vec2(0, 0), b2Vec2(64, 48)};
b2World world(worldAABB, b2Vec2(0.0f, 0.005f), false);
b2Body* mov = create_movable(world);
b2Body* stat = create_static(world);
bool done = false;
while (!done)
{
if (mov->GetCenterPosition().y > 31.5) exit(0);
printf("(%f, %f, %f)\n", mov->GetCenterPosition().x, mov->GetCenterPosition().y, mov->GetRotation());
world.Step(0.01, 10);
}
return 0;
}
// interesting part of the output
// x, y, angle
// probably more than a hundre lines above this
(45.000000, 27.729099, 5.759587)
(45.000000, 27.729382, 5.759587)
(45.000000, 27.729664, 5.759587)
(45.000000, 27.729946, 5.759587)
(45.000114, 28.064529, 5.775726)
(45.000191, 28.393602, 5.792654)
(45.000267, 28.717144, 5.810221)
(45.000343, 29.035154, 5.828268)
(45.000420, 29.347729, 5.846627)
(45.000496, 29.655041, 5.865135)
(45.000572, 29.957279, 5.883638)
(45.000648, 30.254730, 5.901997)
(45.000717, 30.538118, 5.932713)
(45.000755, 30.771885, 6.022929)
(45.000793, 30.981495, 6.117511)
(45.000832, 31.175991, 6.207919)
(45.000866, 31.342186, 6.279333)
(45.000866, 31.398182, 6.283381)
(45.000866, 31.412209, 6.283097)
(45.000866, 31.415705, 6.282977)
(45.000866, 31.416576, 6.282943)
(45.000866, 31.416868, 6.282943)
(45.000866, 31.417160, 6.282943)
(45.000866, 31.417452, 6.282943)

