Building the Bullet wrapper

The Bullet physics library extension is a Java wrapper for the C++ engine. It is generated by the interface compiler called SWIG.

Modifying the wrapper

New or modified functionality can be added to the Bullet wrapper by modifying the SWIG interface files in libgdx/extensions/gdx-bullet/jni/swig. Consult the SWIG documentation for details.

Bullet wrapper custom classes which add extra functionality should be put into libgdx/extensions/gdx-bullet/jni/src/custom. To use the new classes in Java, include them in the SWIG interface files.

Building the Java module

After the SWIG interface files have been modified, build the gdx-bullet Java module.

cd libgdx/extensions/gdx-bullet/jni/swig
ant -f build.xml

This will generate Java classes from the Bullet source in libgdx/extensions/gdx-bullet/jni/src, using the SWIG interface files.

If a new C++ source file was added, it is necessary to update the Android.mk build file before compiling the native Bullet code. This is done by running the Java program libgdx/extensions/gdx-bullet/src/com/badlogic/gdx/physics/bullet/BulletBuild.java using the working directory libgdx/extensions/gdx-bullet.

Compiling the native Bullet libraries

After the SWIG module has been built, the native libraries for the different architectures can be compiled.

cd libgdx/extensions/gdx-bullet/jni
ant -f build.xml all

In order to check for problems, verbose output can be enabled with the -v flag. To compile for Android, the NDK_HOME environment variable must be set. If Linux is used to compile, it may be necessary to append the options -DndkSuffix="" -Denv.NDK_HOME="/opt/android-ndk".

The resulting native binaries will be placed into libgdx/extensions/gdx-bullet/libs. Note that running ant -f fetch.xml in the libGDX root directory will overwrite them.

Testing on Android

Copy the new native libraries into the corresponding Android test paths

cp libgdx/extensions/gdx-bullet/libs/armeabi-v7a/* libgdx/tests/gdx-tests-android/libs/armeabi-v7a/
cp libgdx/extensions/gdx-bullet/libs/armeabi/* libgdx/tests/gdx-tests-android/libs/armeabi/
cp libgdx/extensions/gdx-bullet/libs/arm64-v8a/*  libgdx/tests/gdx-tests-android/libs/arm64-v8a
cp libgdx/extensions/gdx-bullet/libs/x86/*  libgdx/tests/gdx-tests-android/libs/x86
cp libgdx/extensions/gdx-bullet/libs/x86_64/*  libgdx/tests/gdx-tests-android/libs/x86_64

Then build and run the Android test suite.

gradlew tests:gdx-tests-android:installDebug

Testing on Desktop

The new native libraries will be automatically used for the desktop test suite, which you can run using the Gradle wrapper script.

gradlew tests:gdx-tests-lwjgl