Repository navigation
gl: physics bodies are drawn at their pose anywhere in the scene hierarchy - #654
Merged
Merged
Conversation
…archy physics_scene_binding wrote each body's world pose into its node's LOCAL transform, so a node under a transformed parent was drawn at parent x pose, not where physics had it. GraphicsNode::setWorldPoseMatrix(pose, frame) puts the node's WORLD matrix at frame-world x pose (the scene root without a frame). The local transform that achieves it is composed on the owner thread when the pose is applied, against the hierarchy as it is then; it shares setPoseMatrix's thread-safe, latest-wins mailbox. GraphicsNode gains getParentNode(). physics_scene_binding::set_frame(node) names the node standing for the physics world (a render origin, a scale); present() poses through setWorldPoseMatrix, so bodies follow the frame and their nodes may sit at any depth. A frame held weakly and destroyed poses nothing.
This was referenced Oct 17, 2026
Merged
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
Joe asked whether the renderer still respects local transforms and the node hierarchy. It does:
GraphicsNodecaches world = parent world × local;The one place that didn't respect the hierarchy was mine.
physics_scene_binding(#648) wrote each body's world pose into its node's local transform, so a node under a transformed parent was drawn at parent × pose, not where physics had it.Change
GraphicsNode::setWorldPoseMatrix(pose, frame = nullptr)puts the node's world matrix at frame-world × pose, with no frame meaning the scene root.setPoseMatrix's thread-safe, latest-wins, change-detected mailbox; the mailbox now records whether a parked pose is local or world, and its frame.GraphicsNode::getParentNode()(owner thread).physics_scene_binding::set_frame(node)names the node that stands for the physics world: a render-origin offset that keeps city-scale coordinates out of float precision, or a scale.present()now poses throughsetWorldPoseMatrix, so bodies follow the frame, and their nodes may sit at any depth. While a frame is set but destroyed, nothing is posed.Verified (Windows, MSVC Release)
cvcgl_physics_scene_bindingpasses, with two new checks:test_nodes_anywhere_in_the_hierarchy_are_drawn_at_the_body: a node two levels under rotated and translated parents has world matrix = body pose (1e-9). The same holds whenpresent()runs off the owner thread and the group moves before the pump.test_a_frame_node_places_the_physics_world: under a frame translated 1000 m, child and top-level nodes are drawn at frame × pose, and a child's local transform is the plain pose. A destroyed frame poses nothing.cvcgl_pose_matrix(the mailbox's own suite) still passes.Next
gl::add_world_geometry(G3a, in flight) gets aparentargument in G4, so the static world and the bodies can share one frame node.