PhysicsKit - Framework wrapping Bullet for iOS / SceneKit projects

Post Reply
AdamEisfeld
Posts: 2
Joined: Tue Jun 16, 2020 6:11 pm

PhysicsKit - Framework wrapping Bullet for iOS / SceneKit projects

Post by AdamEisfeld »

Hello!

I have created an open source wrapper around Bullet for use in iOS applications which can be found here https://github.com/AdamEisfeld/PhysicsKit.

As I have been working on a personal project backed by Apple's SceneKit library (provides an abstraction for rendering 3D scenes via OpenGL / Metal, wired up to a stock physics engine), I found the physics engine implementation that comes with SceneKit to be a little lacking. Primarily, I needed a way to do client-side prediction / server reconciliation, which required the ability to manually "step" the physics simulation forward after applying some historical client inputs, which SceneKit does not support.

After some investigation I figured Bullet would be a good option so I created the above implementation. It is fairly early stages as I have only been working on it for a few days, but it accomplishes what I need so far and I will continue to add to it as my related project progresses.

At it's core, the framework provides functionality for creating a physics world, collision shapes, rigid bodies and ghost objects ("triggers" in the framework), and optionally attaching those rigid bodies to corresponding SCNNodes as a visual representation of the rigid bodies in SceneKit.

The framework is available via Cocoapods, and I will investigate adding support for Carthage and possibly Swift Package Manager in the future. See the repo's README / the source documentation for more info.

Just thought I would post it here as it might be useful to anyone else trying to get Bullet up and running in an iOS project.

Contributions welcome!
- Adam
AdamEisfeld
Posts: 2
Joined: Tue Jun 16, 2020 6:11 pm

Re: PhysicsKit - Framework wrapping Bullet for iOS / SceneKit projects

Post by AdamEisfeld »

Just an update, I've made several improvements to PhysicsKit:

- fixed various memory management bugs
- added support for raycasting
- added support for "actions" (custom animations to run on rigid bodies over time)
- improved SceneKit geometry parsing for convex hull creation
- greatly improved example application (now demonstrates a static cylinder, with kinematic 3D text that spins / hovers up/down via actions, while random rigid bodies fall from the sky. Touching / dragging on the screen performs raycasts between the camera's near/far clipping plane, applying impulse forces to any intersected rigid bodies. Gif below)

Next steps:

- constraints (joints primarily)
- HACD decomposition support
- physics fields (drag, gravity, repulsion, electromagnetic/static?)
- vehicles
- maybe (big maybe) soft bodies

Thanks,
- Adam
Attachments
physicsKitGif.gif
physicsKitGif.gif (2.81 MiB) Viewed 2120 times
Post Reply