Expand Box2Dxt to the full Box2D v3.1.0 live-object API (ABI 3)#27
Merged
Conversation
The Kit (b2k…) previously left several core binding capabilities unexposed. Add friendly pixel/degree/screen-coordinate helpers so the Kit is a complete cover of the b2… surface: - Read state: b2kPosition, b2kWorldCenter, b2kGravityScale, b2kDamping, and b2kControlContains (rotation-aware point-in-shape test). - Act: b2kAngularImpulse (one-shot, mass-aware angular kick). - Contacts: a polling API (b2kContactCount/A/B + b2kEndContact…) so a b2kFrame handler can read touch pairs without a contact target. - Loader: b2kVersion for a Kit-only "loaded and in sync" check. Update the Kit header cheat sheet, the Kit reference doc, and the changelog to match. https://claude.ai/code/session_01NbsPt8oTFhzZJBry4GxjSR
Expand the shim, the lcb extension, and the Kit to cover essentially the whole Box2D v3.1 live-object surface in one change: ~240 new shim functions, each with a b2… extension wrapper and, where it helps, a b2k… Kit helper. All additive — every existing handler keeps its signature. Shim (src/box2d_lc.c): - Shape-def "pending overrides" builder (sensors, collision filter, per-event flags, material) applied one-shot to the next shape. - Chains handle table + point builder; sensor/hit/body-move event snapshots; one shared query-result buffer with C collector callbacks for overlap / ray-cast-all / shape-cast. - World tuning/info/explode/profile/counters; body transforms, velocity- and force/impulse-at-point, mass data, enumeration; shape geometry get/set, filter, material, event flags, ray cast, sensor overlaps; motor & filter joints; full per-joint get/set. - register_joint stamps joint handles into userData. ABI 2 -> 3. Extension (src/box2dxt.lcb): 1:1 foreign + public wrappers for every new shim function (verified: all binds-to symbols resolve to exports). Kit (src/box2dxt-kit.livecodescript): sensors (b2kAddSensor + on b2kSensorEnter/Exit), named-layer collision filtering, chains (b2kChain/b2kSmoothGround), region/ray queries, motor & filter joints (b2kMotorTo/b2kNoCollide), world-tuning passthroughs + b2kProfile, and a native b2kExplode (old behaviour kept as b2kExplodeLegacy). Tests/docs: new per-area smoke assertions (sensors, filtering, chains, motor joint, ray-cast-all, explosion, body-move events, mass data) — ctest green; api/kit/architecture references and CHANGELOG updated; ABI version bumped across all references. Intentionally not wrapped: pre-solve/custom-filter callbacks (no safe mid-step FFI callback into xTalk) and the standalone math/geometry library. Collision filter bits are exposed as 32-bit (32 layers). https://claude.ai/code/session_01NbsPt8oTFhzZJBry4GxjSR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Two related pieces of work that make the binding feature-complete, both on this branch:
edb0ffe) — the Kit (b2k…) now covers the full existing coreb2…surface (position/centre-of-mass/damping/gravity-scale getters, one-shot angular impulse, per-shape hit-test, contact polling, version check).300768f) — a review found large, useful swaths of the engine unreachable from any layer. This adds essentially the whole live-object surface: ~240 new shim functions, each with ab2…extension wrapper and, where it helps, ab2k…Kit helper. ABI bumped 2 → 3.All changes are additive — every existing handler keeps its signature.
New capabilities (layer 2)
b2…b2k…b2ShapeDefSensor/Filter/Enable*Events),b2SensorsUpdate+ accessorsb2kAddSensor,on b2kSensorEnter/Exitb2SetShapeFilter+ category/mask/group getters (32 layers)b2kDefineLayer,b2kSetCategory/Mask/CollisionGroup,b2kNoCollideb2CreateChain+ builder, materials, segmentsb2kChain,b2kSmoothGroundb2kMotorTo,b2kNoCollideb2kOverlap,b2kOverlapCircle,b2kRayHitAllb2WorldExplode, gravity getter, profile/countersb2kProfile, nativeb2kExplode(old →b2kExplodeLegacy)Design (all mechanical, five reusable shim patterns)
DEFINE_TABLE) + point builder.register_jointstamps joint handles into Box2D userData so the generic/enumeration joint features round-trip.Only
CInt/CDouble/nothingcross the FFI — no new foreign types.Verification
The C-shim side is fully tested here:
tests/smoke_test.cgains a per-area block (sensors begin/end, filtered pair does not collide, chain ground catches a box, motor joint reaches its offset, ray-cast-all returns N sorted hits, native explosion scatters bodies, body-move events report a fallen box, mass-data get/set round-trip). A cleancmake … -DBOX2DXT_BUILD_TESTS=ON && ctestis green (44/44), warning-clean. Cross-layer checks confirm all 368binds tosymbols resolve to shim exports and every Kitb2…call resolves to a public handler.The LCB/Kit side can't be run here (needs OpenXTalk / LiveCode); it was written to match the existing file's idioms exactly and verified structurally (binding resolution, handler balance). Recommend a quick IDE smoke per CONTRIBUTING (
put b2Version()→3; a sensor zone firingon b2kSensorEnter; a chain ground;b2kOverlap).Intentionally out of scope (documented)
userData; exposing setters would corrupt the round-trip.Notes for the reviewer
b2Version()now returns3; updated across code/docs/examples. The committedprebuilt/*libraries are now stale until CI rebuilds them on a release tag.double).box2d_lc.candbox2dxt.lcbare organised under matching section banners for section-by-section review.https://claude.ai/code/session_01NbsPt8oTFhzZJBry4GxjSR