Skip to content

Scene nodes scale along their own axes (T·R·S); ARIADNE.md documents a node's transform - #1486

Merged
transfix merged 2 commits into
masterfrom
scene/transform-trs
Nov 23, 2026
Merged

transfix merged 2 commits into
masterfrom
scene/transform-trs

Conversation

@transfix

Copy link
Copy Markdown
Owner

A scene node's transform: now composes as T·Rz·Ry·Rx·S: a point is scaled along the node's own axes, turned, then moved. That is how glTF, USD and X3D compose a node, and how Ariadne already composed everything except the drawn node. ARIADNE.md now documents the transform, including the rotation order, which was never written down.

What was wrong

  • The drawn node was the odd one out. GraphicsNode::setScale scaled each row of the rotation (T·S·R): a non-uniform scale on a turned node stretched along the parent's axes. Three other places already assumed T·R·S:

    • a view entry's transform: (scene_views.cpp, vtkTransform's Translate, RotateZ/Y/X, Scale);
    • the physics world's decompose (scene_world.cpp), which divides out column lengths and calls non-orthogonal columns skew;
    • conference statics in holon_sync.cpp, which scale a box along its own axes and then turn it.

    So a turned box with scale: [4, 1, 0.5] was drawn one shape and collided as another. The physics world also warned that its transform was skewed.

  • Writing rotation dropped the scale. setRotation and the rotation key handler copied a pure rotation over the matrix and kept only the translation. setScale recovered the rotation by normalising rows, which loses it at a scale of 0 and loses which axis a negative scale was on.

No shipped .ari document uses rotation: (0 of 184), and every non-uniform setScale call outside tests is the realizer's, so nothing shipped changes how it looks.

What changes

  • GraphicsNode keeps the rotation and scale it was last given, and builds the upper 3x3 as Rz·Ry·Rx·S through vtkTransform, as scene_views.cpp does. setRotation keeps the scale, a scale of 0 or below 0 included; setScale keeps the rotation. The rotation and scale key handlers call the same code instead of their own copies.

  • After a whole matrix (setTransform, setPoseMatrix, the matrix key) the parts are marked stale. The next setRotation or setScale reads them back from the matrix first: each column's length is the scale, the last made negative when the matrix mirrors, and what is left is the rotation, read back as Rz·Ry·Rx (with the pitched-straight-up case handled). The per-frame pose path does no extra work.

  • scene_node_local_matrix scales columns instead of rows, so the physics world builds a turned, non-uniformly scaled node as a plain rigid body.

  • Docs: ARIADNE.md §5.4 gets a "Transforms" paragraph covering:

    • position, rotation (degrees about the parent's x, then y, then z: R = Rz Ry Rx, the same order as a vehicle pose's heading/pitch/roll, with its sign) and scale;
    • the runtime position, rotation, scale and matrix keys, and how each keeps the others.

    The §5.18 view-entry text now says it composes the same way.

Tests

  • ariadne_scene_world_test:
    • LocalMatrixIsRotationThenRowScaleThenPosition becomes LocalMatrixIsScaleThenRotationThenPosition;
    • new LocalMatrixTurnsAboutXThenYThenZ;
    • new ATurnedNodesScaleIsAlongItsOwnAxes: a box turned 30 degrees with scale: [4, 1, 0.5] is a rigid body with half extents (2, 0.5, 0.25), turned 30 degrees, and no skew warning.
  • New cvcgl_node_transform, headless:
    • the node's matrix equals scene_node_local_matrix and the view entry's vtkTransform build, for four rotation/scale cases, in either call order, and through realize_scene;
    • a rotation keeps the scale (0 and a mirror included), and a scale keeps the rotation;
    • after setTransform, setPoseMatrix or a matrix key write, a rotation keeps the matrix's scale and a scale keeps its rotation, pitched straight up and mirrored included;
    • the rotation and scale keys do what the setters do;
    • resetTransform starts both over.

With the old GraphicsNode.cpp and scene_geometry.cpp put back, cvcgl_node_transform fails 18 checks, and LocalMatrixIsScaleThenRotationThenPosition and ATurnedNodesScaleIsAlongItsOwnAxes (the skew warning) fail. The rotation-order test passes either way, because that order didn't change.

Verified locally

Windows, MSVC, with cvcGL (no examples, no pycvc), on 484ba6f: the full ctest suite, 8,349 tests.

  • Pass: everything except the four below, including the new and changed tests above, cvcgl_clip_planes (non-uniform scales on turned nodes), cvcgl_pose_matrix, cvcgl_ariadne_realize and cvcgl_ariadne_physics.
  • AriadneFrames.AR03b_ProvidersPostToTheirGroup: failed once under -j 12 and passed when run alone.
  • cvcgl_contour_lab and cvcgl_volume_grid_contours: this build has no cvc::planar (Clipper2/CDT).
  • cvcgl_ari_golden: seven goldens differ on this machine (Intel Arc GPU, no mesh_lab and no cvc::planar). I rebuilt with the old transform code and reran: the same seven goldens fail, with the same pixel counts.

Not verified locally: Linux, macOS, wasm and pycvc.

Not done

  • Quaternion and axis-angle keys. Nothing needs them yet: a node's matrix key already takes an exact orientation, and keyframe interpolation can work on quaternions internally whatever form the keys are written in.

A node's rotation is degrees about the parent's x, then y, then z
(R = Rz Ry Rx), as scene_geometry, GraphicsNode and the view entries
build it. Its scale applies along the parent's axes after the rotation
(position + S R p), unlike a view entry's (position + R S p). At run
time the pose is in position, rotation, scale and matrix (16 numbers,
row-major); writing rotation sets the scale back to 1.
GraphicsNode::setScale scaled each row of the rotation (T S R), so a
non-uniform scale on a turned node stretched along the parent's axes,
while a view entry's transform:, the physics world's decompose and the
conference statics all compose T R S: a turned, scaled box was drawn as
one shape and collided as another, and physics warned it was skewed.
Writing rotation also dropped the scale.

GraphicsNode now keeps the rotation and scale it was last given and
builds Rz Ry Rx S from them, so each keeps the other (a scale of 0 or
below 0 included). After a whole matrix (setTransform, setPoseMatrix,
the matrix key) they are read back from it on the next setRotation or
setScale: column lengths as the scale, the last negative when it
mirrors. scene_node_local_matrix scales columns to match. ARIADNE.md's
Transforms paragraph says so.

cvcgl_node_transform pins the matrix against scene_node_local_matrix,
the view entry's build and realize_scene, and the keeping; the scene
world tests pin the order and a turned, scaled body without skew.
@transfix
transfix enabled auto-merge (squash) November 23, 2026 06:47
@transfix
transfix merged commit d4e2967 into master Nov 23, 2026
31 checks passed
@transfix
transfix deleted the scene/transform-trs branch November 23, 2026 15:39
transfix added a commit that referenced this pull request Nov 23, 2026
… into p9/volume-grid-segment

INDEX.ari keeps both new entries (volume_grid_segmentation, http_cache).
volume_grid_contours.png conflicted (#1450 re-rendered it for rows that
flow); kept ours until CI renders the merged panel.
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