Create custom physics for an object with python Blender has physics options which we can enable for our objects - cloth , fluid etc. Is there a way I can add a custom physical behavior to my objects, where this behavior is modeled as a python script. For example, I'd like to add a new button to the physics tab like "My Physics", and when it is attached as a modifier to objects , the objects follow the behavior as modeled in the script.

Basically, I want to test some physics algorithms and want to use blender for that. So I'd be relying on blender to do the rendering and other things, but the physics will be provided by my code.

Is something like this possible?
Yes it is possible, there are 2 ways of doing this, but there are also 2 big drawbacks for both methods:


method 1: You can script your own modifier in c++, here is how to start. The drawback is you need to build your own Blender version yourself. Modifiers cannot be add with python or addons. If your modifier gets approved it can be added in the trunk (official release).
method 2: You can add your physics simulation code in the app handlers. This way your code gets executed for example every frame change. You can manipulate objects, change mesh etc. This will work from addon but the code will be very slow and you will unlikely get real-time fps.