Skip to main content

Module hierarchy

Module hierarchy 

Source
Expand description

Hierarchical scene-graph composition for items. Hierarchical scene-graph composition for items.

This module lifts Transformed’s “canonical local data + external transform” model from a flat wrapper to a tree. Scene-graph composition lives in the items layer, built on top of ranim-core’s transform-group algebra (TransformGroup): each node stores canonical local data (like Transformed::inner does) plus one transform from its local space into the parent’s space.

The structural rules of the model:

  • Extraction flattens depth-first and composes matrices per node, acc = acc * node_transform, so the resulting CoreItem sequence preserves painter’s-algorithm draw order (front-to-back document order).
  • Every node’s pose interpolates independently of its geometry: lerping moves transforms and leaf payloads only and never bakes points into vertices — the basis for future skeletal animation.

§Examples

use ranim_core::core_item::transformed::{Transformed, TransformedExt};
use ranim_core::core_item::vitem::VItem as CoreVItem;
use ranim_core::glam::{DAffine3, Vec4, dvec3};
use ranim_core::traits::ShiftTransform;
use ranim_core::Extract;
use ranim_items::hierarchy::Node;

let stroke = CoreVItem {
    points: vec![Vec4::new(1.0, 0.0, 0.0, 0.0)],
    ..Default::default()
};
// A tree is placed by wrapping it — root posing is O(1) and never
// bakes points.
let mut tree = Transformed::new(
    Node::<CoreVItem>::group(vec![
        Node::leaf(stroke.clone()).with_id("a"),
        Node::leaf(stroke).with_id("b"),
    ]),
    DAffine3::IDENTITY,
);
tree.shift(dvec3(1.0, 0.0, 0.0));

let extracted = tree.extract();
assert_eq!(extracted.len(), 2);

Structs§

Leaves
Iterator over flattened leaf payloads with accumulated world affines, produced by Node::leaves.
LeavesMut
Iterator over mutable references to leaf payloads, produced by Node::leaves_mut. Depth-first order; no transforms are composed.
Node
A node of a scene-graph tree: pure structure — an external id, an optional payload, and a list of placed children.

Traits§

PlacedLeaves
Leaf iteration for a placed tree: the wrapper’s pose seeds the accumulation. A bare Node iterates from the identity via Node::leaves.

Functions§

expand_with_transparent_repeats 🔒
Expand nodes in place to len entries, preserving order; repeated stand-ins become fully transparent via set_opacity(0.0), matching the Vec<T> align blanket in ranim-core.
lerp_items 🔒
Structural lerp over payloads. None must pair with None: a presence mismatch is filled with transparent clones by Alignable first.
transparent_clones 🔒
Grow source to len entries by cloning entries and marking every clone transparent — the absence rule of Alignable::align_with for child lists that have nothing of their own to repeat.