I have discovered a possible bug in the continuous collision detection. Quite often the boxes you shoot will pass through.
To reproduce replace the following function in ContinueCollision1.cpp in DemosSandbox, and then just rotate the camera around and shoot at different parts of the wall. >50% of the time the boxes pass through the wall.
The wall is just one simple quad.
- Code: Select all
static NewtonBody* CreateBackgroundWallsAndCellingBody(NewtonWorld* world)
{
// ******Added*********
dFloat wall_tris[6][3] =
{
{ 100, 0, 0 },
{ -100, 0, 0 },
{ -100, 100, 0 },
{ -100, 100, 0 },
{ 100, 100, 0 },
{ 100, 0, 0 },
};
// ******Added*********
dFloat wall_quad[4][3] =
{
{ -100, 0, 0 },
{ 100, 0, 0 },
{ 100, 100, 0 },
{ -100, 100, 0 },
};
// crate a collision tree
NewtonCollision* const collision = NewtonCreateTreeCollision(world, 0);
// start building the collision mesh
NewtonTreeCollisionBeginBuild(collision);
// add the face one at a time
/*NewtonTreeCollisionAddFace(collision, 4, &floor[0][0], 3 * sizeof (dFloat), 0);
NewtonTreeCollisionAddFace(collision, 4, &wall_N[0][0], 3 * sizeof (dFloat), 0);
NewtonTreeCollisionAddFace(collision, 4, &wall_W[0][0], 3 * sizeof (dFloat), 0);
NewtonTreeCollisionAddFace(collision, 4, &wall_S[0][0], 3 * sizeof (dFloat), 0);
NewtonTreeCollisionAddFace(collision, 4, &wall_E[0][0], 3 * sizeof (dFloat), 0);
NewtonTreeCollisionAddFace(collision, 4, &celling[0][0], 3 * sizeof (dFloat), 0);*/
// ******Added*********
NewtonTreeCollisionAddFace(collision, 4, &wall_quad[0][0], 3 * sizeof (dFloat), 0);
/*NewtonTreeCollisionAddFace(collision, 3, &wall_tris[0][0], 3 * sizeof (dFloat), 0);
NewtonTreeCollisionAddFace(collision, 3, &wall_tris[3][0], 3 * sizeof (dFloat), 0);*/
// finish building the collision
NewtonTreeCollisionEndBuild(collision, 1);
// create a body with a collision and locate at the identity matrix position
dMatrix matrix(dGetIdentityMatrix());
NewtonBody* const body = NewtonCreateDynamicBody(world, collision, &matrix[0][0]);
// do no forget to destroy the collision after you not longer need it
NewtonDestroyCollision(collision);
return body;
}
The effect is the same when I add triangles instead of a quad.
Then I also noticed that no collisions occur at all from the other side of the wall. Is this intended behaviour? i.e. should they only collide on one side?
Thanks
James