Skip to content

fix(physics): kinematic collider support for movable platforms - #255

Merged
marco-ponds merged 2 commits into
masterfrom
fix/kinematic-platforms
Jul 3, 2026
Merged

fix(physics): kinematic collider support for movable platforms#255
marco-ponds merged 2 commits into
masterfrom
fix/kinematic-platforms

Conversation

@marco-ponds

Copy link
Copy Markdown
Collaborator

Problem

Rotating (or moving) a physics collider with mass 0 made resting objects fall through it. A mass-0 body is a Bullet static body — teleporting its transform each frame reports zero velocity to the solver, so a resting sphere loses support and tunnels through.

Changes

  • Kinematic bodies: makeKinematic + an explicit kinematic flag threaded through createRigidBody / addBox / addSphere. A kinematic body stays mass-0 but is driven by its motionState, so Bullet derives its velocity and carries contacting dynamic bodies.
  • Auto-promotion: a static body is promoted to kinematic the first time a script moves/rotates it, so existing visual-script graphs work without re-authoring.
  • CCD on dynamic bodies (sized from the collider) to stop fast bodies tunnelling through thin colliders.
  • Positional-drift fix: pin a kinematic body's origin to an authoritative kinematicPosition. Reading Bullet's extrapolated world transform back on a rotation-only update let the body's origin drift and run away — the platform slid off and exploded under non-default gravity. This was the root cause of the gravity-dependent blow-up.
  • Solver hardening: split impulse + more iterations to resist deep-penetration velocity spikes.

Tests

Adds unit tests for the kinematic flag arithmetic, CCD wiring, and auto-promotion. Full physics suite green (71 tests).

Verification

Verified in-editor via preview across multiple gravity settings (default 30, 40, 60): the platform rotates in place, carries the resting sphere, and no longer explodes.

🤖 Generated with Claude Code

Let a mass-0 collider that is moved/rotated by a script carry resting
dynamic bodies instead of letting them fall through.

- makeKinematic + an explicit `kinematic` flag threaded through
  createRigidBody / addBox / addSphere
- auto-promote a static body to kinematic the first time a script moves or
  rotates it (so existing graphs work without re-authoring)
- CCD on dynamic bodies (sized from the collider) to stop fast bodies
  tunnelling through thin colliders
- pin a kinematic body's origin to an authoritative kinematicPosition so
  rotation cannot accumulate positional drift; reading Bullet's extrapolated
  transform back was causing runaway blow-ups under non-default gravity
- harden the solver (split impulse + more iterations) against
  deep-penetration velocity spikes

Adds unit tests for the kinematic flag arithmetic, CCD wiring, and
auto-promotion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@marco-ponds
marco-ponds marked this pull request as ready for review July 3, 2026 15:37
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@marco-ponds
marco-ponds merged commit 02c67b7 into master Jul 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant