Page 1 of 1

PhyKit -iOS / macOS framework wrapping Bullet + SceneKit integration

Posted: Tue Jun 16, 2020 8:14 pm
by AdamEisfeld
Update: PhysicsKit has been renamed to PhyKit (due to linker issues with Apple's internal PhysicsKit framework) and has been reworked quite a bit, so I'm editing the body of this original post to describe PhyKit)

Hello!

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

Image

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 (ironically, I believe Apple is using Bullet under the hood, but their API does not support what I'm after and feature requests from a single developer tend to not happen).

PhyKit is compiled as a universal xcframework, targeting iOS simulators / devices as well as macOS. The framework can be downloaded directly from the repo and dragged into your Xcode project, or you can use Swift Package Manager or CocoaPods to install the framework as a dependency.

At it's core, the framework provides functionality for:
- Creating a physics world (PHYWorld)
- Creating various collision shapes, including from SCNNode geometry (PHYCollisionShape)
- Creating rigid bodies (PHYRigidBody)
- Creating ghost objects (PHYTrigger)
- Attaching rigid bodies to SCNNodes
- Raycasting
- PHYActions (performing a piece of logic on a node over time, such as PHYAction.moveTo(x, y, z, 10) or PHYAction.orientBy(x, y, z, 20)

Contributions welcome!
- Adam

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

Posted: Sat Jul 04, 2020 4:54 pm
by AdamEisfeld
I've removed this comment as I've updated the original post's information.

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

Posted: Tue Jan 05, 2021 6:11 am
by AdamEisfeld
I've removed this comment as I've updated the original post's information.

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

Posted: Wed Jan 06, 2021 9:59 am
by ortwingentz
That's funny since SceneKit is already using Bullet under the hood. Did you write an enhancement request? I guess it would be relatively easy for the SceneKit folks to add your features.

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

Posted: Fri Jan 08, 2021 4:34 am
by AdamEisfeld
Even funnier is it turns out they also have a private framework called PhysicsKit which was causing linking issues with my framework on certain builds, so I've had to rename it to PhyKit. I haven't filed an enhancement request (I did contact them asking if there was any way to manually step the sim, and was told it was unsupported and wasn't on any roadmap to be added anytime soon). I'll file a request but I doubt it will get much traction without a lot of people asking for it.

On that note, PhysicsKit is now PhyKit, available at https://github.com/AdamEisfeld/PhyKit. I'll edit the original post with that info.