Explorar o código

Fix: bone hiding, drivers broken in Blender 5.0+

Blender 5.0 introduced a change that makes hiding the bone do nothing,
now it is necessary to hide the pose bone too.
Joseph Brandenburg hai 1 mes
pai
achega
4f707f625f
Modificáronse 2 ficheiros con 10 adicións e 2 borrados
  1. 6 1
      node_common.py
  2. 4 1
      xForm_nodes.py

+ 6 - 1
node_common.py

@@ -8,6 +8,8 @@ from collections.abc import Callable
 # the x_containers files import * from this file
 # the x_containers files import * from this file
 # so all the top-level imports are carried over
 # so all the top-level imports are carried over
 
 
+from bpy.app import version as bpy_version
+
 
 
 #TODO: refactor the socket definitions so this becomes unnecessary.
 #TODO: refactor the socket definitions so this becomes unnecessary.
 def get_socket_value(node_socket):
 def get_socket_value(node_socket):
@@ -288,7 +290,10 @@ def finish_driver(mantis_node, b_object, driver_item, prop):
             driver["owner"] = sub_props[-1]
             driver["owner"] = sub_props[-1]
         elif mantis_node.node_type in ['XFORM',] and mantis_node.__class__.__name__ in ['xFormBone']:
         elif mantis_node.node_type in ['XFORM',] and mantis_node.__class__.__name__ in ['xFormBone']:
             # TODO: I really shouldn't have to hardcode this. Look into better solutions.
             # TODO: I really shouldn't have to hardcode this. Look into better solutions.
-            if prop in ['hide', 'show_wire']: # we need to get the bone, not the pose bone.
+            # NOTE: VERSIONING in Blender 5.0 we have to use pose bone for this, too.
+            if bpy_version <= (5,0,0) and prop  == 'hide': # older blendders, we need the bone
+                bone_col = mantis_node.bGetParentArmature().data.bones
+            if prop  == 'show_wire': # TODO check if the bug that forced the above affects this
                 bone_col = mantis_node.bGetParentArmature().data.bones
                 bone_col = mantis_node.bGetParentArmature().data.bones
             else:
             else:
                 bone_col = mantis_node.bGetParentArmature().pose.bones
                 bone_col = mantis_node.bGetParentArmature().pose.bones

+ 4 - 1
xForm_nodes.py

@@ -519,7 +519,10 @@ class xFormBone(xFormNode):
             'custom_shape_scale_xyz'      : ("Custom Object Scale",  (0.0,0.0,0.0) ),
             'custom_shape_scale_xyz'      : ("Custom Object Scale",  (0.0,0.0,0.0) ),
             'custom_shape_translation'    : ("Custom Object Translation",  (0.0,0.0,0.0) ),
             'custom_shape_translation'    : ("Custom Object Translation",  (0.0,0.0,0.0) ),
             'custom_shape_rotation_euler' : ("Custom Object Rotation",  (0.0,0.0,0.0) ),
             'custom_shape_rotation_euler' : ("Custom Object Rotation",  (0.0,0.0,0.0) ),
-            'use_custom_shape_bone_size'  : ("Custom Object Scale to Bone Length",  True,)
+            'use_custom_shape_bone_size'  : ("Custom Object Scale to Bone Length",  True,),
+            # in 5.0.0 and newer I have to do pose bone also. Irritating.
+            # it doesn't hurt to do it in all versions.
+            'hide'                        : ("Hide", False),
         }
         }
 
 
         evaluate_sockets(self, pb, props_sockets)
         evaluate_sockets(self, pb, props_sockets)