diff --git a/apps/shaders_lab/shaders_lab.exe b/apps/shaders_lab/shaders_lab.exe index 475f3557..f3e82dd3 100755 Binary files a/apps/shaders_lab/shaders_lab.exe and b/apps/shaders_lab/shaders_lab.exe differ diff --git a/cpp/functions/gfx/dag_node_editor.cpp b/cpp/functions/gfx/dag_node_editor.cpp index cf5a09ce..c57df7d7 100644 --- a/cpp/functions/gfx/dag_node_editor.cpp +++ b/cpp/functions/gfx/dag_node_editor.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include namespace ed = ax::NodeEditor; @@ -15,8 +16,9 @@ namespace fn::gfx { static constexpr int MAX_NODES = 16; -static ed::EditorContext* s_ctx = nullptr; -static uint32_t s_next_uid = 1; +static ed::EditorContext* s_ctx = nullptr; +static uint32_t s_next_uid = 1; +static std::unordered_set s_positioned; // ── ID encoding ────────────────────────────────────────────────────────────── // node id = editor_uid @@ -213,6 +215,18 @@ bool dag_node_editor(std::vector& pipeline) { ImVec4 col = kind_color(def->kind); + // Initial position only — after that, the editor owns the node's position + // and user drags must not be overwritten. + if (s_positioned.find(step.editor_uid) == s_positioned.end()) { + if (step.editor_pos_x == 0.0f && step.editor_pos_y == 0.0f) { + step.editor_pos_x = 50.0f + static_cast(i) * 220.0f; + step.editor_pos_y = 100.0f; + } + ed::SetNodePosition(ed::NodeId(node_id(step.editor_uid)), + ImVec2(step.editor_pos_x, step.editor_pos_y)); + s_positioned.insert(step.editor_uid); + } + ed::BeginNode(ed::NodeId(node_id(step.editor_uid))); // Header @@ -272,14 +286,6 @@ bool dag_node_editor(std::vector& pipeline) { ed::EndPin(); ed::EndNode(); - - // Set initial position if not yet placed (both zero = first time) - if (step.editor_pos_x == 0.0f && step.editor_pos_y == 0.0f) { - step.editor_pos_x = 50.0f + static_cast(i) * 220.0f; - step.editor_pos_y = 100.0f; - } - ed::SetNodePosition(ed::NodeId(node_id(step.editor_uid)), - ImVec2(step.editor_pos_x, step.editor_pos_y)); } // ── Draw existing links ──────────────────────────────────────────────────