Differences between Box2D and Farseer Physics Engine 3.0
Static bodies have mass
Giving static bodies a mass means that we can attach joints to static bodies. A feature that can come in handy when creating dynamic game levels.
Normal joints take two bodies as arguments in order to keep a constrain between the two bodies. Fixed joints are joints that only take one body and then a world anchor. Sometimes we want a revolute joint to spin without attaching it to a body. This greatly
simplifies the use of joints and give a more intuitive interface to joints.
Box2D decided not to include controllers because they are only small containers of logic that run after a timestep. In FPE 3.0 we supply a couple of useful controllers, and even better, you can write your own controllers. Including controllers into the engine
also gives you live diagnostics on how long it takes to run your controller. This way you can identify performance related problems caused by controllers.
If you enable diagnostics in the Settings class, a stopwatch will time each module of the engine. This can be used to identify performance problems in your engine and in what areas you should optimize in order to get a smooth running game.
We collected all the settings in one place: the Settings class. You can optimize, tweak and enable/disable whole sections of the engine by editing the Settings. Some settings can even be edited while the engine is running.
Easy to use delegates
Collisions gets reported by the fixtures that creates them using the OnCollision delegate. There is also a OnSeparation delegate that tells you when a fixture is no longer in touch with anything. We have several easy to use delegates in the engine:
- Created and Removed versions of delegates to Body, Fixture and Joint
We have a couple of joints not included in the Box2D package. And we will probably get more in the future. Right now we have:
With compiler conditionals like "ConserveMemory" we can optimize the engine by changing the default behavior. The ConserveMemory conditional makes the engine use references of classes instead of cloning the classes. This way it consumes less memory,
but changing a class outside the engine will change it inside the engine.
Easy to use breakable bodies. You just give it a list of vertices and the engine will take care of the rest.
Creating complex curved chains is now possible using the Path Factory. You just give it the path it should build from and it will create a series of bodies along the path.
We can detect the outline of a polygon inside a texture and use the result in the engine. A useful feature when you have all the graphics pre-made and you want to make it physics enabled.
Factories provide a simple interface to common functionality. Instead of creating several objects and combining them, we do it all in one line of code. Common tasks of creating Fixtures, Bodies and even Joints have been simplified and can be done with just
one line of code.
Decoupled debug drawing
We took out all the stuff related to drawing and put it into a project by itself. This means we have absolutely no graphics related stuff inside the engine and even better; we provide a couple of debug views that you easily can plug into your project.
Lists versus linked lists
It is just an implementation detail, but we think it is intuitive to use lists instead of linked lists. Commonly used linked lists have been converted to ordinary lists to make it easier for you to interact with the engine.
There is a bunch of new tools in FPE 3.0:
- GiftWrap (convex hull algorithm)
- Melkman (convex hull algorithm)
- Bayazit (convex decomposer algorithm)
- Earclip (convex decomposer algorithm)
- YuPengClipper (Boolean operations using Yu Peng's algoritm)
- CutterTools (A tool to cut convex polygons)
- SimplifyTools (A toolset to simplify polygons using a variety of different algorithms.)
Cancel a collision
If you return false inside a OnCollision delegate, the contact will not be created and solved. This way you can disable collisions based on game logic.