internal_containers.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from .node_container_common import *
  2. from bpy.types import Node
  3. from .base_definitions import MantisNode
  4. from uuid import uuid4
  5. class DummyNode(MantisNode):
  6. def __init__(self, signature, base_tree, prototype = None, ui_signature=None):
  7. super().__init__(signature, base_tree)
  8. self.prototype = prototype
  9. self.node_type = 'DUMMY'
  10. self.prepared = True
  11. self.uuid = uuid4()
  12. self.solver = None
  13. if prototype:
  14. if prototype.bl_idname in ["MantisSchemaGroup"]:
  15. self.node_type = 'DUMMY_SCHEMA'
  16. self.prepared = False
  17. for sock in prototype.inputs:
  18. if sock.identifier == "__extend__" or sock.name == "__extend__":
  19. continue
  20. self.inputs[sock.identifier] = NodeSocket(is_input = True, name = sock.identifier, node = self)
  21. for sock in prototype.outputs:
  22. if sock.identifier == "__extend__" or sock.name == "__extend__":
  23. continue
  24. self.outputs[sock.identifier] = NodeSocket(is_input = False, name = sock.identifier, node = self)
  25. self.parameters[sock.identifier]=None
  26. # keep track of the "natural signature" of Schema nodes - so that they are unambiguous
  27. self.ui_signature=self.signature
  28. if ui_signature:
  29. self.ui_signature=ui_signature
  30. # This is necessary for Schema to work if there are multiple Schema nodes using the same Schema tree.
  31. # this is ugly and I hate it.
  32. self.execution_prepared=True # in case it gets left behind in the tree as a dependency
  33. class NoOpNode(MantisNode):
  34. def __init__(self, signature, base_tree):
  35. super().__init__(signature, base_tree)
  36. self.inputs.init_sockets(["Input"])
  37. self.outputs.init_sockets(["Output"])
  38. self.init_parameters()
  39. self.set_traverse([("Input", "Output")])
  40. self.node_type = 'UTILITY'
  41. self.prepared = True
  42. self.executed = True
  43. # this node is useful for me to insert in the tree and use for debugging especially connections.
  44. class AutoGenNode(MantisNode):
  45. def __init__(self, signature, base_tree):
  46. super().__init__(signature, base_tree)
  47. self.node_type = 'UTILITY'
  48. self.prepared, self.executed = True, True
  49. def reset_execution(self):
  50. super().reset_execution()
  51. self.prepared, self.executed = True, True