PhysX-sharp

- Subversion Repository 

PhysX-sharp (previously PhysX.NET) is our C# wrapper around the Ageia PhysX api. It allows you to use the PhysX physics engine in your .NET or XNA pc-game. It is build using our home-made tool DoxyBind, which parses the xml output of the popular documentation generator Doxygen. The generated bindings still need a little manual fixing afterwards, but the results are generally very good. The bindings also support class inheritance wherever possible. Compared to some other bindings for PhysX that are out there, our bindings have the advantage that they use a combination of a C and C# wrapper using P/Invoke. This method is also supported on Linux and MacOS using Mono. Most of the other projects are using C++/CLI which is not (yet) available outside Windows. Because of the automatic generation our bindings also wrap virtually everything. The downside is however, that performance will be a bit lower than for manual bindings and there a greater chance that errors will go unnoticed until someone stumbles over them.

A few remarks to consider when using these bindings:

  • You should keep an eye out on abstract methods, these will be declared virtual in C#. If you do not override these methods, you will get an exception.
  • You have to dispose of objects manually. The managed class is merely a nice way to toss pointers around, so the GC has no proper way to track the native object. Besides that, you have to do the same if you're using C++.
    ( version 0.9.2 has finalizers for classes that are created ( new NxObject() ) in managed code and they will delete the unmanaged class when the managed class is collected, but using Dispose() is still recommended as it will release memory earlier and make sure that the class is not collected until you want to )
  • Properties have to be explicitly set. This means that if, for example, a property returns a vector, just changing the vector won't do anything, you'll have assign the new vector explicitly to the property (much like value type properties in C#).
  • The PhysX SDK libraries (PhysXLoader.dll, NxCooking.dll and NxCharacter.dll) and the C bindings (PhysX.dll) should be placed in the executable path.