-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
do you have a sense how hard it would be to adapt this for liquidfun? #17
Comments
Hm, I agree that the approach used in this repository (consume C++ via git submodule, bind via WebIDL) would be more maintainable. Might not be too difficult. Some observations:
Based on file dates, it kinda looks like Liquidfun leaves most of the Box2D source untouched; the fork contribution is primarily the Particle directory? The approach used for binding in this repository would not be interface-compatible with the manual bindings used in Liquidfun currently, so any testbed examples would need tweaking in order to work. The path of least resistance may be to fork Box2D at its latest commit, and add the Particle folder back in, (and confront any breaking API changes). then consume that in this repository, update the WebIDL bindings to include Particle classes. |
Totally agree with your observations (it is old and under-maintained), and the clever trickery to speed up calls looked both like a maintenance burden, and unnecessary in 2021. I believe the original intent was gamedev but these days box2d is getting a lot of usage as a simple physics engine for machine learning / AI. Much of that is in a Python-led world e.g. openai environments like BipedalWalker; but also increasingly in JS (example, see also [tensorflow.js]).(https://www.tensorflow.org/js/demos).
AFAIK that sounds plausible
Noted. Personally I don't see that as a problem (it's possible others have other plans, but things seem quiet...).
I had the impression from comments in the liquidfun repo that this would be a substantial undertaking, definitely beyond me, though I'd love to see it! |
I've made a commit of "all non-whitespace changes to C++ source", based on Box2D v2.3.0: Looks like it's more than just the Particle folder that changed. Quite a few files are touched, but it's mostly additions rather than contradictions. Not sure how much the world moved in the years since then (i.e. Box2D v2.4.1). All files were renamed (i.e. to eliminate capital letters), which will add some challenge to a rebase. I think there's a lot of changes, but most are so light-touch that it'd be easy to figure out where to insert them in v2.4.1. May need manual attention though. |
I've had a stab at manually copying all those changes onto Box2D v2.4.1: https://github.com/erincatto/box2d/compare/master...Birch-san:liquidfun-rebase?expand=1 Haven't tried compiling or running it. There weren't many errors in my IDE, except that I'll need to change all Bost of the changes don't look like they'd cause problems, but I saw substantial rewrites to timers and to memory allocation. |
Updated WebIDL bindings: Fixed other compile errors (e.g. missing symbols that Emscripten noticed at link-time): It's successfully compiled to WASM locally on my computer, and my original examples still work (haven't regressed). Various new symbols (i.e. the ones that I exposed via WebIDL) are accessible via JS:
Next step would be to build a demo to see if they work. |
I've only had a little time to poke at this, but it looks great - can confirm it builds fine, the integration-test app works and shows particles, the demos still function etc. |
I've (as a temporary step for testing/exploration) put a copy of the generated .js and .wasm on my site, so it can be loaded from elsewhere (please nobody make anything that will break if this goes away!). I did this to see how the WASM approach might look in other environments. I only got this far in the online P5 editor: https://editor.p5js.org/danbri/sketches/hWpLvdEB5 - for some reason it only works for me when using an incognito window, but fails while logged in. It could also be interesting to adapt the backend examples and try a python-wasm runtime e.g. via Colab. The P5 example doesn't try using particles yet.
See also Twitter thread |
Liquidfun (an interesting fork of box2d that adds particle/fluid capabilities) has some pre-WASM emscripten tooling, but it seems out of date. I was wondering if your approach here would be more maintainable, and if you'd have any interest in trying it...
The text was updated successfully, but these errors were encountered: