Drag-to-create-and-connect nodes; double-click to rename materials
Drag a link off a pin onto empty canvas to open a create-node menu at the drop point (the editor's QueryNewNode path), filtered to nodes with a type-connectable pin; the chosen node is created and auto-wired to the source pin. Direction is handled both ways — drag from an output makes a downstream consumer, from an input an upstream producer. Type matching is lenient (exact, or same scalar/2-/3-/4-vector class), mirroring what USD/ MaterialX networks already tolerate; the target pin is the first exact match else the first connectable. RenderNodeSearchMenu gained an optional linkSource arg so the TAB popup and this share one implementation, and CreateShaderNode now returns the created path. Create and connect are two undo steps. Materials list: double-click a row starts an inline rename (mirrors SceneHierarchyPanel — Enter commits, focus-loss/Esc cancels) through RenamePrimCommand, which fixes up bindings/arcs via UsdNamespaceEditor. Selection and the open graph follow the rename. This repurposes the row's double-click, which previously opened the graph; opening stays on the Show Graph button. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -60,7 +60,7 @@ private:
|
||||
struct PinInfo {
|
||||
pxr::SdfPath nodePath;
|
||||
std::string name;
|
||||
bool isOutput;
|
||||
bool isOutput = false;
|
||||
pxr::SdfValueTypeName typeName;
|
||||
};
|
||||
/// Resolved endpoint of a rendered link, keyed by its ax::NodeEditor LinkId.
|
||||
@@ -92,9 +92,13 @@ private:
|
||||
void RenderPreviewPanel();
|
||||
void HandleCreateAndDelete();
|
||||
/// Nuke-style TAB popup: type-to-filter shader node list; Enter or click
|
||||
/// creates the highlighted node at canvasPos.
|
||||
void RenderNodeSearchMenu(const ImVec2& canvasPos);
|
||||
void CreateShaderNode(const std::string& shaderId, const ImVec2& canvasPos);
|
||||
/// creates the highlighted node at canvasPos. When linkSource is non-null
|
||||
/// (a connection was dragged onto empty canvas), the list is filtered to
|
||||
/// nodes with a type-connectable pin and the chosen node is auto-wired to
|
||||
/// linkSource.
|
||||
void RenderNodeSearchMenu(const ImVec2& canvasPos, const PinInfo* linkSource = nullptr);
|
||||
/// Creates the node and returns its prim path (empty on failure).
|
||||
pxr::SdfPath CreateShaderNode(const std::string& shaderId, const ImVec2& canvasPos);
|
||||
/// Nudges a creation point right until the new node's estimated rectangle
|
||||
/// clears every existing node's rendered rectangle. Overlapping nodes
|
||||
/// fight over the editor's hit test: the buried one becomes unmovable and
|
||||
@@ -152,6 +156,13 @@ private:
|
||||
char m_nodeSearchBuf[128] = "";
|
||||
int m_nodeSearchSelected = 0;
|
||||
|
||||
/// Nuke-style drag-to-create: set when a connection was dragged from a pin
|
||||
/// onto empty canvas. m_openLinkDragMenu requests the create-node popup on
|
||||
/// the next frame (deferred so OpenPopup runs while the editor is
|
||||
/// suspended); m_linkDragSourcePin is the pin to auto-wire the new node to.
|
||||
bool m_openLinkDragMenu = false;
|
||||
PinInfo m_linkDragSourcePin;
|
||||
|
||||
/// Column widths of the browser (left) and preview (right) sections,
|
||||
/// user-adjustable via the splitters between them and the canvas.
|
||||
float m_browserWidth = 220.0f;
|
||||
@@ -162,6 +173,13 @@ private:
|
||||
/// splitter between them.
|
||||
float m_browserListRatio = 0.45f;
|
||||
|
||||
/// Inline-rename state for the materials list (double-click a row to start;
|
||||
/// mirrors SceneHierarchyPanel): the material being renamed (empty = none),
|
||||
/// the edit buffer, and a one-frame flag to focus the InputText on start.
|
||||
pxr::SdfPath m_renamingMaterial;
|
||||
char m_materialRenameBuf[128] = "";
|
||||
bool m_materialRenameJustStarted = false;
|
||||
|
||||
/// Search text of the browser's persistent create-node list.
|
||||
char m_browserNodeSearchBuf[128] = "";
|
||||
/// Shader id clicked in the browser's create-node list; created at the
|
||||
|
||||
Reference in New Issue
Block a user