Repository navigation
physics: draw a world in a scene graph between its last two states (P6a) - #648
Merged
Merged
Conversation
world::states(ids) reads several bodies and the tick under one lock; an unknown or removed id reads as empty. cvc::physics::pose_tracker keeps the last two states of the bodies it tracks and interpolates between them at the clock's fraction of a step (position lerp, rotation along the shorter arc). follow(clock) steps the world in two parts when several steps are due, so the samples are the last two ticks; alpha() converts the clock's alpha for a world that steps every several quanta; snap() handles teleports; removed bodies drop out. cvc::gl::physics_scene_binding (cvcGL) poses bound nodes through setPoseMatrix every present(), with an optional visual offset, and hands merged-mesh groups their poses through a sink. Nodes are held weakly; destroyed nodes and removed bodies unbind. One writer per actor: dynamic bodies are drawn from physics, kinematic actors by their own source.
On a fast runner the stepping loop finished 2000 frames before the viewer thread was first scheduled, so SamplersNeverSeeHalfACapture saw no samples. Start once the viewer has sampled, and step until both sides have done real work (2000 frames and 200 samples), capped.
transfix
added a commit
that referenced
this pull request
Nov 27, 2026
… recipes The job installed wamr and binaryen from cvcpkg.org, which has wamr only at cvc.3 (with WAMR's own WASI, which takes a guest's WASI imports from the host) and no binaryen until cy-pca/cvcpkg#648 is published, so it failed at its install step. It now checks out that PR's recipes at a pinned commit and builds both with cvcpkg build, then installs python312 from the catalog. Once #648 is published the step goes back to cvcpkg install.
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.
Why
The first piece of P6a, the scene binding: how a
cvc::physicsworld shows up in the scene graph. The world steps in fixed quanta and the display runs at its own rate, so drawing each body at its newest state judders whenever the two rates beat. Nothing in the tree interpolates poses today; the nav demos draw the latest snapshot.Change
world::states(ids)reads several bodies and the tick under one lock, so a batch never mixes two steps. An unknown or removed id reads as empty instead of throwing.cvc::physics::pose_tracker(core, std-only header) keeps the last two states of the bodies it tracks.follow(clock)steps the world in two parts when several steps are due, so the two samples are the last two ticks. It replacesworld::follow; don't call both.alpha(clock, clock_alpha)converts the clock's fraction of a quantum into the world's fraction of a step, for a world that steps once every several quanta.sample_all/sample_onelerp the position and blend the rotation along the shorter arc. A body without a previous sample exactly one step back is drawn at its newest state: just tracked, after a gap, after a restore, or aftersnap()for a teleport.cvc::gl::physics_scene_binding(cvcGL) owns a tracker and writes the scene.bind(id, node, body_from_visual)sets the node's local transform throughsetPoseMatrixeverypresent(). That call is already thread-safe: latest wins, applied on the owner thread.bind_group(ids, sink)hands a merged-mesh swarm its poses once per frame, in group order.PHYSICS_API.mdcovers the one-writer-per-actor rule: dynamic bodies are drawn from physics, while kinematic actors are drawn by their own source, which also callsmove_kinematic. It also covers usingworld_binding'spull()/push()around the scene binding'sfollow, and the clock-quantum mismatch:cvc::app's clock defaults to 1/120 s and a world to 0.01 s, which throws. The roadmap gets a P6a row.Verified (Windows, MSVC Release)
physics_pose_tracker_test: 10/10 pass, including a Jolt box falling between its last two states and a 2000-frame sampler-vs-stepper tearing check.cvcgl_physics_scene_binding(headless): 6/6 pass. A bound node's transform equals the interpolated pose bit for bit; an off-threadpresent()is posted and applied atprocessEvents(); group order; removed bodies and destroyed nodes unbind; a slower world's alpha; a Jolt crate lands at its half height.physics_world_test30/30 andsystem_macro_headers_test3/3 still pass.Next in P6a
physics:/body:specs.