Ver código fonte

Merge branch 'keep_this'

Joseph Brandenburg 4 meses atrás
pai
commit
63885b9b72
7 arquivos alterados com 95 adições e 7 exclusões
  1. 2 1
      __init__.py
  2. 1 1
      blender_manifest.toml
  3. 27 1
      link_containers.py
  4. 15 1
      link_definitions.py
  5. 15 0
      link_socket_templates.py
  6. 5 3
      schema_solve.py
  7. 30 0
      socket_definitions.py

+ 2 - 1
__init__.py

@@ -16,7 +16,7 @@ from .utilities import prRed
 
 MANTIS_VERSION_MAJOR=0
 MANTIS_VERSION_MINOR=11
-MANTIS_VERSION_SUB=12
+MANTIS_VERSION_SUB=13
 
 classLists = [module.TellClasses() for module in [
  link_definitions,
@@ -84,6 +84,7 @@ link_transform_category = [
         NodeItem("LinkLimitRotation"),
         NodeItem("LinkLimitDistance"),
         NodeItem("LinkTransformation"),
+        NodeItem("LinkFloor"),
     ]
 link_tracking_category = [
         NodeItem("LinkInverseKinematics"),

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

+ 27 - 1
link_containers.py

@@ -29,6 +29,7 @@ def TellClasses():
              # IK
              LinkInverseKinematics,
              LinkSplineIK,
+             LinkFloor,
              # Drivers
              LinkDrivenParameter,
             ]
@@ -838,4 +839,29 @@ class LinkSplineIK(MantisLinkNode):
             self.bObject.append(c)
             props_sockets = self.gen_property_socket_map()
             evaluate_sockets(self, c, props_sockets)
-        self.executed = True
+        self.executed = True
+    
+
+class LinkFloor(MantisLinkNode):
+    '''A node representing an armature object'''
+
+    def __init__(self, signature, base_tree,):
+        super().__init__(signature, base_tree, LinkFloorSockets)
+        self.init_parameters(additional_parameters={"Name":None })
+        self.set_traverse([("Input Relationship", "Output Relationship")])
+        setup_custom_props(self) # <-- this takes care of the runtime-added sockets
+
+    def bExecute(self, bContext = None,):
+        prepare_parameters(self)
+        for xf in self.GetxForm():
+            print(wrapGreen("Creating ")+wrapOrange("Floor")+
+                wrapGreen(" Constraint for bone: ") +
+                wrapOrange(xf.bGetObject().name))
+            c = xf.bGetObject().constraints.new('FLOOR')
+            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

+ 15 - 1
link_definitions.py

@@ -28,6 +28,7 @@ def TellClasses():
              LinkDrivenParameterNode,
              LinkArmatureNode,
              LinkSplineIKNode,
+             LinkFloorNode,
              LinkTransformationNode,
            ]
 
@@ -374,8 +375,21 @@ class LinkSplineIKNode(Node, LinkNode):
         self.color = ikColor
         self.initialized = True
         
-# DRIVERS!!
+class LinkFloorNode(Node, LinkNode):
+    """A node representing Blender's Floor Constraint"""
+    bl_idname = "LinkFloor"
+    bl_label = "Floor"
+    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
 
+# DRIVERS!!
 class LinkDrivenParameterNode(Node, LinkNode):
     """Represents a driven parameter in the downstream xForm node."""
     bl_idname = "LinkDrivenParameter"

+ 15 - 0
link_socket_templates.py

@@ -407,6 +407,21 @@ LinkSplineIKSockets = [
     OutputRelationshipTemplate,
 ]
 
+LinkFloorSockets = [
+    InputRelationshipTemplate,
+    TargetTemplate,
+    FloorOffsetTemplate := SockTemplate(name="Offset", bl_idname="BooleanSocket",
+            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"),
+    FloorUseRotation := SockTemplate(name="Rotation", bl_idname='BooleanSocket',
+            is_input=True, default_value=False, blender_property='use_rotation',),
+    TargetSpaceTemplate,
+    OwnerSpaceTemplate,
+    EnableTemplate,
+    OutputRelationshipTemplate,
+]
+
 # Remove this socket because of Blender changes.
 if (app.version >= (4, 5, 0)):
     LinkSplineIKSockets.pop(9)

+ 5 - 3
schema_solve.py

@@ -372,8 +372,10 @@ class SchemaSolver:
 
     def handle_link_to_constant_output(self, frame_mantis_nodes, index, ui_link,  to_ui_node):
         to_node = self.schema_nodes[(*self.tree_path_names, to_ui_node.bl_idname)]
-        expose_when = to_node.evaluate_input('Expose at Index')
-        if expose_when > self.solve_length-1:
+        expose_when = to_node.evaluate_input('Expose when N==')
+        # this will be None for nested Groups that have ordinary Group Input and Group Output nodes.
+        # and in that case we just do it no matter what
+        if expose_when is not None and expose_when > self.solve_length-1:
             raise GraphError(f"The Schema has a constant output at index {expose_when}"
                              f" but it terminates at index {self.solve_length-1}. "
                              f"The Schema must have a length of at least {expose_when+1}.")
@@ -392,7 +394,7 @@ class SchemaSolver:
                 from_socket_name = ui_link.from_socket.name
         # HACK here to force it to work with ordinary node groups, which don't seem to set this value correctly.
         if to_ui_node.bl_idname == "NodeGroupOutput":
-            expose_when = index # just set it directly since it is getting set to None somewhere (I should find out where tho)
+            expose_when = index # the expose-when value is None because the GroupOutput doesn't have the socket.
         # end HACK
         if index == expose_when:
             for outgoing in self.constant_out[ui_link.to_socket.name]:

+ 30 - 0
socket_definitions.py

@@ -155,6 +155,7 @@ def TellClasses() -> List[MantisSocket]:
              EnumTrackAxis,
              EnumUpAxis,
              EnumFollowPathForwardAxis,
+             EnumFloorAxis,
              EnumLockAxis,
              EnumLimitMode,
              EnumYScaleMode,
@@ -1438,6 +1439,35 @@ class EnumFollowPathForwardAxis(MantisSocket):
     def draw_color_simple(self):
         return self.color_simple
 
+# Follow Track Forward axis
+eFloorAxis =   (('FLOOR_X',        "X",  "X",  0),
+                ('FLOOR_Y',        "Y",  "Y",  1),
+                ('FLOOR_Z',        "Z",  "Z",  2),
+                ('FLOOR_NEGATIVE_X', "-X", "-X", 3),
+                ('FLOOR_NEGATIVE_Y', "-Y", "-Y", 4),
+                ('FLOOR_NEGATIVE_Z', "-Z", "-Z", 5),)
+
+class EnumFloorAxis(MantisSocket):
+    '''Floor Constraint Axis'''
+    bl_idname = 'EnumFloorAxis'
+    bl_label = "Floor Axis"
+    
+    default_value: bpy.props.EnumProperty(
+        items=eFloorAxis,
+        name="Floor Axis",
+        description="Floor Axis",
+        default = 'FLOOR_X',
+        update = update_socket,)
+    color_simple = cString
+    color : bpy.props.FloatVectorProperty(default=cString, size=4)
+    input : bpy.props.BoolProperty(default =False,)
+    def draw(self, context, layout, node, text):
+        ChooseDraw(self, context, layout, node, text)
+    def draw_color(self, context, node):
+        return self.color
+    @classmethod
+    def draw_color_simple(self):
+        return self.color_simple
 # Locked Track
 
 eLockAxis = (('LOCK_X', "X", "X", 1),