Native Bullet - SoftBody

@zzuegg
I think if you just try and have specific questions,we will help as good as possible, as always :slight_smile:

Yeah, i will play with it a bit.

Oh you can write directly to directbytebuffers from c++, in fact this is already at at least one place in the bullet binding.

*NativeMeshUtil.cpp
int* triangles = (int*) env->GetDirectBufferAddress(triangleIndexBase);
        float* vertices = (float*) env->GetDirectBufferAddress(vertexIndexBase);

As for the performance, I agree, getting stuff to work first is most important, the few methods with real performance problems could be made into an (optional) accelearation native lib then. that replaces certain method calls if necessary.
JNA is fine itself, and widely supported.

Hey David

It turned out that I hadn’t instantiated a callback that Bullet uses to pass the fact that there is a pending collision into JME3 (This callback checks that the collision is allowed to take place, then proceeds with the collision as per the usual bullet physics)

If you instantiate this callback and handle it correctly, SoftBody and RigidBody bullet objects interact perfectly in the Bullet physics engine.

However, the integration between JME and Softbody with respect to rendering and manipulating SoftBody objects is not present.

This doesn’t matter for my project, since I use an external rendering program (Java3D) and simply use a now customised version of JME3 as a convenient interface to the physics engine- with my objects instantiated and controlled with my own software.

I’ve been meaning to fully wrap the SoftBody class in a way that is fully usable and extensible by the JME community (and indeed have created classes such as SoftBodyControl and PhysicsSoftBody), but a lack of familiarity with the spatial management and rendering pipeline of the JME engine has been holding me back.

I’ll upload the code that I’ve created so far open sourced so that you can check it out- and I’ll try to figure out a good way of adding softBody to the JME3 main branch in a clean way that is separate from my project (it’s a little messy and custom at the moment)

tl;dr

=) SoftBody works within Bullet Physics and can be made to work in JME3
=( SoftBody doesn’t get natively drawn by JME3
=) It doesn’t take much to make SoftBody work with JME3: I can generate a basics-only test case for you to play with
=( It requires recompiling the JME3/Bullet interface JNI code, but that can be done easily with an Ant script

2 Likes

@anthonyevans2000, thanks for the status. It seems lot of work todo, out of my skill :-(.

I 've got an other issue with native bullet : jvm crash (see Bullet-native, fatal error )

[libbulletjme64.so+0x1280f4]  btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleIndexCallback*, btVector3 const&, btVector3 const&) const+0x244

So I’ll first try a workaround like having spring in jbullet.

How large is your mesh? Bullet does internally compress some values into one int, this is a cause for overflow errors.