Skip to main content

Module sdf_node_editor

Module sdf_node_editor 

Source
Expand description

SDF Node Editor — visual node graph for constructing signed-distance-field bodies.

§Architecture

The node graph owns a directed acyclic graph of SdfNode values. Each node is either a primitive (Sphere, Capsule, Box, Ellipsoid, Torus, Cylinder, Cone, Plane) or a combinator (SmoothUnion, SmoothSubtract, SmoothIntersect, Union, Subtract, Intersect, Blend, Twist, Bend, Elongate, Onion, Extrude, Revolve, Displace). Primitives carry transform + shape parameters; combinators carry a smoothness radius k and two input slots.

The graph is evaluated bottom-up: every terminal primitive evaluates to a closed-form SDF; every combinator merges its two children. The root node yields the final body SDF.

§Real-time feedback

NodeGraph::evaluate_at samples the compiled SDF tree at an arbitrary 3-D point for viewport preview. NodeGraph::compile_glsl emits a GLSL function body ready to be injected into the rendering shader.

§Node positions

Each node carries a canvas_pos: Vec2 that records where it sits in the 2-D node-graph canvas. The layout engine auto-arranges new nodes, but the user can drag them freely; positions are serialised with the graph.

Structs§

Connection
A directed edge: output of from feeds input port of to.
NodeClipboard
Clipboard entry for copy/paste in the node graph.
NodeGraph
The full SDF node graph owned by the editor.
NodeGraphStats
Summary statistics about a compiled node graph.
NodeId
Opaque handle to a node in the graph.
NodeSelection
Selection state for the canvas.
NodeTransform
World-space transform applied to a node before SDF evaluation.
PortId
Input port index (0 = left child, 1 = right child for combinators).
SdfNode
A single node in the SDF graph.
SdfNodeEditor
Full SDF node editor — owns the graph, selection, clipboard, undo stack.

Enums§

CombinatorKind
Boolean / blending operations between two SDF sub-trees.
NodeEdit
A single undo entry in the node editor.
NodePayload
The inner data of a node — either a primitive or a combinator.
PrimitiveKind
Supported SDF primitive shapes.