Переглянути джерело

partial: new matrix from curve/ compose matrix mode

Joseph Brandenburg 4 тижнів тому
батько
коміт
febb181a66
3 змінених файлів з 49 додано та 6 видалено
  1. 11 5
      misc_nodes_socket_templates.py
  2. 20 1
      misc_nodes_ui.py
  3. 18 0
      versioning.py

+ 11 - 5
misc_nodes_socket_templates.py

@@ -49,19 +49,25 @@ InputMatrixSockets = [
 ]
 
 MatrixFromCurveSockets=[
+    MatrixFromCurveMode := ST(name="Mode", bl_idname="EnumMatrixFromCurveMode",
+        is_input = True, ),
     CurveTemplate := ST(name="Curve", bl_idname='EnumCurveSocket', 
         is_input=True,),
     SplineIndexTemplate,
-    TotalDivisionsTemplate := ST(name="Total Divisions",
+    TotalDivisionsTemplate := ST(name="Total Divisions", category = "divisions",
         bl_idname='UnsignedIntSocket', is_input=True, default_value=0,),
-    MatrixIndexTemplate := ST(name="Matrix Index",
+    MatrixIndexTemplate := ST(name="Matrix Index", category = "divisions",
         bl_idname='UnsignedIntSocket', is_input=True, default_value=0,),
+    replace(FactorTemplate, category="factor"),
     MatrixOutput,
 ]
 
-MatricesFromCurveSockets=MatrixFromCurveSockets.copy()
-MatricesFromCurveSockets[4] = MatricesOutTemplate
-MatricesFromCurveSockets.pop(3)
+MatricesFromCurveSockets=[
+    CurveTemplate,
+    SplineIndexTemplate,
+    TotalDivisionsTemplate,
+    MatricesOutTemplate,
+]
 
 MatrixFromCurveSegmentSockets=[
     CurveTemplate,

+ 20 - 1
misc_nodes_ui.py

@@ -224,7 +224,26 @@ class UtilityMatrixFromCurve(Node, MantisMiscNode):
     mantis_node_class_name=bl_idname
     socket_templates=MatrixFromCurveSockets
 
-class UtilityPointFromCurve(Node, MantisMiscNode):
+    def display_update(self, parsed_tree, context):
+        # first we'll checc if the mode is connected to a noodle, should be rare
+        mode = 'DIVISIONS'
+        if self.inputs['Mode'].is_linked:
+            if mantis_node := parsed_tree.get(get_signature_from_edited_tree(self, context)):
+                mode = mantis_node.evaluate_input("Mode")
+        else: # We can use it directly, this is a little faster.
+            mode = self.inputs['Mode'].default_value
+        # We just hide/show based on the selected mode.
+        for template in self.__class__.socket_templates:
+            if mode == 'DIVISIONS' and template.category == 'factor':
+                self.inputs[template.name].hide=True
+            if mode == 'DIVISIONS' and template.category == 'divisions':
+                self.inputs[template.name].hide=False
+            elif mode == 'FACTOR' and template.category == 'divisions':
+                self.inputs[template.name].hide=True
+            elif mode == 'FACTOR' and template.category == 'factor':
+                self.inputs[template.name].hide=False
+
+class UtilityPointFromCurve(Node, MantisUINode):
     """Gets a point from a curve."""
     bl_idname = "UtilityPointFromCurve"
     bl_label = "Point from Curve"

+ 18 - 0
versioning.py

@@ -523,6 +523,21 @@ def add_new_display_features_v0_13_5(*args, **kwargs):
                 node.is_updating = False
         tree.do_live_update = live_updates
 
+def up_0_13_5_modes_for_matrix_from_curve_and_compose_matrix(*args, **kwargs):
+    node = kwargs['node']
+    node.is_updating = True
+    do_live_updates = node.id_data.do_live_updates
+    node.id_data.do_live_updates = False
+    # new re_init keyword should use socket template to automate the update.
+    prGreen("THIS ONE HERE")
+    print (node.id_data.name, node.name)
+    print (node.inputs.keys())
+    if "Mode" not in node.inputs.keys(): # just check here to see if it is needed.
+        prOrange("DOING THE THING BRO")
+        node.init_sockets(node.__class__.socket_templates, re_init=True)
+    node.id_data.do_live_updates = do_live_updates
+    node.is_updating = False
+
 # versioning tasks that involve Blender versions rather than Mantis versions:
 error_description_4_5_0_LTS = 'There is a bug in Blender 4.5.0 LTS, that is why these sockets are blue.'\
                              ' This will be fixed in future Blender versions.'
@@ -561,6 +576,9 @@ versioning_tasks = [
            update_fcurve_and_armature_node_to_multi_socket, ['node']),
     (['MantisTree', 'SchemaTree'], fix_bbone_default_scale_in_and_out, ['tree']),
     (['MantisTree', 'SchemaTree'], add_new_display_features_v0_13_5, ['tree']),
+    (['UtilityMatrixFromCurve', 'UtilityMatrixCompose'],
+       up_0_13_5_modes_for_matrix_from_curve_and_compose_matrix,
+     ['node',], ),
 ]