[Bf-blender-cvs] [8b5af7f] object_nodes: Disable explicit update calls _while_ the modal node link operator is running.

Lukas Tönne noreply at git.blender.org
Thu Dec 3 15:35:58 CET 2015


Commit: 8b5af7f3cac14fd180b80faab1abf2c03b3ce1ff
Author: Lukas Tönne
Date:   Thu Dec 3 15:33:30 2015 +0100
Branches: object_nodes
https://developer.blender.org/rB8b5af7f3cac14fd180b80faab1abf2c03b3ce1ff

Disable explicit update calls _while_ the modal node link operator is running.

These update calls can have bad consequences such as removing node sockets,
which should not happen until after the operator is finished. This was already
questionable in the past. At some point all update handling for nodes should go
through the depsgraph rather than the current fragile update flag/callback system.

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

M	release/scripts/startup/bl_operators/object_nodes.py
M	source/blender/editors/space_node/node_relationships.c

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

diff --git a/release/scripts/startup/bl_operators/object_nodes.py b/release/scripts/startup/bl_operators/object_nodes.py
index ab496a2..a03200b 100644
--- a/release/scripts/startup/bl_operators/object_nodes.py
+++ b/release/scripts/startup/bl_operators/object_nodes.py
@@ -34,11 +34,15 @@ class GeometrySocket(NodeSocket):
     bl_idname = 'GeometrySocket'
     bl_label = 'Geometry'
 
+    is_placeholder = BoolProperty(name="Is Placeholder",
+                                  default=False)
+
     def draw(self, context, layout, node, text):
         layout.label(text)
 
     def draw_color(self, context, node):
-        return (1.0, 0.4, 0.216, 1.0)
+        alpha = 0.4 if self.is_placeholder else 1.0
+        return (1.0, 0.4, 0.216, alpha)
 
 
 ###############################################################################
@@ -590,16 +594,57 @@ class GeometryMeshCombineNode(GeometryNodeBase, ObjectNode):
     bl_idname = 'GeometryMeshCombineNode'
     bl_label = 'Combine Meshes'
 
+    def add_extender(self):
+        socket = self.inputs.new('GeometrySocket', "")
+        socket.is_placeholder = True
+        return socket
+
     def init(self, context):
-        self.inputs.new('GeometrySocket', "A")
-        self.inputs.new('GeometrySocket', "B")
+        self.add_extender()
         self.outputs.new('GeometrySocket', "")
 
+    def update(self):
+        ntree = self.id_data
+        num_inputs = len(self.inputs)
+
+        # build map of connected inputs
+        input_links = dict()
+        for link in ntree.links:
+            if link.to_node == self:
+                input_links[link.to_socket] = link
+
+        # move links upward to fill gaps
+        last = 0
+        for i, socket in enumerate(self.inputs):
+            if socket not in input_links:
+                continues
+            
+            link = input_links[socket]
+            from_socket = link.from_socket
+            to_socket = self.inputs[last]
+            to_socket.is_placeholder = False
+            if i > last:
+                ntree.links.remove(link)
+                ntree.links.new(from_socket, to_socket)
+            
+            last += 1
+
+        if last >= num_inputs:
+            # add a placeholder socket if needed
+            self.add_extender()
+        else:
+            # remove empty sockets at the end
+            for i in range(last, num_inputs-1):
+                self.inputs.remove(self.inputs[i])
+            # make last socket into placeholder
+            self.inputs[-1].is_placeholder = True
+
     def compile(self, compiler):
-        node = compiler.add_node("MESH_COMBINE", self.name)
-        compiler.map_input(0, node.inputs[0])
-        compiler.map_input(1, node.inputs[1])
-        compiler.map_output(0, node.outputs[0])
+        #node = compiler.add_node("MESH_COMBINE", self.name)
+        #compiler.map_input(0, node.inputs[0])
+        #compiler.map_input(1, node.inputs[1])
+        #compiler.map_output(0, node.outputs[0])
+        pass
 
 
 class GeometryMeshArrayNode(GeometryNodeBase, ObjectNode):
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index f58cfe5..d05d52f 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -668,10 +668,6 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
 					
 					BLI_addtail(&nldrag->links, linkdata);
 					nodeRemLink(snode->edittree, link);
-					
-					/* send changed event to original link->tonode */
-					if (node)
-						snode_update(snode, node);
 				}
 			}
 		}




More information about the Bf-blender-cvs mailing list