Starting Box2D 3.0
box2d.org
box2d.org
Hah! In Planimeter Game Engine 2D, we shrink physics objects by the polygon skin slop so that we can achieve "pixel approximate" physics.[1] We keep sprite sizes the same and as a result there's no visible separation of objects, but Box2D continues to safely separate objects.
afaik, we're the only engine that does this with Box2D, and I think the results end up superior.
[1]: https://github.com/Planimeter/game-engine-2d/blob/master/eng...
No big rewrite effort, better type safety.
Get ready for CVEs.
As for the memory safety aspects: When returning raw pointers to internal objects from an API, those pointers can become dangling.
C++ smart pointers are not a solution because those cannot be expressed through a C API for language bindings - also there's the question what type of smart pointer to return - unique vs shared? That should be up to the API user, not dictated by the API.
Tagged index handles solve all those problems in a very elegant way - and they work equally well for C, C++ or any other language that supports arrays, and since those handles are essentially just integers, they are trivial to tunnel through FFI (see for instance: https://floooh.github.io/2018/06/17/handles-vs-pointers.html)
I know how well they work in C, having worked on a RPC server for IVR/CRM middleware using similar approach for shared memory IPC across UNIX/Windows multiprocess, and having my share of fixing memory corruption issues in collaboration with our QA team nicely written attack tests in Rational Robot.
I guess instead of using Purify and BoundsChecker, now the fun will be with ASAN.