qml-box2d / qml-box2d

Box2D QML plugin
zlib License
268 stars 95 forks source link

A new LiquidFun integration #115

Open ThomasVogelpohl opened 7 years ago

ThomasVogelpohl commented 7 years ago

Hi all,

I really like the water simulation LiquidFun from Google and therefore I have tried a new integration into qmlbox2d. I have taken the excellent work of Vikke Matikainen on https://github.com/vmatikainen/qml-box2d (See issue #58 https://github.com/qml-box2d/qml-box2d/issues/58) and tried to improve the CPU cycles needed. The original software of Vikke does not run on an iPad Air and quite bad on a Google Nexus 9. Vikke used a QML Particle system with a manual update of the positions, which is quite slow.

So I have created a lot of QML Rectangles ( in form ofQQuickItems) and set the position of the items in the update C++ update function. The identification works with attaching the pointer of the QQuickItem to the corresponding Box2D Particle. I have only done rough profiling (just CPU cycles on the Mac) and QQuickItems version seems to be 40% to 45% faster than the QML Particle version. I can run this version even on the tablets and they run just about OK, depending on the number of box2d-Particles.

I have also implemented debug draw for the box2d Particles.

Missing:

You can find the fork on: git@github.com:ThomasVogelpohl/qml-box2d.git Branch: LiquidFun

You find an example: wavemachine.qml

Please let me know what you think. Maybe you have suggestions for speed enhancements.

Best regards, Thomas

ThomasVogelpohl commented 7 years ago

Hi, just enabled SIMD instructions for Arm Neon and the example wavemachine runs really well with more than 5300 particles on the Google Nexus 9. Very neat. I have not tried on the iPad, as currently it does not compile.

Will check-in the changes soon.

BR, Thomas

bjorn commented 7 years ago

@ThomasVogelpohl This sounds really awesome! I'll be sure to try it out sometime soon.

Since unfortunately I have very little time for this project, as you've already noticed of course, I've just invited you to the qml-box2d organization so that you can feel free to push changes yourself that you are comfortable with.