Using Ammo To Create Soft Body Entities

Hello, I’m trying to use Ammo directly to create soft body entities, which the documentation suggests is possible, but either I’m missing something or this is not possible without forking the engine.

Here is where the physics world is created using Ammo in the engine.

It uses the Ammo.btDiscreteDynamicsWorld constructor which returns a world instance that does not have the ability to add soft bodies. The Bullet user manual suggests (page 7) you need to use the btSoftRigidDynamicsWorld constructor if you want to be able to add soft bodies to the world.

Seeing as how the component system in the engine file referenced above handles calling the the stepSimulation on the physics world returned from btDiscreteDynamicsWorld and all the other rigid bodies I don’t see how it would be possible for me to create a separate physics world for the soft body that can still interact with the rest of the rigid bodies in the project.

One option of course is to fork the engine and change the btDiscreteDynamicsWorld to btSoftRigidDynamicsWorld, but that’s not ideal. Any help / direction on if I’m just missing / not understanding something would be greatly appreciated!

Hmm… Judging from what you have found I was thinking you might be able to monkey patch the engine which would get around the need for forking. However, I don’t know when that component system gets created and the monkey patch may be added too later into the process.

Maybe that patch could be added via the external script system, that could add it sooner.

That’s what I was thinking as well, but I’m not sure what exactly you mean by an external script system, if you could elaborate or have any examples for that that would be great.

https://developer.playcanvas.com/en/user-manual/designer/settings/#external-scripts

Ohh I see, I’ll try implementing a patch by doing that and see how it goes. If anyone on the playcanvas team happens to see this, would love to know if there are any performance reasons for not just using btSoftRigidDynamicsWorld to give the option of soft body support or if it would possible to create some flag for switching between btDiscreteDynamicsWorld and btSoftRigidDynamicsWorld at a project level.