Birch-san / box2d-wasm

Box2D physics engine compiled to WebAssembly. Supports TypeScript and ES modules.
265 stars 21 forks source link

Thanks you for your Liquidfun rebase! #44

Open DJuego opened 2 years ago

DJuego commented 2 years ago

My best regards!

I want to thank you for having shared your work on the rebasing of the LiquidFun library with the latest Box2D version. I program in C++ (I'm a novice), and I was really interested in an effort along these lines.

I was able to compile it successfully in Visual Studio 2019 except for Testbed, which gave me errors. Fortunately it can be disabled with -D BOX2D_BUILD_TESTBED:BOOL=OFF. Anyway I leave you here the errors for reference. :-)

P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\testbed\draw.h(98): error C2259: 'DebugDraw': cannot instantiate abstract class
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\testbed\draw.h(61): note: see declaration of 'DebugDraw'
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\testbed\draw.h(98): note: due to following members:
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\testbed\draw.h(98): note: 'void b2Draw::DrawParticles(const b2Vec2 *,float,const b2ParticleColor *,int32)': is abstract
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\include\box2d\b2_draw.h(91): note: see declaration of 'b2Draw::DrawParticles'
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\testbed\draw.cpp(32): error C2259: 'DebugDraw': cannot instantiate abstract class
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\testbed\draw.h(61): note: see declaration of 'DebugDraw'
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\testbed\draw.cpp(32): note: due to following members:
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\testbed\draw.cpp(32): note: 'void b2Draw::DrawParticles(const b2Vec2 *,float,const b2ParticleColor *,int32)': is abstract
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\box2d-liquidfun-rebase\include\box2d\b2_draw.h(91): note: see declaration of 'b2Draw::DrawParticles'
NMAKE : fatal error U1077: 'P:\Desarrollo\cmake\bin\cmake.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.

I would like to ask you about the experience with your rebase, does it work correctly, has it met your expectations, has it been stable?

I am surprised that this interesting contribution has not had more projection.

Thanks again!

DJuego

Birch-san commented 2 years ago

no problem; glad it's appreciated. here's some extra diffs that illustrate what's included in the rebase:
https://github.com/google/liquidfun/issues/81#issuecomment-787498634

except for Testbed

okay, yeah that makes sense… draw.cpp needs to implement the new b2Draw method, DrawParticles.
it gives you a pointer-to-circle (an array thereof); you just need to iterate over each circle and invoke your existing DrawCircle method on each of them.
I implemented it in JS here:
https://github.com/Birch-san/liquidfun-play-2/blob/master/src/debugDraw.ts#L148
and here (integration-test/src/debugDraw.ts):
https://github.com/Birch-san/box2d-wasm/compare/master...liquidfun

experience with your rebase, does it work correctly, has it met your expectations, has it been stable?

yeah, I haven't found any problems at all. seems to work very well. the only thing I really tried was this:
https://birchlabs.co.uk/liquidfun-wasm/

mercifully, most of the liquidfun stuff is self-contained (new files like the Particle folder), so it rebased pretty well, and makes sense that it wasn't weaved too sensitively into the rest of the code. I'm optimistic that if you wanted to do something big with it, it'd probably go smoothly.