Browse Source

Fix: Incorrect socket templates for LinkFloor

it was also missing custom space
and versioning to fix the socket for old files.
Brandenburg 1 month ago
parent
commit
7d454c9324
5 changed files with 33 additions and 5 deletions
  1. 1 1
      __init__.py
  2. 1 1
      blender_manifest.toml
  3. 2 0
      link_nodes.py
  4. 1 1
      link_socket_templates.py
  5. 28 2
      versioning.py

+ 1 - 1
__init__.py

@@ -18,7 +18,7 @@ from .utilities import prRed
 
 MANTIS_VERSION_MAJOR=0
 MANTIS_VERSION_MINOR=12
-MANTIS_VERSION_SUB=24
+MANTIS_VERSION_SUB=25
 
 classLists = [module.TellClasses() for module in [
  link_nodes_ui,

+ 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.12.24"
+version = "0.12.25"
 name = "Mantis"
 tagline = "Mantis is a rigging nodes toolkit"
 maintainer = "Nodespaghetti <josephbburg@protonmail.com>"

+ 2 - 0
link_nodes.py

@@ -863,6 +863,7 @@ class LinkFloor(MantisLinkNode):
             if constraint_name := self.evaluate_input("Name"):
                 c.name = constraint_name
             self.bObject.append(c)
+            self.set_custom_space()
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
         self.executed = True
@@ -885,6 +886,7 @@ class LinkShrinkWrap(MantisLinkNode):
             if constraint_name := self.evaluate_input("Name"):
                 c.name = constraint_name
             self.bObject.append(c)
+            # self.set_custom_space() # this needs to be overridden for me TODO
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
         self.executed = True

+ 1 - 1
link_socket_templates.py

@@ -411,7 +411,7 @@ LinkSplineIKSockets = [
 LinkFloorSockets = [
     InputRelationshipTemplate,
     TargetTemplate,
-    FloorOffsetTemplate := SockTemplate(name="Offset", bl_idname="BooleanSocket",
+    FloorOffsetTemplate := SockTemplate(name="Offset", bl_idname="FloatSocket",
             is_input=True, default_value=False, blender_property='offset'),
     FloorAxisTemplate := SockTemplate(name='Min/Max', bl_idname='EnumFloorAxis',
             is_input = True, default_value="FLOOR_X", blender_property="floor_location"),

+ 28 - 2
versioning.py

@@ -220,13 +220,40 @@ def cleanup_4_5_0_LTS_interface_workaround(*args, **kwargs):
             interface_item.description = ''
     # that should be enough!
 
+
+def up_0_12_25_replace_floor_offset_type(*args, **kwargs):
+    # add an inherit color input.
+    node = kwargs['node']
+    current_major_version = node.id_data.mantis_version[0]
+    current_minor_version = node.id_data.mantis_version[1]
+    current_sub_version = node.id_data.mantis_version[2]
+    if  current_major_version > 0: return# major version must be 0
+    if current_minor_version > 12: return# minor version must be 12 or less
+    if current_minor_version == 12 and current_sub_version > 24: return # sub version must be 8 or less
+    # I am having it do 8 or less because there was a bug in this function prior to 9
+    # sub version doesn't matter since any subversion of 11 should trigger this task
+    socket_maps = get_socket_maps(node)
+    prPurple(f"Fixing \"Offset\" socket in {node.name}")
+    try:
+        offset = node.inputs("Offset")
+        node.inputs.remove(offset)
+        s = node.inputs.new('FloatSocket', 'Offset',)
+        node.inputs.move(len(node.inputs)-1, 2)
+        do_relink(node, s, socket_maps[0])
+    except Exception as e:
+        prRed(f"Error updating version in node: {node.id_data.name}::{node.name}; see error:")
+        print(e)
+
+
+
 versioning_tasks = [
-    # node bl_idname    task                required keyword arguments 
+    # node bl_idname    task                required keyword arguments
     (['ALL'], version_upgrade_very_old, ['node_tree', 'node'],),
     (['xFormBoneNode'], version_upgrade_bone_0_12_0_from_older, ['node'],),
     (['xFormBoneNode'], up_0_12_1_add_inherit_color, ['node'],),
     (['MantisTree', 'SchemaTree'], cleanup_4_5_0_LTS_interface_workaround, ['tree']),
     (['InputWidget'], up_0_12_13_add_widget_scale, ['node']),
+    (['LinkFloor'], up_0_12_25_replace_floor_offset_type, ['node']),
 ]
 
 
@@ -274,4 +301,3 @@ def socket_add_workaround_for_4_5_0_LTS(item, socket_collection, multi):
         identifier=item.identifier,
         use_multi_input=multi, )
     return s
-