Hello, everyone!
I’ve just released a new KMP library called Boks2D. The library binds to the Box2D physics engine (written in C by Erin Catto) and enables 2D physics simulations within the KMP ecosystem with great performance.
I ran benchmarks against other Kotlin 2D physics options (KBox2D and dyn4j), and Boks2D came out significantly ahead. You can see the graphs in the repo
https://github.com/joaomcl/boks2d
There's also a Compose Multiplatform sample app included, running at a steady 60 fps on all supported platforms.
The benchmark code is there too if you want to reproduce the results locally.
I understand that as it is essentially a game development library, it would be very useful to target the Web as well, so I'm already exploring the viability. The plan would be to compile Box2D to WebAssembly via Emscripten and expose it through a Kotlin/Wasm target, keeping the same performance-first approach. Memory management across the Kotlin/Wasm boundary sounds more challenging than JNI, but if it's actually viable and everything works out, I plan to release it as the next target.
If you try it out, I'd love to hear your feedback. Issues, PRs, and ideas are all welcome!