Box penetration problem

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Fax3D
Posts: 22
Joined: Mon Sep 29, 2008 7:42 am

Box penetration problem

Post by Fax3D »

Hi all,

I'm implementing Bepu Physics into my graphics engine for XNA. I simply create a new space lefting all settings to default. Next, i create a simple scene with a static cube for the ground, and 3 dynamic boxes falling down. Here it's the code:

Code: Select all

Space m_Space;
Entity m_staticBox;
Entity m_dynBox1; 
Entity m_dynBox2;
Entity m_dynBox3;

void Initialize()
{
     m_Space = new Space();

    m_staticBox = new Box(new Vector3(0, 0, 0), 400f, 1f, 400f);
    m_dynBox1 = new Box(new Vector3(0, 100, 0), 50f, 50f, 50f, 10f); 
    m_dynBox2 = new Box(new Vector3(0, 200, 0), 50f, 50f, 50f, 10f));
    m_dynBox3 = new Box(new Vector3(0, 300, 0), 50f, 50f, 50f, 10f));

    m_Space.add(m_staticBox);
    m_Space.add(m_dynBox1);
    m_Space.add(m_dynBox2);
    m_Space.add(m_dynBox3);
}

void Update(GameTime p_GameTime)
{
    space.update(GameTime);

    Matrix _matrixStaticBox = m_staticBox.orientationMatrix * Matrix.CreateTranslation(m_staticBox.centerOfMass);
    Matrix _matrixDynBox1 = m_dynBox1.orientationMatrix * Matrix.CreateTranslation(m_dynBox1.centerOfMass);
    Matrix _matrixDynBox2 = m_dynBox2.orientationMatrix * Matrix.CreateTranslation(m_dynBox2.centerOfMass);
    Matrix _matrixDynBox3 = m_dynBox3.orientationMatrix * Matrix.CreateTranslation(m_dynBox3.centerOfMass);
}
When i draw the box with the result matrix, i see the 3 boxes falling down but there are many penetration each other. I try adding more boxes to the silmulation and some sphere, and the result is there are some boxes/spheres penatrating and other works fine. In add, there is much instability because the box/sphere that are penetrating each other, also with the ground box, continues bouncing, moving and rotating a little bit because they are in an instable position.

Could you help me?

Thanks in advance!

Fax3D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Box penetration problem

Post by Norbo »

I'm not observing effects of the severity you mention, but the cause is most likely the scale. The general convex-convex collision detection system likes shapes to be closer to unit length (1 unit = 1 meter works pretty good). If you scale down the boxes 10x or 50x, pretty much all the problems should disappear. In this example, the 400x400 ground would stress the detection system quite a bit. Contact manifolds are also tuned to work on a smaller scale, so two giant boxes sitting on each other will be a little less stable than two smaller boxes.

v0.7.0 includes special case collision detection for sphere-sphere, sphere-box, sphere-triangle, box-box, and maybe a few others (box-triangle and such). These special cases do not suffer from the scale issues nearly as much, though it will still be a good idea to stick around a smaller scale for the rest of the systems.
Post Reply