Lots and lots of problems with BEPU.

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Charibo
Posts: 2
Joined: Mon Aug 24, 2009 6:31 pm

Lots and lots of problems with BEPU.

Post by Charibo »

Hello!

I`ve been fighting with it since like eight hours, and I`m fed up. I have basically no idea what may be going wrong.

First and most annoying problem:
I`ve got two tanks in my test app. They both are created like this:

Code: Select all

List<Entity> spheres = new List<Entity>();
            for (int i = 0; i < czolg.mdl.Meshes.Count ; i++)
            {
                ModelMesh mesh = czolg.mdl.Meshes[i];
                float rad = mesh.BoundingSphere.Radius * 0.9f;
                Box box = new Box(mesh.BoundingSphere.Center, rad, rad, rad, 1000);
                spheres.Add(box);
            }
            tankS = new WrappedBody(playerCar.Position, spheres, 10000);
They both have their mass parameter set to 10000 units. Yet still, when I`ll apply some velocity, and they collide, they are rolling, bouncing and flying all over the scene: http://screenup.pl/?l=E4PMV7O (screen). Setting mass to even higher values won`t work.

Second problem:
Gravity doesn`t work. I`m setting it as in an example (scene.Settings.gravity, blabla). Yet it is only visible, when I set it to some ridiculous value (like 0, -90000, 0). And then, objects start to shake.

Third problem:
Rotation. I've been trying to integrate BEPU into existing game core, so I`ve got all classes, input management and so on ready. I figured out something to do translation, and I do it this way:

Code: Select all

tankS.linearVelocity = playerCar.Velocity;
playerCar is an instance of my own class, tankS is WrappedBody. Yet I`ve got no idea how to create rotation of my tank. I`ve got a vector pointing to a direction where it`s faced. I tried some tricks, like

Code: Select all

Matrix World = tankS.worldTransform;
                World.Right = playerCar.Right;
                World.Forward = playerCar.Direction;
Yet it deforms my mesh (when it starts to collide). I also tried to create rotation matrices from these vectors and so on.

Fourth problem:
Collision Detection sometimes doesn`t work. Especially with StaticTriangleGroup (loaded and created as in example). See a screenshot: http://screenup.pl/?l=9AAUKIP . I`ve managed to "push" one tank beneath the surface with another pretty easily. Surface is StaticTriangleGroup of course.

Fifth problem:
Simulation freezes quite often. I mean - totally. When I do a Break in Visual Studio during that freeze, it shows in call stack, that program frozen during space.update(..) method. It never ends, like infinite loop or sth.

Regards!
Maurycy Chomicz
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Lots and lots of problems with BEPU.

Post by Norbo »

It sounds like most of these problems stem from the scale of your scene. As a rule of thumb, consider 1 unit in the physics engine to be about 1 meter in real life. For example, a tank might be a few units in each dimension.

Extremely large (or small) values run into floating point precision problems, especially in collision detection. This is because the single-precision floating point value just doesn't have enough values at those large scales to handle finely detailed things like collision accurately. Avoid excessively large or excessively small objects; try to keep things around 0.2 to 10 units (including individual collision mesh triangles) if possible.

Check out the demos or basic setup demos for some example simulations. You could start with the 28th demo of the demos project for an example of StaticTriangleGroups.

It may also help to keep masses relatively small, and avoid large mass ratios. Mass ratios higher than 1:10 in certain interactions can be difficult for the collision response system.

The angular version of linearVelocity is angularVelocity. You can also rotate objects directly by setting an Entity's orientationMatrix, orientationQuaternion, worldTransform, or motionState properties with valid values.
Charibo
Posts: 2
Joined: Mon Aug 24, 2009 6:31 pm

Re: Lots and lots of problems with BEPU.

Post by Charibo »

That was it! Norbo, you`re awesome :]
Thanks a lot, I`d never think about floating point precision issues. I just scaled down whole world 100 times and everything is working good now. :)
Post Reply