Couple of questions

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
RobH
Posts: 1
Joined: Tue Jun 02, 2009 8:26 am

Couple of questions

Post by RobH »

Firstly I want to say.. thanks for a very cool physics engine, I spent a bit of time playing with various engines in my game and this seemed by far to be the easiest to use.

Now just a few questions;

Firstly, how does the mass on the physics entity constructor work? I tried cranking it way up on some stuff yet it seemed to have no effect on how weighty an object appeared. I've had to speed up the time and increase gravity to make my entities stop feeling like they are sort of in liquid.

Secondly, I'm having some performance issues with the engine when there are ~110 or so entities in the world. The entities are all boxes (not complex meshes) but I've noticed that they never seem to just sit still; they constantly look as though they are jiggling around slightly which makes me think that the engine is running logic on them even though they are not being disturbed; is this normal? is there some sort of threshold for "don't mind me I'm just sat idle".

And lastly, my world is loaded from a BSP tree similar to Quake/Half-Life and I'm doing world collision with the physics engine by carving the map faces up into triangles at load time and loading those triangles into the physics engine as a static triangle group. It seems to work well but is this the most efficient way of doing this for a large world?

many thanks

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

Re: Couple of questions

Post by Norbo »

RobH wrote:Firstly, how does the mass on the physics entity constructor work?
It comes into play during physical interactions. Kinematic objects (including nonmoving static triangles) have infinite mass, so the collider's mass doesn't change anything. Between two dynamic objects, the mass and inertia tensor are used to figure out how to resolve the interaction. A heavy object interacting with a light object will have the expected result. Changing the mass of an object that is in a vacuum has no effect since it interacts with nothing.

Basically, heavy objects need to be heavy relative to something. You can further adjust the 'feel' with damping/friction/bounciness (or if it is supposed to be really heavy, sound effects and screen shaking).
RobH wrote:they constantly look as though they are jiggling around slightly which makes me think that the engine is running logic on them even though they are not being disturbed; is this normal? is there some sort of threshold for "don't mind me I'm just sat idle".
Yes, you can adjust the space.simulationSettings.linearVelocityClamping field and the other related clamping fields. However, I have a feeling that the jittering is caused by scaling problems. If your world is very large relative to what the system is tuned for, you will experience various odd effects. The collision detection system is one area where these effects manifest.

How large is your world in units? Typically, sticking to sizes between .2 and 50 or so will help robustness. For an average game level, most objects could consider a unit to be a meter safely. This scaling issue would also explain why, with default gravity/timing, things appeared to be overly floaty. Since the default gravity was 9.81 units per second, if your shapes are 100 units across (yet are intended to be something like 1 meter in 'gameplay' units), they would appear to fall very slowly.
RobH wrote:And lastly, my world is loaded from a BSP tree similar to Quake/Half-Life and I'm doing world collision with the physics engine by carving the map faces up into triangles at load time and loading those triangles into the physics engine as a static triangle group. It seems to work well but is this the most efficient way of doing this for a large world?
The StaticTriangleGroup is your best bet as of right now. In the future I'd like to look into adding some more explicit BSP-style collision support to allow for more application specific optimizations, but it won't be available in the near term.

If the BSP to mesh conversion time is a concern, you could try creating a TriangleMesh object from the BSP during the build stage and serializing it. The TriangleMesh has a few static methods to help with this process (TriangleMesh.save and TriangleMesh.load).
Post Reply