Pārlūkot izejas kodu

Add Linear Interpolation operator to Static Vector Math

Joseph Brandenburg 9 mēneši atpakaļ
vecāks
revīzija
7057595d99
3 mainītis faili ar 7 papildinājumiem un 1 dzēšanām
  1. 2 0
      math_containers.py
  2. 3 0
      math_definitions.py
  3. 2 1
      socket_definitions.py

+ 2 - 0
math_containers.py

@@ -206,6 +206,8 @@ class MathStaticVector:
             f_result =  a.dot(b)
         if self.evaluate_input("Operation") == "NORMALIZE":
             v_result =  a.normalized()
+        if self.evaluate_input("Operation") == "LINEAR_INTERP":
+            v_result =  a.lerp(b, s).copy()
         self.parameters["Result Float"] = f_result
         # if v_result:
         self.parameters["Result Vector"] = v_result

+ 3 - 0
math_definitions.py

@@ -116,6 +116,9 @@ class MathStaticVectorNode(Node, MantisNode):
             elif op in ['LENGTH', 'NORMALIZE']: # only a vector input
                 self.inputs["Vector B"].hide = True
                 self.inputs["Scalar A"].hide = True
+            elif op in ['LINEAR_INTERP']: # both inputs
+                self.inputs["Vector B"].hide = False
+                self.inputs["Scalar A"].hide = False
             else:
                 self.inputs["Vector B"].hide = False
                 self.inputs["Scalar A"].hide = True

+ 2 - 1
socket_definitions.py

@@ -2166,7 +2166,8 @@ enumVectorOperations = (('ADD', 'Add', 'Add (Component-wise)'),
                         ('LENGTH', "Length", "Length"),
                         ('CROSS', "Cross Product", "Cross product of A X B"),
                         ('NORMALIZE', "Normalize", "Returns a normalized vector."),
-                        ('DOT', "Dot Product", "Dot product of A . B"),)
+                        ('DOT', "Dot Product", "Dot product of A . B"),
+                        ('LINEAR_INTERP', "Linear Interpolation", "Linear Interpolation between vectors A and B by factor"))