Forráskód Böngészése

Add floor, ceil, round to Float Math node

Joseph Brandenburg 5 hónapja
szülő
commit
89c6df8d36
3 módosított fájl, 14 hozzáadás és 3 törlés
  1. 9 1
      math_containers.py
  2. 1 1
      math_definitions.py
  3. 4 1
      socket_definitions.py

+ 9 - 1
math_containers.py

@@ -34,9 +34,17 @@ def math_operation(operation, a, b):
             return float(a > b)
         case "LESS THAN":
             return float(a < b)
-        case" ARCTAN2":
+        case "ARCTAN2":
             from math import atan2
             return atan2(a,b)
+        case "FLOOR":
+            from math import floor
+            return floor(a)
+        case "CEIL":
+            from math import ceil
+            return ceil(a)
+        case "ROUND":
+            return round(a)
 
 #*#-------------------------------#++#-------------------------------#*#
 # M A T H  N O D E S

+ 1 - 1
math_definitions.py

@@ -68,7 +68,7 @@ class MathStaticFloatNode(Node, MantisUINode):
             node_tree = context.space_data.path[0].node_tree
             nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
             op = nc.evaluate_input("Operation")
-            if op in ['ABSOLUTE']:
+            if op in ['ABSOLUTE', 'FLOOR', 'CEIL', 'ROUND']:
                 self.inputs["Float B"].hide = True
             else:
                 self.inputs["Float B"].hide = False

+ 4 - 1
socket_definitions.py

@@ -2277,7 +2277,10 @@ enumFloatOperations = (('ADD', 'Add', 'Add'),
                       ('MINIMUM', "Minimum", "Minimum"),
                       ('GREATER THAN', "Greater Than", "Greater Than"),
                       ('LESS THAN', "Less Than", "Less Than"),
-                      ('ARCTAN2', "atan2", "2-argument arctan function"),)
+                      ('ARCTAN2', "atan2", "2-argument arctan function"),
+                      ('FLOOR', "Floor", "the nearest integer lower than input A"),
+                      ('CEIL', "Ceiling", "the next integer higher than input A"),
+                      ('ROUND', "Round", "Round to the nearest integer"),)
 
 class MathFloatOperation(MantisSocket):
     """Float Math Operation"""