Box entity sometimes passes through triangle entity.

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Box entity sometimes passes through triangle entity.

Post by Spankenstein »

If I fire a box entity at a triangle entity then the box will sometimes not collide with the triangle entity and pass straight through it.

My box is setup as follows:

Code: Select all

            box = new Box(position, size, size, size, 1);
            box.PositionUpdateMode = PositionUpdateMode.Continuous;
The triangle is setup as follows:

Code: Select all

                    triangles[0] = new TriangleShape();        // 0, 1, 2
                    triangles[0].VertexA = p0;
                    triangles[0].VertexB = p1;
                    triangles[0].VertexC = p2;

                    triangles[1] = new TriangleShape();        // 1, 3, 2
                    triangles[1].VertexA = p1;
                    triangles[1].VertexB = p3;
                    triangles[1].VertexC = p2;

                    triangles[0].Sidedness = BEPUphysics.CollisionShapes.ConvexShapes.TriangleSidedness.Counterclockwise;
                    triangles[1].Sidedness = BEPUphysics.CollisionShapes.ConvexShapes.TriangleSidedness.Counterclockwise;
Here is a video demonstrating this phenomenon:

http://screencast.com/t/4TwrUyu7
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Box entity sometimes passes through triangle entity.

Post by Norbo »

CCD can't absolutely guarantee that things won't penetrate another object. Even if CCD identifies a time of contact, it's still possible for an object to generate a sequence of individually valid contacts which cannot stop the object from 'walking' its way through a wall with sufficient angular velocity.

If your update rate is set to 30hz, this problem would be more noticeable. Increasing the update rate would help at the cost of performance.

What are the exact sizes of the boxes/triangles and velocities involved? The convex-triangle case doesn't yet use a special case for CCD, so it's possible there are numerical issues. It shouldn't manifest until sizes get pretty extreme, though.

There are some improvements coming in the future (not for the initial v0.15.0 release). The information CCD uses to find the time of impact can be used to improve discrete collision as well, which could be used to significantly reduce the 'walking through the wall' issue. A special case sweep test for convex-triangle would also help with numerical issues.
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Re: Box entity sometimes passes through triangle entity.

Post by Spankenstein »

Box Size: 0.25f
Triangle Size: Ranges from: (1f x 1f) to (25f x 25f)

Velocity of the Box is set using:

Code: Select all

voxel.ApplyImpulse(activeCamera.Forward * 15f);
Camera Forward is of unit length (normalized) and the velocity never changes.

Changing ONLY the time step duration helps:

Code: Select all

space.ActivityManager.TimeStepSettings.TimeStepDuration = 1f / 300f;
This doesn't appear to have a great impact on the performance. What TimeStepDuration would you recommend?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Box entity sometimes passes through triangle entity.

Post by Norbo »

The default is 1/60f, which should work okay in most cases. CCD should allow you to avoid increasing the update rate quite that high, though you can just try increasing the update rate (1/60, 1/90, 1/120, and so on) until the problem goes away or the performance gets too low. The box being that small might push the requirement a bit higher than it would otherwise be. Increasing the size of the cubes would help some, if it makes sense in the game.

Given those sizes, I wouldn't expect to see significant numerical issues though. I'm guessing the problems you're seeing are related to the 'walking through the wall' issue.

(By the way, the you can access the TimeStepSettings directly in the space TimeStepSettings property.)
Post Reply