JBullet Math Library Requirements

Hi guys,

I am looking to begin integrating physics into my game engine with JBullet. I am using JOML as my math library, but the JBullet library appears to use the javax.vecmath library. Does this mean that I will need to add the vecmath library to my project in order to use Bullet, or is there a port that uses JOML instead of vecmath? I understand that the two libraries offer different features that are suited to different tasks, but coordinating between two math libraries seems a little gross.

How have you guys gone about physics integration?

I just wrote some wrapper functionality in my engine, which only expose a few functions that just re-direct to the jbullet ones. I pass in joml classes into my functions, an create vecmath equivalents.

Probably not the cleanest way. But I agree with you, a JOML port would be very convenient.

@unlight, it would certainly be great if you could do the port. The latest JOML 1.9.3-SNAPSHOT version should now contain everything for a straightforward port. If not, anything missing can be added or worked-around quickly.
When porting, always make sure to check the source code of the exchanged methods, because even though javax.vecmath and JOML have similar designs, they deviate in two central aspects:

  1. Whenever the method of a binary operator is overloaded by taking an additional argument of the declaring class, in javax.vecmath this never means that the additional argument is the ‘destination’ into which to write the result, which is always the case with JOML operators.
    Instead, with javax.vecmath the destination is always ‘this’ and the additional overload only allows other objects than ‘this’ to be the left operand.
  2. the order of matrix row and column indices is swapped in the ‘m’ fields and in methods taking those indices, such as Matrix3f.setElement(row, column, value) vs. JOML’s Matrix3f.set(column, row, value).

That is a very reasonable approach, I think I will take a similar path, thank you!

Doing the port myself is definitely something that I would be interested in doing. I will create a post once university wraps up to gauge interest.