BEPUphysics (physics library) for Monogame

Last night, I was looking for a 3D physics engine for Monogame and I reached BEPUphysics.

BEPUphysics is a 3D physics library by BEPU.  It’s fast and has a bunch of cool features like constraints, terrain, static and instanced meshes, continuous collision detection, custom collision rules, vehicles, easy multithreading, yadda yadda yadda.  Full support for XBox360 and WP7 too!

Investigating BEPU website, I found that there's a work in progress version of BEPUPhysics for Monogame (the clue was a one blog post called "BEPUPhisics and XNA" and said The most likely target frameworks for the rewritten demos will be either SharpDX or, for wider use, MonoGame.) and also a twitt form the BEPUPhysics that said "The new demos application is indeed almost certainly going to be MonoGame based"

So I decided to take a look at BEPU source code repository and community-contributed forks.

I saw a monogame fork of BEPUphysics at http://bepuphysics.codeplex.com/SourceControl/network/forks/StephenOC/MonoGame and quickly download it, but my surprise was when I found that It's a windows version of BEPUphysics. But I far as I know I read it's posible running BEPUphysics on Monogame so I decided to try.

First, I openned Visual Studio and create a Windows class library. Then, I references Monogame Dll (to this test I use Windows OpenGL version) and put all BEPUphysics classes. Dont forget to set your project build propertis symbols to WINDOWS;ALLOWUNSAFE;CHECKMATH;MONOGAME

After a few build trys and removing some unuseful files, my build was succesful!

Then I create a Monogame Windows OpenGL game to test the BlocksExplodeYourCastle BEPU Demo game and I (almost) everything works out of the box! I say almost because the Monogame version of BlocksExplodeYourCastle was a lot of slower then XNA Version, but that's another history.

Also, I found a monogame build on the Monogame brach of PloobsEngine (https://code.google.com/p/port-ploobsengine/source/browse/PloobsEngine/PloobsEngine/Dlls/BEPUphysics.dll?name=MonoReach), but the BlocksExplodeYourCastle monogame version is still slow.

PS: I just run BlocksExplodeYourCastle monogame version and It runs at an acceptable speed! so I just need to make some more tests