Disabling certain physics properties?

Aug 6, 2009 at 12:25 AM
Edited Aug 6, 2009 at 12:49 AM

Hey guys,


So I'm trying to use the physics engine less like a physics engine and more like a simple collision and movement engine. Is there a easy way to say turn off rotational calculations, bounce physics, frictions,  etc... but I would still like to keep the collision part and simple impulses.

I'm not sure that is the right train of thought. The reason I want to dumb it down is to possibly get more bodies with geoms attached on the screen. currently my new game is crawling once I have 80+ active objects in the physics simulation.


Btw, I'm just using rectangles and spherical geometries. I was thinking maybe SAT can help me increase performance?


Aug 6, 2009 at 12:37 AM

Well, it is not supported by the engine, but if you really don't need friction or rotation you can just comment out those lines of code. They only account for about 5-10% of the total running time of the engine. Are your geometries complex or is this on Xbox360? I can simulate 120 geometries easily (in less than 4 ms) - I simply ran the pyramid sample.

Anyway, there are several optimization techniques depending on game logics. An example would be to only load what can be seen and not all physics objects at one time. You could also switch to another broad phase collider to see if that improves performance.

Aug 6, 2009 at 12:56 AM

Maybe if I describe the logic it might help out. So I have static planets, and dynamic ships. I apply impulses to ships to get them heading towards a specific planet. Once they hit a planet the bodies are disabled. I think that's really the only part I'm using with the engine.

This is on the 360, I have no problems with the PC. The geometries right now are complex, but I can compromise by switching the ships to a rectangle. All active objects are always visible because total playing area is always in view.

I was thinking of setting collisionResponseEnabled to false on all my objects since they are destroyed upon contact with each other. Another thing I was thinking of doing was using SAT for narrowPhase since all my objects are convex.


What are your thoughts genbox?


Aug 6, 2009 at 11:19 AM

Since you only need to know when a collision happens, you can go ahead and set collisionResponseEnabled to false. It will disable all physics responses on the geometries. You should profile if the SAT algorithm really is giving you better performance than DG. You can do this by simply see how much time it takes to calculate your collisions.

SAT does not like a lot of polygons. Lesser polygons equals better SAT performance. DG likes more polygons (give better accuracy).

Also, if your planets are round you might gain something by implementing a BoundingCircle and use that. It does not sound like you really need to know the exact position of the collision, so you can skip a narrow phase check all together. When you have the BoundingCircle in place, you can use the OnBroadPhaseCollision() event on the broadphase collider and just return false. This will completely disable all kinds of physics and half the collision system.