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
fromfeeds inputportofto. - Node
Clipboard - Clipboard entry for copy/paste in the node graph.
- Node
Graph - The full SDF node graph owned by the editor.
- Node
Graph Stats - Summary statistics about a compiled node graph.
- NodeId
- Opaque handle to a node in the graph.
- Node
Selection - Selection state for the canvas.
- Node
Transform - 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.
- SdfNode
Editor - Full SDF node editor — owns the graph, selection, clipboard, undo stack.
Enums§
- Combinator
Kind - Boolean / blending operations between two SDF sub-trees.
- Node
Edit - A single undo entry in the node editor.
- Node
Payload - The inner data of a node — either a primitive or a combinator.
- Primitive
Kind - Supported SDF primitive shapes.