Skip to content

Expose btCollisionObject interpolation transform and velocity accessors#446

Merged
kripken merged 1 commit into
kripken:mainfrom
willeastcott:interpolation-accessors
Jun 16, 2026
Merged

Expose btCollisionObject interpolation transform and velocity accessors#446
kripken merged 1 commit into
kripken:mainfrom
willeastcott:interpolation-accessors

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Binds the six public btCollisionObject interpolation methods, which currently have no WebIDL bindings:

  • get/setInterpolationWorldTransform
  • set/getInterpolationLinearVelocity
  • set/getInterpolationAngularVelocity

They're declared on btCollisionObject, so via the existing implements they're also available on btRigidBody, btGhostObject, and btSoftBody.

Why: after setting a body's world transform directly (e.g. a teleport), Bullet's synchronizeMotionStates() still extrapolates the motion state from the interpolation transform, which setWorldTransform doesn't update. With these bound, a caller can reset the interpolation transform/velocities too, so motion-state read-back is correct even on frames that run zero fixed substeps. (Fixes the high-refresh teleport issue in PlayCanvas — playcanvas/engine#4277, playcanvas/engine#7822.)

builds/* rebuilt with emsdk 3.1.35. Adds tests/interpolation.js, which round-trips all six on a btRigidBody.

@willeastcott

Copy link
Copy Markdown
Contributor Author

The failing CI here isn't caused by this change. continuous.yml fails at the mymindstorm/setup-emsdk@v8 step — emsdk install latest errors with No tool or SDK found by name 'sdk-releases-upstream-…-64bit'before the build runs, so it currently fails on any PR.

I built and tested this change on a pinned emsdk 3.1.35 (the toolchain the committed builds/* were produced with): clean build, and the new tests/interpolation.js round-trips all six accessors on both the asm.js and wasm outputs.

I'll open a separate PR to repair the CI setup (pin emsdk so latest can't rot again); this bindings change is independent of it.

Binds the six public btCollisionObject interpolation methods (world transform
+ linear/angular velocity get/set), available on btRigidBody and the other
btCollisionObject subtypes via `implements`. Lets callers reset Bullet's
interpolation state after setting a body's transform directly, so motion-state
read-back is correct on frames that run zero fixed substeps.

Adds tests/interpolation.js and rebuilds builds/* (emsdk 3.1.35).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@willeastcott willeastcott force-pushed the interpolation-accessors branch from 1870eab to 75bb530 Compare June 16, 2026 18:46
@kripken kripken merged commit 0f92865 into kripken:main Jun 16, 2026
3 checks passed
willeastcott added a commit to playcanvas/engine that referenced this pull request Jun 17, 2026
… rates (#8915)

* fix(physics): keep interpolation in sync on teleport for high refresh rates

A dynamic body's teleport (syncEntityToBody) only set its world transform. On frames
that run zero fixed sub-steps (dt < fixedTimeStep, e.g. high refresh-rate displays),
Bullet fills the motion state by extrapolating from the stale interpolation transform,
so the entity read back its pre-teleport pose (#4277, #7822).

Reset the interpolation transform and linear/angular velocity for dynamic bodies,
feature-detected so older ammo builds (lacking the bindings) no-op. Bundled ammo
updated to the build exposing the btCollisionObject interpolation accessors
(kripken/ammo.js#446).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(physics): zero interpolation velocities so teleport read-back is exact

Per review: copying the body's velocity into the interpolation state left the
read-back within velocity*fixedTimeStep of the target (Bullet extrapolates from
the interpolation transform by the leftover sub-step fraction). Zeroing the
interpolation velocities makes getPosition() return exactly the teleport target
on every frame, including for a moving body.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants