Fix Auto-offset for nodes: Revert "Cleanup: Return early"
This "cleanup" commit broke Auto-offset for nodes.
This reverts commit e3ef6a6660.
This commit is contained in:
@@ -1727,35 +1727,34 @@ static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
|
|||||||
SpaceNode &snode = *CTX_wm_space_node(C);
|
SpaceNode &snode = *CTX_wm_space_node(C);
|
||||||
bNodeTree &ntree = *snode.edittree;
|
bNodeTree &ntree = *snode.edittree;
|
||||||
bNode *frame = node_find_frame_to_attach(region, ntree, event->mval);
|
bNode *frame = node_find_frame_to_attach(region, ntree, event->mval);
|
||||||
if (frame == nullptr) {
|
|
||||||
return OPERATOR_CANCELLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree.nodes) {
|
if (frame) {
|
||||||
if (node->flag & NODE_SELECT) {
|
LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree.nodes) {
|
||||||
if (node->parent == nullptr) {
|
if (node->flag & NODE_SELECT) {
|
||||||
/* disallow moving a parent into its child */
|
if (node->parent == nullptr) {
|
||||||
if (nodeAttachNodeCheck(frame, node) == false) {
|
|
||||||
/* attach all unparented nodes */
|
|
||||||
nodeAttachNode(node, frame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* attach nodes which share parent with the frame */
|
|
||||||
bNode *parent;
|
|
||||||
for (parent = frame->parent; parent; parent = parent->parent) {
|
|
||||||
if (parent == node->parent) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent) {
|
|
||||||
/* disallow moving a parent into its child */
|
/* disallow moving a parent into its child */
|
||||||
if (nodeAttachNodeCheck(frame, node) == false) {
|
if (nodeAttachNodeCheck(frame, node) == false) {
|
||||||
nodeDetachNode(node);
|
/* attach all unparented nodes */
|
||||||
nodeAttachNode(node, frame);
|
nodeAttachNode(node, frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* attach nodes which share parent with the frame */
|
||||||
|
bNode *parent;
|
||||||
|
for (parent = frame->parent; parent; parent = parent->parent) {
|
||||||
|
if (parent == node->parent) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent) {
|
||||||
|
/* disallow moving a parent into its child */
|
||||||
|
if (nodeAttachNodeCheck(frame, node) == false) {
|
||||||
|
nodeDetachNode(node);
|
||||||
|
nodeAttachNode(node, frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "BLI_lasso_2d.h"
|
#include "BLI_lasso_2d.h"
|
||||||
#include "BLI_listbase.h"
|
#include "BLI_listbase.h"
|
||||||
#include "BLI_rect.h"
|
#include "BLI_rect.h"
|
||||||
#include "BLI_set.hh"
|
|
||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
#include "BLI_string_search.h"
|
#include "BLI_string_search.h"
|
||||||
#include "BLI_string_utf8.h"
|
#include "BLI_string_utf8.h"
|
||||||
@@ -645,29 +644,28 @@ static bool node_mouse_select(bContext *C,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(changed || found)) {
|
/* update node order */
|
||||||
return false;
|
if (changed || found) {
|
||||||
|
bool active_texture_changed = false;
|
||||||
|
bool viewer_node_changed = false;
|
||||||
|
if ((node != nullptr) && (node_was_selected == false || params->select_passthrough == false)) {
|
||||||
|
viewer_node_changed = (node->flag & NODE_DO_OUTPUT) == 0 && node->type == GEO_NODE_VIEWER;
|
||||||
|
ED_node_set_active(&bmain, &snode, snode.edittree, node, &active_texture_changed);
|
||||||
|
}
|
||||||
|
else if (node != nullptr && node->type == GEO_NODE_VIEWER) {
|
||||||
|
ED_spreadsheet_context_paths_set_geometry_node(&bmain, &snode, node);
|
||||||
|
}
|
||||||
|
ED_node_set_active_viewer_key(&snode);
|
||||||
|
node_sort(*snode.edittree);
|
||||||
|
if ((active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) ||
|
||||||
|
viewer_node_changed) {
|
||||||
|
DEG_id_tag_update(&snode.edittree->id, ID_RECALC_COPY_ON_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool active_texture_changed = false;
|
return changed || found;
|
||||||
bool viewer_node_changed = false;
|
|
||||||
if ((node != nullptr) && (node_was_selected == false || params->select_passthrough == false)) {
|
|
||||||
viewer_node_changed = (node->flag & NODE_DO_OUTPUT) == 0 && node->type == GEO_NODE_VIEWER;
|
|
||||||
ED_node_set_active(&bmain, &snode, snode.edittree, node, &active_texture_changed);
|
|
||||||
}
|
|
||||||
else if (node != nullptr && node->type == GEO_NODE_VIEWER) {
|
|
||||||
ED_spreadsheet_context_paths_set_geometry_node(&bmain, &snode, node);
|
|
||||||
}
|
|
||||||
ED_node_set_active_viewer_key(&snode);
|
|
||||||
node_sort(*snode.edittree);
|
|
||||||
if ((active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) ||
|
|
||||||
viewer_node_changed) {
|
|
||||||
DEG_id_tag_update(&snode.edittree->id, ID_RECALC_COPY_ON_WRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int node_select_exec(bContext *C, wmOperator *op)
|
static int node_select_exec(bContext *C, wmOperator *op)
|
||||||
|
|||||||
Reference in New Issue
Block a user