Bladeren bron

Update Version & Fix Node Group Update

Adds versioning for previous patch and updates version number
Fixes problem in Node Group update when sockets have been removed from
  previous/next node. Now it is forced to update properly.
Joseph Brandenburg 8 maanden geleden
bovenliggende
commit
7e6f482804
4 gewijzigde bestanden met toevoegingen van 34 en 14 verwijderingen
  1. 9 2
      __init__.py
  2. 22 11
      base_definitions.py
  3. 1 1
      blender_manifest.toml
  4. 2 0
      ops_nodegroup.py

+ 9 - 2
__init__.py

@@ -17,7 +17,7 @@ from .utilities import prRed
 
 MANTIS_VERSION_MAJOR=0
 MANTIS_VERSION_MINOR=9
-MANTIS_VERSION_SUB=4
+MANTIS_VERSION_SUB=7
 
 
 classLists = [module.TellClasses() for module in [
@@ -238,7 +238,7 @@ def execute_handler(scene):
 
 @persistent
 def version_update_handler(filename):
-    from .base_definitions import NODES_REMOVED, SOCKETS_REMOVED
+    from .base_definitions import NODES_REMOVED, SOCKETS_REMOVED, SOCKETS_RENAMED, SOCKETS_ADDED
     for node_tree in bpy.data.node_groups:
         if node_tree.bl_idname in ["MantisTree", "SchemaTree"]:
             if (node_tree.mantis_version[0] < MANTIS_VERSION_MAJOR) or \
@@ -261,6 +261,13 @@ def version_update_handler(filename):
                         if (n.bl_idname, socket.identifier) in SOCKETS_REMOVED:
                             print(f"INFO: removing socket {socket.identifier} of node {n.name} of type {n.bl_idname} because it has been deprecated.")
                             n.outputs.remove(socket)
+                    for bl_idname, in_out, socket_type, socket_name, index in SOCKETS_ADDED:
+                        if n.bl_idname != bl_idname:
+                            continue
+                        if in_out == 'INPUT' and n.inputs.get(socket_name) is None:
+                            print(f"INFO: adding socket \"{socket_name}\" of type {socket_type} to node {n.name} of type {n.bl_idname}.")
+                            s = n.inputs.new(socket_type, socket_name)
+                            # n.inputs.move(len(n.inputs), index)
                 
                 
 

+ 22 - 11
base_definitions.py

@@ -286,11 +286,16 @@ class MantisNodeGroup(Node, MantisNode):
     is_updating:BoolProperty(default=False)
     
     def update(self):
+        live_update = self.id_data.do_live_update
         if self.is_updating: # update() can be called from update() and that leads to an infinite loop.
             return           # so we check if an update is currently running.
-        self.is_updating = True
-        node_group_update(self)
-        self.is_updating = False
+        try:
+            self.is_updating = True
+            node_group_update(self)
+            self.is_updating = False
+        finally: # we need to reset this regardless of whether or not the operation succeeds!
+            self.is_updating = False
+            self.id_data.do_live_update = live_update # ensure this remains the same
 
     def draw_buttons(self, context, layout):
         row = layout.row(align=True)
@@ -328,17 +333,21 @@ class SchemaGroup(Node, MantisNode):
         row.operator("mantis.edit_group", text="", icon='NODETREE', emboss=True)
 
     def update(self):
+        live_update = self.id_data.do_live_update
         if self.is_updating: # update() can be called from update() and that leads to an infinite loop.
             return           # so we check if an update is currently running.
         self.is_updating = True
-        node_group_update(self)
-        # reset things if necessary:
-        if self.node_tree:
-            if len(self.inputs) == 0:
-                self.inputs.new("IntSocket", "Schema Length", identifier='Schema Length')
-            if self.inputs[-1].bl_idname != "WildcardSocket":
-                self.inputs.new("WildcardSocket", "", identifier="__extend__")
-        self.is_updating = False
+        try:
+            node_group_update(self)
+            # reset things if necessary:
+            if self.node_tree:
+                if len(self.inputs) == 0:
+                    self.inputs.new("IntSocket", "Schema Length", identifier='Schema Length')
+                if self.inputs[-1].bl_idname != "WildcardSocket":
+                    self.inputs.new("WildcardSocket", "", identifier="__extend__")
+        finally: # we need to reset this regardless of whether or not the operation succeeds!
+            self.is_updating = False
+            self.id_data.do_live_update = live_update # ensure this remains the same
 
 
 
@@ -346,6 +355,8 @@ NODES_REMOVED=["xFormRootNode"]
 SOCKETS_REMOVED=[("UtilityDriverVariable","Transform Channel"),
                  ("xFormRootNode","World Out"),
                  ("UtilitySwitch","xForm")]
+SOCKETS_RENAMED=[]
+SOCKETS_ADDED=[("DeformerMorphTargetDeform", 'INPUT', 'BooleanSocket', "Use Shape Key", 1),]
 
 # replace names with bl_idnames for reading the tree and solving schemas.
 replace_types = ["NodeGroupInput", "NodeGroupOutput", "SchemaIncomingConnection",

+ 1 - 1
blender_manifest.toml

@@ -3,7 +3,7 @@ schema_version = "1.0.0"
 # Example of manifest file for a Blender extension
 # Change the values according to your extension
 id = "mantis"
-version = "0.9.6"
+version = "0.9.7"
 name = "Mantis"
 tagline = "Mantis is a rigging nodes toolkit"
 maintainer = "Nodespaghetti <josephbburg@protonmail.com>"

+ 2 - 0
ops_nodegroup.py

@@ -101,6 +101,8 @@ class MantisGroupNodes(Operator):
             n.location -= bb_center
 
         grp_node.location = Vector((all_nodes_bounding_box[0].x+200, all_nodes_bounding_box[0].lerp(all_nodes_bounding_box[1], 0.5).y))
+        from .base_definitions import node_group_update
+        node_group_update(grp_node, force=True)
 
         # for each node in the JSON
         for n in selected_nodes[base_tree.name][2].values():