|
1 | 1 | # GENERATED FILE - DO NOT EDIT |
2 | 2 | # This file is a stub for OmniGraph editor compatibility, and is not used by the Remix Runtime. |
3 | | -from __future__ import annotations |
4 | | - |
5 | | -from typing import TYPE_CHECKING |
6 | | - |
7 | 3 | import omni.graph.core as og |
8 | 4 |
|
9 | | -if TYPE_CHECKING: |
10 | | - from lightspeed.trex.logic.ogn.ogn.AddDatabase import AddDatabase |
| 5 | +from lightspeed.trex.logic.ogn._impl.type_resolution import resolve_types, standard_compute, standard_initialize |
11 | 6 |
|
12 | 7 |
|
13 | 8 | class Add: |
14 | | - @staticmethod |
15 | | - def compute(_db: AddDatabase): |
16 | | - return True |
| 9 | + # fmt: off |
| 10 | + VALID_COMBINATIONS = [ |
| 11 | + {"inputs:a": og.Type(og.BaseDataType.FLOAT), "inputs:b": og.Type(og.BaseDataType.FLOAT), "outputs:sum": og.Type(og.BaseDataType.FLOAT)}, |
| 12 | + {"inputs:a": og.Type(og.BaseDataType.FLOAT, 2), "inputs:b": og.Type(og.BaseDataType.FLOAT, 2), "outputs:sum": og.Type(og.BaseDataType.FLOAT, 2)}, |
| 13 | + {"inputs:a": og.Type(og.BaseDataType.FLOAT, 3), "inputs:b": og.Type(og.BaseDataType.FLOAT, 3), "outputs:sum": og.Type(og.BaseDataType.FLOAT, 3)}, |
| 14 | + {"inputs:a": og.Type(og.BaseDataType.FLOAT, 4), "inputs:b": og.Type(og.BaseDataType.FLOAT, 4), "outputs:sum": og.Type(og.BaseDataType.FLOAT, 4)}, |
| 15 | + ] |
| 16 | + # fmt: on |
| 17 | + |
| 18 | + compute = standard_compute |
| 19 | + initialize = standard_initialize |
17 | 20 |
|
18 | 21 | @staticmethod |
19 | 22 | def on_connection_type_resolve(node) -> None: |
20 | | - """Resolve flexible types based on connected attribute types.""" |
21 | | - # Valid type combinations for this component: |
22 | | - # Combination 1: a=float, b=float, sum=float |
23 | | - # Combination 2: a=float[2], b=float[2], sum=float[2] |
24 | | - # Combination 3: a=float[3], b=float[3], sum=float[3] |
25 | | - # Combination 4: a=float[4], b=float[4], sum=float[4] |
26 | | - |
27 | | - # Get attributes |
28 | | - input_a = node.get_attribute("inputs:a") |
29 | | - input_b = node.get_attribute("inputs:b") |
30 | | - output_sum = node.get_attribute("outputs:sum") |
31 | | - |
32 | | - # Get current types of connected attributes |
33 | | - type_a = input_a.get_resolved_type() |
34 | | - type_b = input_b.get_resolved_type() |
35 | | - |
36 | | - # Check all valid type combinations and resolve output types |
37 | | - if (type_a == og.Type(og.BaseDataType.FLOAT) and |
38 | | - type_b == og.Type(og.BaseDataType.FLOAT)): |
39 | | - output_sum.set_resolved_type(og.Type(og.BaseDataType.FLOAT)) |
40 | | - elif (type_a == og.Type(og.BaseDataType.FLOAT, 2) and |
41 | | - type_b == og.Type(og.BaseDataType.FLOAT, 2)): |
42 | | - output_sum.set_resolved_type(og.Type(og.BaseDataType.FLOAT, 2)) |
43 | | - elif (type_a == og.Type(og.BaseDataType.FLOAT, 3) and |
44 | | - type_b == og.Type(og.BaseDataType.FLOAT, 3)): |
45 | | - output_sum.set_resolved_type(og.Type(og.BaseDataType.FLOAT, 3)) |
46 | | - elif (type_a == og.Type(og.BaseDataType.FLOAT, 4) and |
47 | | - type_b == og.Type(og.BaseDataType.FLOAT, 4)): |
48 | | - output_sum.set_resolved_type(og.Type(og.BaseDataType.FLOAT, 4)) |
| 23 | + resolve_types(node, Add.VALID_COMBINATIONS) |
0 commit comments