Browse Source

Add Shrinkkwrap constraint

Brandenburg 1 month ago
parent
commit
fbde56e1c4
5 changed files with 385 additions and 183 deletions
  1. 6 5
      __init__.py
  2. 67 43
      link_nodes.py
  3. 32 17
      link_nodes_ui.py
  4. 39 5
      link_socket_templates.py
  5. 241 113
      socket_definitions.py

+ 6 - 5
__init__.py

@@ -1,5 +1,5 @@
 from . import ( ops_nodegroup,
-                ops_ui, 
+                ops_ui,
                 base_definitions,
                 socket_definitions,
                 link_nodes_ui,
@@ -104,6 +104,7 @@ link_tracking_category = [
         NodeItem("LinkDampedTrack"),
         NodeItem("LinkLockedTrack"),
         NodeItem("LinkTrackTo"),
+        NodeItem("LinkShrinkWrap"),
     ]
 link_relationship_category = [
         NodeItem("linkInherit"),
@@ -245,7 +246,7 @@ def update_handler(scene):
         if not trees: return
         if (node_tree := trees[0]).bl_idname in ['MantisTree']:
             if node_tree.is_exporting:
-                return 
+                return
             if node_tree.prevent_next_exec : pass
             elif node_tree.do_live_update and not (node_tree.is_executing):
                 node_tree.update_tree(context)
@@ -349,7 +350,7 @@ def autoload_components(filename):
             for tree_name in json_data.keys():
                 tree = data.node_groups.get(tree_name)
                 tree.use_fake_user = True
-            
+
     # now we need to unlink the collections, and add fake users to them
     curves_collection = get_default_collection(collection_type="CURVE")
     armature_collection = get_default_collection(collection_type="ARMATURE")
@@ -387,7 +388,7 @@ from .menu_classes import (node_context_menu_draw, node_add_menu_draw,
 
 def register():
     from bpy.utils import register_class
-    
+
     for cls in classes:
         try:
             register_class(cls)
@@ -431,7 +432,7 @@ def unregister():
     from bpy.utils import unregister_class
     for cls in reversed(classes):
         unregister_class(cls)
-    
+
     for km, kmi in addon_keymaps:
         km.keymap_items.remove(kmi)
     addon_keymaps.clear()

+ 67 - 43
link_nodes.py

@@ -29,7 +29,9 @@ def TellClasses():
              # IK
              LinkInverseKinematics,
              LinkSplineIK,
+             # stuff that snaps or limits a bone
              LinkFloor,
+             LinkShrinkWrap,
              # Drivers
              LinkDrivenParameter,
             ]
@@ -53,10 +55,10 @@ class MantisLinkNode(MantisNode):
             if socket.is_linked:
                 return socket.links[0].from_node
             return None
-            
+
         else:
             return super().evaluate_input(input_name)
-    
+
     def gen_property_socket_map(self) -> dict:
         props_sockets = super().gen_property_socket_map()
         if (os := self.inputs.get("Owner Space")) and os.is_connected and os.links[0].from_node.node_type == 'XFORM':
@@ -64,7 +66,7 @@ class MantisLinkNode(MantisNode):
         if ts := self.inputs.get("Target_Space") and ts.is_connected and ts.links[0].from_node.node_type == 'XFORM':
             del props_sockets['target_space']
         return props_sockets
-    
+
     def set_custom_space(self):
         for c in self.bObject:
             if (os := self.inputs.get("Owner Space")) and os.is_connected and os.links[0].from_node.node_type == 'XFORM':
@@ -81,7 +83,7 @@ class MantisLinkNode(MantisNode):
                     c.space_object=self.inputs["Target_Space Space"].links[0].from_node.bGetParentArmature(); c.space_subtarget=xf.name
                 else:
                     c.space_object=xf
-        
+
     def GetxForm(nc, output_name="Output Relationship"):
         break_condition= lambda node : node.node_type=='XFORM'
         xforms = trace_line_up_branching(nc, output_name, break_condition)
@@ -93,11 +95,11 @@ class MantisLinkNode(MantisNode):
                 continue
             return_me.append(xf)
         return return_me
-    
+
     def reset_execution(self):
         super().reset_execution()
         self.prepared = True; self.bObject = []
-    
+
     def bFinalize(self, bContext=None):
         finish_drivers(self)
 
@@ -108,13 +110,13 @@ class MantisLinkNode(MantisNode):
 
 class LinkInherit(MantisLinkNode):
     '''A node representing inheritance'''
-    
+
     def __init__(self, signature, base_tree):
         super().__init__(signature, base_tree, LinkInheritSockets)
         self.init_parameters()
         self.set_traverse([('Parent', 'Inheritance')])
         self.executed = True
-    
+
     def GetxForm(self):
         # I think this is only run in display update.
         trace = trace_single_line_up(self, "Inheritance")
@@ -125,7 +127,7 @@ class LinkInherit(MantisLinkNode):
 
 class LinkCopyLocation(MantisLinkNode):
     '''A node representing Copy Location'''
-    
+
     def __init__(self, signature : tuple,
                  base_tree : NodeTree,):
         super().__init__(signature, base_tree, LinkCopyLocationSockets)
@@ -148,10 +150,10 @@ class LinkCopyLocation(MantisLinkNode):
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
         self.executed = True
-        
+
 class LinkCopyRotation(MantisLinkNode):
     '''A node representing Copy Rotation'''
-    
+
     def __init__(self, signature, base_tree):
         super().__init__(signature, base_tree, LinkCopyRotationSockets)
         additional_parameters = { "Name":None }
@@ -166,7 +168,7 @@ class LinkCopyRotation(MantisLinkNode):
             print(wrapGreen("Creating ")+wrapWhite("Copy Rotation")+
                 wrapGreen(" Constraint for bone: ") +
                 wrapOrange(xf.bGetObject().name))
-            
+
             rotation_order = self.evaluate_input("RotationOrder")
             if ((rotation_order == 'QUATERNION') or (rotation_order == 'AXIS_ANGLE')):
                 c.euler_order = 'AUTO'
@@ -182,10 +184,10 @@ class LinkCopyRotation(MantisLinkNode):
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
         self.executed = True
-        
+
 class LinkCopyScale(MantisLinkNode):
     '''A node representing Copy Scale'''
-    
+
     def __init__(self, signature, base_tree):
         super().__init__(signature, base_tree, LinkCopyScaleSockets)
         additional_parameters = { "Name":None }
@@ -218,13 +220,13 @@ class LinkCopyScale(MantisLinkNode):
                 else:
                     c.space_object=xf
             props_sockets = self.gen_property_socket_map()
-            evaluate_sockets(self, c, props_sockets)   
-        self.executed = True 
-            
+            evaluate_sockets(self, c, props_sockets)
+        self.executed = True
+
 
 class LinkCopyTransforms(MantisLinkNode):
     '''A node representing Copy Transfoms'''
-    
+
     def __init__(self, signature, base_tree):
         super().__init__(signature, base_tree, LinkCopyTransformsSockets)
         additional_parameters = { "Name":None }
@@ -244,17 +246,17 @@ class LinkCopyTransforms(MantisLinkNode):
             self.bObject.append(c)
             self.set_custom_space()
             props_sockets = self.gen_property_socket_map()
-            evaluate_sockets(self, c, props_sockets)  
+            evaluate_sockets(self, c, props_sockets)
         self.executed = True
 
 class LinkTransformation(MantisLinkNode):
     '''A node representing Copy Transfoms'''
-    
+
     def __init__(self, signature, base_tree):
         super().__init__(signature, base_tree, LinkTransformationSockets)
         self.init_parameters(additional_parameters={"Name":None })
         self.set_traverse([("Input Relationship", "Output Relationship")])
-    
+
     def ui_modify_socket(self, ui_socket, socket_name=None):
         from_suffix, to_suffix = '', ''
         if self.evaluate_input("Map From") == 'ROTATION': from_suffix='_rot'
@@ -312,7 +314,7 @@ class LinkTransformation(MantisLinkNode):
                     stub='to_max_'+axis
                     props_sockets[stub+to_replace]=props_sockets[stub]
                     del props_sockets[stub]
-            evaluate_sockets(self, c, props_sockets)  
+            evaluate_sockets(self, c, props_sockets)
         self.executed = True
 
 class LinkLimitLocation(MantisLinkNode):
@@ -335,7 +337,7 @@ class LinkLimitLocation(MantisLinkNode):
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
         self.executed = True
-        
+
 class LinkLimitRotation(MantisLinkNode):
     def __init__(self, signature, base_tree):
         super().__init__(signature, base_tree, LinkLimitRotationSockets)
@@ -349,7 +351,7 @@ class LinkLimitRotation(MantisLinkNode):
             print(wrapGreen("Creating ")+wrapWhite("Limit Rotation")+
                 wrapGreen(" Constraint for bone: ") +
                 wrapOrange(xf.bGetObject().name))
-            
+
             if constraint_name := self.evaluate_input("Name"):
                 c.name = constraint_name
             self.bObject.append(c)
@@ -371,7 +373,7 @@ class LinkLimitScale(MantisLinkNode):
             print(wrapGreen("Creating ")+wrapWhite("Limit Scale")+
                 wrapGreen(" Constraint for bone: ") +
                 wrapOrange(xf.bGetObject().name))
-            
+
             if constraint_name := self.evaluate_input("Name"):
                 c.name = constraint_name
             self.bObject.append(c)
@@ -379,7 +381,7 @@ class LinkLimitScale(MantisLinkNode):
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
         self.executed = True
- 
+
 class LinkLimitDistance(MantisLinkNode):
     def __init__(self, signature, base_tree):
         super().__init__(signature, base_tree, LinkLimitDistanceSockets)
@@ -423,7 +425,7 @@ class LinkStretchTo(MantisLinkNode):
             self.bObject.append(c)
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
-            
+
             if (self.evaluate_input("Original Length") == 0):
                 # this is meant to be set automatically.
                 c.rest_length = xf.bGetObject().bone.length
@@ -509,7 +511,7 @@ class LinkInheritConstraint(MantisLinkNode):
             if constraint_name := self.evaluate_input("Name"):
                 c.name = constraint_name
             self.bObject.append(c)
-            
+
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
             c.set_inverse_pending
@@ -520,19 +522,19 @@ class LinkInverseKinematics(MantisLinkNode):
         super().__init__(signature, base_tree, LinkInverseKinematicsSockets)
         self.init_parameters(additional_parameters={"Name":None })
         self.set_traverse([("Input Relationship", "Output Relationship")])
-    
+
     def get_base_ik_bone(self, ik_bone):
         chain_length : int = (self.evaluate_input("Chain Length"))
         if not isinstance(chain_length, (int, float)):
             raise GraphError(f"Chain Length must be an integer number in {self}::Chain Length")
         if chain_length == 0:
             chain_length = int("inf")
-        
+
         base_ik_bone = ik_bone; i=1
         while (i<chain_length) and (base_ik_bone.parent):
             base_ik_bone=base_ik_bone.parent; i+=1
         return base_ik_bone
-    
+
     # We need to do the calculation in a "full circle", meaning the pole_angle
     # can go over pi or less than -pi - but the actuall constraint value must
     # be clamped in that range.
@@ -542,7 +544,7 @@ class LinkInverseKinematics(MantisLinkNode):
         from math import pi
         from .utilities import wrap
         constraint.pole_angle = wrap(-pi, pi, angle)
-    
+
     def calc_pole_angle_pre(self, c, ik_bone):
         """
             This function gets us most of the way to a correct IK pole angle. Unfortunately,
@@ -563,9 +565,9 @@ class LinkInverseKinematics(MantisLinkNode):
         ik_pole = c.pole_target.pose.bones[c.pole_subtarget]
         if ik_pole.id_data != ik_bone.id_data:
             raise NotImplementedError(f"Currently,IK Constraint Pole Target for {self} must be a bone within the same armature.")
-        
+
         base_ik_bone = self.get_base_ik_bone(ik_bone)
-        
+
         start_effector = base_ik_bone.bone.head_local
         end_effector = ik_handle.bone.head_local
         pole_location = ik_pole.bone.head_local
@@ -596,7 +598,7 @@ class LinkInverseKinematics(MantisLinkNode):
             if angle != 0 and vector_u.cross(vector_v).angle(normal) < 1:
                 angle = -angle
             return angle
-        
+
         # we have already checked for valid data.
         ik_handle = c.target.pose.bones[c.subtarget]
         base_ik_bone = self.get_base_ik_bone(ik_bone)
@@ -614,7 +616,7 @@ class LinkInverseKinematics(MantisLinkNode):
         error=signed_angle(current_knee_direction, knee_direction, ik_axis)
         if error == 0:
             prGreen("No Fine-tuning needed."); return
-        
+
         # Flip it if needed
         dot_before=current_knee_direction.dot(knee_direction)
         if dot_before < 0 and angle!=0: # then it is not aligned and we should check the inverse
@@ -669,7 +671,7 @@ class LinkInverseKinematics(MantisLinkNode):
             self.get_target_and_subtarget(c, input_name = 'Pole Target')
             if constraint_name := self.evaluate_input("Name"):
                 c.name = constraint_name
-            
+
             self.bObject.append(c)
             c.chain_count = 1 # so that, if there are errors, this doesn't print
             #  a whole bunch of circular dependency crap from having infinite chain length
@@ -695,7 +697,7 @@ class LinkInverseKinematics(MantisLinkNode):
                     self.calc_pole_angle_post(constraint, ik_bone, bContext)
                     constraint.mute = enabled_before
         super().bFinalize(bContext)
-        
+
 
 def ik_report_error(pb, context, do_print=False):
     dg = context.view_layer.depsgraph
@@ -712,7 +714,7 @@ def ik_report_error(pb, context, do_print=False):
         print (f"IK Location Error: {location_error}")
         print (f"IK Rotation Error: {rotation_error}")
         print (f"IK Scale Error   : {scale_error}")
-    return (location_error, rotation_error, scale_error) 
+    return (location_error, rotation_error, scale_error)
 
 # This is kinda a weird design decision?
 class LinkDrivenParameter(MantisLinkNode):
@@ -767,7 +769,7 @@ class LinkDrivenParameter(MantisLinkNode):
         except TypeError:
             self.parameters["Value"] = driver
         super().bFinalize(bContext)
-    
+
 class LinkArmature(MantisLinkNode):
     '''A node representing an armature object'''
 
@@ -789,7 +791,7 @@ class LinkArmature(MantisLinkNode):
             self.bObject.append(c)
             # get number of targets
             num_targets = len( list(self.inputs.values())[6:] )//2
-            
+
             props_sockets = self.gen_property_socket_map()
             targets_weights = {}
             for i in range(num_targets):
@@ -825,7 +827,7 @@ class LinkSplineIK(MantisLinkNode):
                 wrapGreen(" Constraint for bone: ") +
                 wrapOrange(xf.bGetObject().name))
             c = xf.bGetObject().constraints.new('SPLINE_IK')
-            # set the spline - we need to get the right one 
+            # set the spline - we need to get the right one
             spline_index = self.evaluate_input("Spline Index")
             from .utilities import get_extracted_spline_object
             proto_curve = self.inputs['Target'].links[0].from_node.bGetObject()
@@ -840,7 +842,7 @@ class LinkSplineIK(MantisLinkNode):
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
         self.executed = True
-    
+
 
 class LinkFloor(MantisLinkNode):
     '''A node representing an armature object'''
@@ -864,3 +866,25 @@ class LinkFloor(MantisLinkNode):
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
         self.executed = True
+
+class LinkShrinkWrap(MantisLinkNode):
+    '''A node representing a shrinkwrap relationship.'''
+    def __init__(self, signature, base_tree,):
+        super().__init__(signature, base_tree, LinkShrinkWrapSockets)
+        self.init_parameters(additional_parameters={"Name":None })
+        self.set_traverse([("Input Relationship", "Output Relationship")])
+
+    def bRelationshipPass(self, bContext = None,):
+        prepare_parameters(self)
+        for xf in self.GetxForm():
+            print(wrapGreen("Creating ")+wrapOrange("Shrinkwrap")+
+                wrapGreen(" Constraint for bone: ") +
+                wrapOrange(xf.bGetObject().name))
+            c = xf.bGetObject().constraints.new('SHRINKWRAP')
+            self.get_target_and_subtarget(c)
+            if constraint_name := self.evaluate_input("Name"):
+                c.name = constraint_name
+            self.bObject.append(c)
+            props_sockets = self.gen_property_socket_map()
+            evaluate_sockets(self, c, props_sockets)
+        self.executed = True

+ 32 - 17
link_nodes_ui.py

@@ -29,6 +29,7 @@ def TellClasses():
              LinkArmatureNode,
              LinkSplineIKNode,
              LinkFloorNode,
+             LinkShrinkWrapNode,
              LinkTransformationNode,
            ]
 
@@ -50,13 +51,13 @@ class LinkInheritNode(Node, LinkNode):
     bl_icon = 'CONSTRAINT_BONE'
     initialized : bpy.props.BoolProperty(default = False)
     mantis_node_class_name="LinkInherit"
-    
+
     def init(self, context):
         self.init_sockets(LinkInheritSockets)
         self.initialized = True
         self.use_custom_color = True
         self.color = inheritColor
-    
+
     def display_update(self, parsed_tree, context):
         node_tree = context.space_data.path[0].node_tree
         nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
@@ -70,7 +71,7 @@ class LinkInheritNode(Node, LinkNode):
             try:
                 xForm = nc.GetxForm()
                 if xForm.__class__.__name__ not in "xFormBone":
-                    
+
                     bone_next=False
             except GraphError:
 
@@ -86,7 +87,7 @@ class LinkInheritNode(Node, LinkNode):
                 self.inputs["Connected"].hide        = True or self.inputs["Connected"].is_connected
             # the node_groups on the way here ought to be active if there
             #  is no funny business going on.
-    
+
 
 # DO: make another node for ITASC IK, eh?
 class LinkInverseKinematics(Node, LinkNode):
@@ -118,7 +119,7 @@ class LinkCopyLocationNode(Node, LinkNode):
         self.color = linkColor
         self.initialized = True
 
-        
+
 class LinkCopyRotationNode(Node, LinkNode):
     '''A node representing Copy Rotation'''
     bl_idname = 'LinkCopyRotation'
@@ -134,7 +135,7 @@ class LinkCopyRotationNode(Node, LinkNode):
         self.initialized = True
 
 
-        
+
 class LinkCopyScaleNode(Node, LinkNode):
     '''A node representing Copy Scale'''
     bl_idname = 'LinkCopyScale'
@@ -150,7 +151,7 @@ class LinkCopyScaleNode(Node, LinkNode):
         self.initialized = True
 
 
-        
+
 class LinkInheritConstraintNode(Node, LinkNode):
     # === Basics ===
     # Description string
@@ -186,7 +187,7 @@ class LinkCopyTransformNode(Node, LinkNode):
         self.initialized = True
 
 
-        
+
 class LinkStretchToNode(Node, LinkNode):
     '''A node representing Stretch-To'''
     bl_idname = 'LinkStretchTo'
@@ -214,7 +215,7 @@ class LinkDampedTrackNode(Node, LinkNode):
         self.initialized = True
         self.use_custom_color = True
         self.color = trackingColor
-        
+
 class LinkLockedTrackNode(Node, LinkNode):
     '''A node representing Stretch-To'''
     bl_idname = 'LinkLockedTrack'
@@ -228,7 +229,7 @@ class LinkLockedTrackNode(Node, LinkNode):
         self.initialized = True
         self.use_custom_color = True
         self.color = trackingColor
-        
+
 class LinkTrackToNode(Node, LinkNode):
     '''A node representing Stretch-To'''
     bl_idname = 'LinkTrackTo'
@@ -270,7 +271,7 @@ class LinkLimitScaleNode(Node, LinkNode):
         self.initialized = True
         self.use_custom_color = True
         self.color = linkColor
- 
+
 class LinkLimitRotationNode(Node, LinkNode):
     '''A node representing Limit Rotation'''
     bl_idname = 'LinkLimitRotation'
@@ -346,13 +347,13 @@ class LinkArmatureNode(Node, LinkNode):
     bl_icon = "CON_ARMATURE"
     initialized : bpy.props.BoolProperty(default = False)
     mantis_node_class_name=bl_idname
-    
+
     def init(self, context):
         self.init_sockets(LinkArmatureSockets)
         self.use_custom_color = True
         self.color = inheritColor
         self.initialized = True
-    
+
     def draw_buttons(self, context, layout):
         # return
         layout.operator( 'mantis.link_armature_node_add_target' )
@@ -368,13 +369,13 @@ class LinkSplineIKNode(Node, LinkNode):
     bl_icon = "CON_SPLINEIK"
     initialized : bpy.props.BoolProperty(default = False)
     mantis_node_class_name=bl_idname
-    
+
     def init(self, context):
         self.init_sockets(LinkSplineIKSockets)
         self.use_custom_color = True
         self.color = ikColor
         self.initialized = True
-        
+
 class LinkFloorNode(Node, LinkNode):
     """A node representing Blender's Floor Constraint"""
     bl_idname = "LinkFloor"
@@ -382,13 +383,27 @@ class LinkFloorNode(Node, LinkNode):
     bl_icon = "CON_FLOOR"
     initialized : bpy.props.BoolProperty(default = False)
     mantis_node_class_name=bl_idname
-    
+
     def init(self, context):
         self.init_sockets(LinkFloorSockets)
         self.use_custom_color = True
         self.color = linkColor
         self.initialized = True
 
+class LinkShrinkWrapNode(Node, LinkNode):
+    """A node representing Blender's Shrinkwrap Constraint"""
+    bl_idname = "LinkShrinkWrap"
+    bl_label = "Shrinkwrap"
+    bl_icon = "CON_SHRINKWRAP"
+    initialized : bpy.props.BoolProperty(default = False)
+    mantis_node_class_name=bl_idname
+
+    def init(self, context):
+        self.init_sockets(LinkShrinkWrapSockets)
+        self.use_custom_color = True
+        self.color = trackingColor
+        self.initialized = True
+
 # DRIVERS!!
 class LinkDrivenParameterNode(Node, LinkNode):
     """Represents a driven parameter in the downstream xForm node."""
@@ -397,7 +412,7 @@ class LinkDrivenParameterNode(Node, LinkNode):
     bl_icon = "CONSTRAINT_BONE"
     initialized : bpy.props.BoolProperty(default = False)
     mantis_node_class_name=bl_idname
-    
+
     def init(self, context):
         self.init_sockets(LinkDrivenParameterSockets)
         self.use_custom_color = True

+ 39 - 5
link_socket_templates.py

@@ -1,5 +1,6 @@
 from .base_definitions import MantisSocketTemplate as SockTemplate
 from bpy import app
+from dataclasses import replace
 
 from .misc_nodes_socket_templates import SplineIndexTemplate
 # Socket Templates we will reuse:
@@ -80,7 +81,7 @@ OutputRelationshipTemplate : SockTemplate = SockTemplate(
     name="Output Relationship", is_input=False,  bl_idname='RelationshipSocket', )
 
 
-LinkInheritSockets = [              
+LinkInheritSockets = [
     SockTemplate(name="Inherit Rotation", is_input=True,
                  bl_idname='BooleanSocket',       default_value=True,),
     SockTemplate(name="Inherit Scale",    is_input=True,
@@ -106,7 +107,7 @@ LinkCopyLocationSockets = [
     EnableTemplate,
     OutputRelationshipTemplate,
 ]
-    
+
 LinkCopyRotationSockets = [
     InputRelationshipTemplate,
     SockTemplate(name='RotationOrder', bl_idname='RotationOrderSocket', is_input=True,
@@ -160,7 +161,7 @@ TransformationMinMaxTemplateGenerator = lambda name, bprop  : SockTemplate(
     bl_idname='EnumTransformationAxes' if "Source" in name else "FloatSocket",
     default_value='X' if "Source" in name else 1.0,
     blender_property=bprop)
-    
+
 LinkTransformationSockets = [
     InputRelationshipTemplate,
     TargetTemplate,
@@ -370,7 +371,7 @@ LinkDrivenParameterSockets = [
                  default_value=0,),
     OutputRelationshipTemplate,
 ]
-  
+
 LinkArmatureSockets=[
     InputRelationshipTemplate,
     SockTemplate(name="Preserve Volume", bl_idname='BooleanSocket', is_input=True,
@@ -423,6 +424,39 @@ LinkFloorSockets = [
     OutputRelationshipTemplate,
 ]
 
+# DO: arrange these guys in order for goodness' sake
+LinkShrinkWrapSockets = [
+    InputRelationshipTemplate,
+    TargetTemplate, # IMPORTANT TO DO: targets should be an array
+    # and the constraints are made  ONLY if the target is valid...
+    # for BONE targets, maybe auto-magically build a mesh for the user.
+    CullFaceTemplate := SockTemplate(name='Face Cull', is_input = True,
+            bl_idname="EnumShrinkwrapFaceCullSocket", default_value='OFF',
+            blender_property = "cull_face"),
+    SWDistanceTemplate := SockTemplate(name="Distance", bl_idname="FloatSocket",
+            is_input=True, default_value=0.0, blender_property='distance'),
+    ProjectAxisTemplate := SockTemplate(name="Project Axis",
+            bl_idname="EnumShrinkwrapProjectAxisSocket", is_input=True,
+            blender_property='project_axis'),
+    TrackAxisTemplate:= SockTemplate(name="Track Axis", bl_idname="EnumTrackAxis",
+            is_input=True, blender_property='track_axis'),
+    ProjectAxisSpaceTemplate := replace(TargetSpaceTemplate, name='Space',
+            blender_property='project_axis_space'),
+    UseInvertCullTemplate:= SockTemplate(name="Invert Cull",
+            bl_idname="BooleanSocket", is_input=True,
+            blender_property='use_invert_cull'),
+    UseProjectOppositeTemplate:= replace(UseInvertCullTemplate,
+            name="Project Opposite", blender_property='use_project_opposite'),
+    UseTrackNormalTemplate:= replace(UseInvertCullTemplate,
+            name="Align to Normal", blender_property='use_track_normal'),
+    ShrinkwrapModeTemplate := SockTemplate(name="Snap Mode",
+            bl_idname="EnumShrinkwrapModeSocket", is_input=True,
+            blender_property='wrap_mode'),
+    InfluenceTemplate,
+    EnableTemplate,
+    OutputRelationshipTemplate,
+]
+
 # Remove this socket because of Blender changes.
 if (app.version >= (4, 5, 0)):
-    LinkSplineIKSockets.pop(9)
+    LinkSplineIKSockets.pop(9)

File diff suppressed because it is too large
+ 241 - 113
socket_definitions.py


Some files were not shown because too many files changed in this diff