From a3337dbdbf36fad51cc03773c8a4716d24ae187c Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Mon, 28 Nov 2022 17:32:21 -0500 Subject: [PATCH] Improve invert and linking logic --- api/node_mapper.py | 14 ++++++++++---- api/types.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/api/node_mapper.py b/api/node_mapper.py index 531283e..1f173e9 100644 --- a/api/node_mapper.py +++ b/api/node_mapper.py @@ -42,11 +42,16 @@ def build_node(node_type): if issubclass(type(x), Type): State.current_node_tree.links.new(x._socket, node_input) else: - try: - node_input.default_value = x - except: + def link_constant(): constant = Type(value=x) State.current_node_tree.links.new(constant._socket, node_input) + if node_input.hide_value: + link_constant() + else: + try: + node_input.default_value = x + except: + link_constant() value = kwargs[argname] if isinstance(value, enum.Enum): value = value.value @@ -331,7 +336,8 @@ class Type: x = Type() y = Type() z = Type() - def capture(self, attribute: Type, **kwargs) -> Callable[[], Type]: return transfer_attribute + def capture(self, attribute: Type, **kwargs) -> (Geometry, Type): return Geometry(), Type() + def transfer(self, attribute: Type, **kwargs) -> Type: return Type() {(newline + ' ').join(map(add_self_arg, filter(lambda x: x.startswith('def'), symbols)))} {newline.join(map(type_symbol, Type.__subclasses__()))} diff --git a/api/types.py b/api/types.py index 576c169..51570b7 100644 --- a/api/types.py +++ b/api/types.py @@ -151,7 +151,7 @@ class Type(metaclass=_TypeMeta): if self._socket.type == 'BOOLEAN': return self._boolean_math(None, 'NOT') else: - return self._math(-1, 'MULTIPLY') + return self._math((-1, -1, -1) if self._socket.type == 'VECTOR' else -1, 'MULTIPLY') def _get_xyz_component(self, component): if self._socket.type != 'VECTOR':