diff --git a/api/types.py b/api/types.py index d8346bc..620e17a 100644 --- a/api/types.py +++ b/api/types.py @@ -57,10 +57,15 @@ def __init__(self, socket: bpy.types.NodeSocket = None, value = None): self.socket_type = type(socket).__name__ def _math(self, other, operation, reverse=False): + if other is None: + vector_or_value = self + else: + vector_or_value = (other, self) if reverse else (self, other) + if self._socket.type == 'VECTOR': - return geometry_script.vector_math(operation=operation, vector=(other, self) if reverse else (self, other)) + return geometry_script.vector_math(operation=operation, vector=vector_or_value) else: - return geometry_script.math(operation=operation, value=(other, self) if reverse else (self, other)) + return geometry_script.math(operation=operation, value=vector_or_value) def __add__(self, other): return self._math(other, 'ADD') @@ -92,6 +97,36 @@ def __mod__(self, other): def __rmod__(self, other): return self._math(other, 'MODULO', True) + def __floordiv__(self, other): + return self._math(other, 'DIVIDE')._math(None,'FLOOR') + + def __rfloordiv__(self, other): + return self._math(other, 'DIVIDE',True)._math(None,'FLOOR') + + def __pow__(self, other): + return self._math(other, 'POWER') + + def __rpow__(self, other): + return self._math(other, 'POWER', True) + + def __matmul__(self, other): + return self._math(other, 'DOT_PRODUCT') + + def __rmatmul__(self, other): + return self._math(other, 'DOT_PRODUCT', True) + + def __abs__(self): + return self._math(None,'ABSOLUTE') + + def __neg__(self): + return self._math(-1, 'MULTIPLY') + + def __pos__(self): + return self + + def __round__(self): + return self._math(None,'ROUND') + def _compare(self, other, operation): return geometry_script.compare(operation=operation, a=self, b=other)