JVM bindings for Jolt Physics
currently under construction
Jolt-jni provides a thin layer atop Jolt Physics, to facilitate physics simulation in JVM languages such as Java and Kotlin.
There’s close correspondence between the class/method names of JoltPhysics and jolt-jni. For example:
- The
Body
class in jolt-jni will eventually provide all the functionality of theBody
class in Jolt Physics. - The
ConstBody
interface will include all theconst
methods of the JoltPhysicsBody
class, such as itsGetPosition()
method, which in jolt-jni is calledgetPosition()
.
Things become slightly more interesting when C++ templates and public member data are involved:
- An array of body IDs is
Array<BodyID>
in JoltPhysics; in jolt-jni it’s called aBodyIdVector
. - The
mConvexRadius
member of the JoltPhysicsBoxShapeSettings
class is accessed usinggetConvexRadius()
andsetConvexRadius()
in jolt-jni.
For a couple well-known JoltPhysics examples, direct translations into Java are provided.
Jolt-jni comes pre-built as a platform-independent JVM library plus a set of native libraries, all downloadable from Maven Central.
Current jolt-jni releases provide the JVM library under 6 distinct names (artifact IDs). They also provide 24 native libraries, each specific to a particular platform, build type, and build flavor.
Your runtime classpath should include a JVM library plus 1-to-6 native libraries: a native library for each platform on which the code will run.
Add to the project’s "build.gradle" or "build.gradle.kts" file:
repositories {
mavenCentral()
}
dependencies {
implementation("com.github.stephengold:jolt-jni-Linux64:0.5.0") // JVM library
runtimeOnly("com.github.stephengold:jolt-jni-Linux64:0.5.0:DebugSp") // native library for Linux
// (Native libraries for other platforms could go here.)
}
- The "Linux64" platform name may be replaced by "Linux_ARM32hf", "Linux_ARM64", "MacOSX64", "MacOSX_ARM64", or "Windows64".
- The "DebugSp" classifier may be replaced by "DebugDp", "ReleaseSp", or "ReleaseDp".