Skip to content

Node instances are never created or tracked, so parameter state has nowhere to live #438

Description

@matt-edmondson

A node created by AttributeBasedNodeFactory has no instance behind it and no value storage, so there is nowhere for a parameter like Threshold or Sigma to live. Raised while investigating #437.

What happens

AttributeBasedNodeFactory.CreateNode<T> reads the NodeDefinition, extracts the pin display names, and calls engine.CreateNode(position, name, inputPinNames, outputPinNames). Everything else the definition knows is dropped at that boundary. The factory never calls Activator.CreateInstance, so no T is ever constructed.

The runtime types have nowhere to put a value even if one existed. Node (ImGui.NodeEditor/DomainModels.cs:11) is id, position, name, pins, dimensions, velocity, force and pinned state. Pin (DomainModels.cs:43) is id, direction, name, display name and connection capacity. Neither carries an instance, a payload or a user-data slot.

The factory also keeps no map from a node id back to the definition it came from, so nothing in the library can answer "which type is this selected node" on a host's behalf.

Verified

Against a type declaring [InputPin] public double Threshold { get; set; } = 128.0;:

Pin members carrying a value: 0
Node members carrying an instance/payload: 0
Factory can map a node id back to its definition: False
Anything in the engine that instantiates or executes a node type: 0

Why it matters

The shipped node library in NodeGraph/Library declares every tunable as an [InputPin] with a C# initializer for its default: RandomNode.Min, RandomNode.Max, TimerNode.StartTime. That is a clear statement of intent about where parameter state belongs. None of it survives node creation, so a host that wants an editable Threshold has to keep its own parallel dictionary of instances keyed by node id, and re-derive the mapping the factory already had.

There is a usable half of this today: PinDefinition.GetValue(object) and SetValue(object, object?) (NodeDefinition.cs:263 and :278) read and write the member on an instance, and they work. What is missing is the instance itself and anything that knows which node it belongs to.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions