[Bf-blender-cvs] [df40440d223] master: Cleanup: Avoid using node socket location

Hans Goudey noreply at git.blender.org
Sat Sep 3 01:01:59 CEST 2022


Commit: df40440d22390a86c59e0e9fcc0db5dcfaa8cc11
Author: Hans Goudey
Date:   Fri Sep 2 16:43:12 2022 -0500
Branches: master
https://developer.blender.org/rBdf40440d22390a86c59e0e9fcc0db5dcfaa8cc11

Cleanup: Avoid using node socket location

The location of a reroute node and its sockets should be the same,
only stored in different coordinate spaces. Because the node's location
is the ground truth, use that for finding whether the mouse is hovering.

===================================================================

M	source/blender/editors/space_node/node_select.cc

===================================================================

diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc
index 29a809b8053..8cc3c80fdfd 100644
--- a/source/blender/editors/space_node/node_select.cc
+++ b/source/blender/editors/space_node/node_select.cc
@@ -141,14 +141,11 @@ static bNode *node_under_mouse_select(bNodeTree &ntree, const float2 mouse)
 
 static bool node_under_mouse_tweak(const bNodeTree &ntree, const float2 &mouse)
 {
-  using namespace blender::math;
-
   LISTBASE_FOREACH_BACKWARD (const bNode *, node, &ntree.nodes) {
     switch (node->type) {
       case NODE_REROUTE: {
-        bNodeSocket *socket = (bNodeSocket *)node->inputs.first;
-        const float2 location{socket->locx, socket->locy};
-        if (distance(mouse, location) < 24.0f) {
+        const float2 location = node_to_view(*node, {node->locx, node->locy});
+        if (math::distance(mouse, location) < 24.0f) {
           return true;
         }
         break;



More information about the Bf-blender-cvs mailing list