Add simulation input and output node as a pair #106557
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#106557
Loading…
Reference in New Issue
No description provided.
Delete Branch "LukasTonne/blender:geometry-nodes-simulation-add-pair"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Simulation input and output nodes are currently added individually, but they always need to exist as pair. This PR modifies the Add Node menu so that a single menu entry adds and input and output node together.
The
NODE_OT_add_node
operator currently adds just a single node type. A new variant of this operator is added which adds a simulation zone with origin + target node instead. This requires some modification of theNodeAddOperator
base class, moving thenode_type
property into the final implementation. Unlike theNODE_OT_add_node
operator, theNODE_OT_add_simulation_zone
adds 2 different node types.After adding the two nodes, a reference needs to be added to "pair" them: Input node ("origin") stores the UID of the output node ("target") in its
output_node_id
property. So far this was detected automatically when adding an input, but this method is not very robust (e.g. it depends on order of adding nodes and adding multiple pairs can be tricky).Now the pairing is done explicitly through an API function
node_geo_simulation_input_pair_with_output
. TheNODE_OT_add_simulation_zone
operator performs pairing of the input/output nodes after adding them. The function is accessible through RNA, so an operator may be added if necessary to allow users to fix unpaired nodes.In addition to pairing the two nodes, the operator also positions them at a comfortable distance, as well as adding a default link between the two Geometry sockets for convenience.
Resolves #105727
Does that also work if I add the pair via the Python API without using an operator? e.g., by using: my_node_group.nodes.add.new("GeometryNodeSimulation")
No, the
nodes.new
function just takes a single actual node type. You can, however, do what the menu entry does and add an input, an output, and then pair the two nodes:Thanks, the behavior looks good. I'd change
Simulation Nodes
to justSimulation
orSimulation Zone
(haven't made up my mind yet).Implementation wise it feels like adding
NODE_OT_add_node_pair
instead of e.g.NODE_OT_add_simulation_zone
is premature abstraction and feels like this abstraction won't hold up for long (especially since it has simulation nodes specific behavior already). I think this patch could be a fair amount simpler by not trying to abstract away adding a node pair. Once we add e.g.NODE_OT_add_parallel_loop_zone
we can potentially extract common functionality into utility functions (instead of having a single operator for both).The new
pair_with_output
method in rna and its implementation seem reasonable.Regarding the constructor of
LazyFunctionForSimulationInputNode
, I think it would be better to only get to that place when it is known that the simulation zone is complete, hence the validity of the zone should probably be checked inhandle_simulation_input_node
already (also seehandle_group_node
for how it handles error conditions). This simplifies the code there because it doesn't have to handle the case anymore.Also note that, while this has to be done at some point, it's not a change that has to be included in this patch, because it's kind of unrelated to adding the simulation zone.
I'd prefer just "Simulation", IMO "zone" is too much of an implementation detail.
Yeah, i wasn't sure about that, didn't like to hardcode node types into the operator. I'm ok with making the operator just for the input sim too. Do we have an idea if this zone concept will be carried over to general loops eventually?
Ok, but i did noticed it crashes very easily when e.g. removing one node. I think it needs to be made robust soon, so pairing isn't always just expected to be valid. Can add a separate PR for that.
I'm fine with that for now, but note that the purpose of finding a name for zones was explicitly so that we and users can talk about them instead of having to make up different names all the time. Using the term "Zone" in the menu can be a good teaching moment.
Hardcoding node types into operators is totally fine if the purpose of the operator is to add that node.
There will likely be different types of loops, so I don't know what a "general loop" is for you. Either way, yes I think it's very likely that the we will use the zone concept for those as well.
Made a separate PR for checking the output is valid before creating the LF #106585
Got some minor comments inline, but looks good now, thx.
@ -149,2 +159,4 @@
bl_label = "Add Simulation Zone"
bl_options = {'REGISTER', 'UNDO'}
origin_type = "GeometryNodeSimulationInput"
Would call it
input_node_type
.@ -151,0 +180,4 @@
if origin_node is None or target_node is None:
return {'CANCELLED'}
# Simulation input must be paired with the output
End comments with a dot.
@ -207,2 +185,4 @@
nodeRegisterType(&ntype);
}
bool node_geo_simulation_input_pair_with_output(bNode *simulation_input_node,
Should probably also fail in the case when trying to connect an output to an input that is already linked to another input.
@ -207,2 +185,4 @@
nodeRegisterType(&ntype);
}
bool node_geo_simulation_input_pair_with_output(bNode *simulation_input_node,
Right now you can easily cause an ambiguous situation by e.g. duplicating a sim input node. The duplicate then has the same
output_node_id
so it's paired with the same output node But that doesn't make much sense because which input node then defines the initial state?We should also make sure the input node's
output_node_id
is cleared when duplicating the node, copy&pasting, etc. I think the storagecopyfunc
should be able to take care of that. Then any new input node is unpaired by default.@ -207,2 +185,4 @@
nodeRegisterType(&ntype);
}
bool node_geo_simulation_input_pair_with_output(bNode *simulation_input_node,
I think short- to mid-term we should disallow copying only a simulation input or output node. For the most part, the ui should treat those as one.
I think the copy operator should take care of updating the
output_node_id
. It should be set to zero in other cases. We just have to make sure that we don't clear it when making the copy for the depsgraph (or when copying the entire node tree).I'm find with solving all of that after this patch is committed.