godot-orchestrator
godot-orchestrator copied to clipboard
Have a single node for mathematical operations that adapts to its input
Description
Right now we have a lot of dedicated nodes that handle all the basic mathematical operations in all their various flavours. This has two problems. First, it makes it rather cumbersome to find the correct operation because even if you exactly type "Vector3 Multiply Vector" you get a lot of results:
Second, If you realize you picked the wrong one, you have to delete the node and search for the right one again. It would be much nicer if there was just a single operator node for each operation, that automatically adjusts its input and outputs depending on what is connected. E.g. Vector3 * float yields Vector3, Vector3 * Vector3 yields Vector3, float * float yields float:
https://github.com/user-attachments/assets/8c4c4c9e-1710-4d82-89e2-b3c9ecbc9779
This operator node could then also have convenience functions like switching to a different operator (e.g. ==, <, > , * ,etc.) or flipping the inputs:
https://github.com/user-attachments/assets/6c1d4141-02b1-4339-8efb-ea298dd164e5
Implementation ideas
No response
This specific feature is somewhat isolated and could easily be worked in parallel to the current refactor.
For this, I would suggest creating a new class OScriptNodePromotableOperator that extends OScriptEditablePinNode. We have a few ways to drive the compatibility logic, but my suggestion is to use the ExtensionDB.
In the ExtensionDB, we have a set of OperationInfo structs you can pull that drive what you already see in terms of what operators are available and for what variant types. We can use these inside the node's _bind_methods() static call so that we only pay this cost in the graph once, and we can also reuse that mapping at runtime if needed.
I suggest a new node class for several reasons:
- Minimizes upgrade risk (keeps all changes in a new node type)
- Use a toggle to enable the new Promotable Operator nodes and hide the older ones by default.