NodeGraphCanvas class

Self-contained node graph canvas — state + interaction + drawing. Designed to be embedded by value (one per open document tab) in any editor window. Call DrawPalette() then DrawCanvas() each frame, or just DrawCanvas() if the palette is handled separately.

Public types

struct NodeLink
struct Pin
struct ScriptNode
enum class PinType: uint8_t { Exec, Float, Int, Bool, Vec3, Any }
enum class PinDir: uint8_t { Input, Output }
enum class NodeKind: uint8_t { Event_OnPrePhysics, Event_OnPhysicsStep, Event_OnPostPhysics, Event_OnUpdate, Event_OnSpawn, Event_OnDestroy, Sequence, Branch, GetProperty, SetProperty, Math_Add, Math_Subtract, Math_Multiply, Math_Divide, Math_Clamp, Math_Lerp, Vec3_Make, Vec3_Break, Vec3_Length, Vec3_Normalize, Vec3_Scale, GetPosition, SetPosition, GetVelocity, SetVelocity, ApplyImpulse, Const_Float, Const_Int, Const_Bool, GetDeltaTime, Compare, LogicalAnd, LogicalOr, LogicalNot, CheckAction, Math_Sqrt, Math_Abs, Math_Negate, Return_, LocalVar, FuncEntry, RawCode }

Public static functions

static auto PinTypeColor(PinType t) -> uint32_t
static auto NodeKindTitle(NodeKind k) -> const char*

Constructors, destructors, conversion operators

NodeGraphCanvas()

Public functions

void AddDefaultEventNode()
Seed the graph with a default OnUpdate event node.
void Clear()
Remove all nodes and links, reset view.
void DrawPalette(const char* uniqueID, float width, float height)
void DrawCanvas(const char* uniqueID, float canvasW, float canvasH)
void AddEventNode(NodeKind kind, float cx, float cy)
void AddFuncEntryNode(const char* displayName, float cx, float cy)
void AddActionNode(NodeKind kind, float cx, float cy)
void AddNode(ScriptNode node)
Add a pre-built node directly (used by the body parser).
void AddExecLink(int srcNodeID, int srcPinID, int dstNodeID, int dstPinID)
Wire an exec-out pin to an exec-in pin.
void AddDataLink(int srcNodeID, int srcPinID, int dstNodeID, int dstPinID)
Wire any two data pins.
auto NewID() -> int
auto FindNode(int id) -> ScriptNode*
auto FindNode(int id) const -> const ScriptNode*
auto FindPin(int nodeID, int pinID) const -> const Pin*

Public variables

std::vector<ScriptNode> Nodes
std::vector<NodeLink> Links

Function documentation

void NodeGraphCanvas::DrawPalette(const char* uniqueID, float width, float height)

Draw the node palette sidebar (category headers + clickable node buttons). width/height = the region available for the palette child window.

void NodeGraphCanvas::DrawCanvas(const char* uniqueID, float canvasW, float canvasH)

Draw the canvas background, grid, links, nodes, and handle all interaction. canvasW/canvasH = the available region for the canvas child window.