Remove simulation inputs when deleting outputs and vice versa #106597

Merged
Member

To avoid unpaired simulation inputs or outputs, whenever deleting such
nodes the respective paired node should be deleted as well. A simple
utility function selects paired nodes before the delete operator removes
them.

This does not affect API methods, which still remove only individual
nodes. The feature is primarily a workflow improvement.

Resolves #105728

To avoid unpaired simulation inputs or outputs, whenever deleting such nodes the respective paired node should be deleted as well. A simple utility function selects paired nodes before the delete operator removes them. This does not affect API methods, which still remove only individual nodes. The feature is primarily a workflow improvement. Resolves #105728
Lukas Tönne added 1 commit 2023-04-05 17:25:38 +02:00
8e684c722a Remove simulation inputs when deleting outputs and vice versa.
To avoid "orphaned" simulation inputs or outputs, whenever deleting such
nodes the respective paired node should be deleted as well. A simple
utility function selects paired nodes before the delete operator removes
them.

This does not affect API methods, which still remove only individual
nodes. The feature is primarily a workflow improvement.

Resolves #105728
Lukas Tönne requested review from Jacques Lucke 2023-04-05 17:25:54 +02:00
Hans Goudey requested changes 2023-04-05 17:38:05 +02:00
Hans Goudey left a comment
Member

I think this is a reasonable approach to implement this. Just a few inline comments.

I think this is a reasonable approach to implement this. Just a few inline comments.
@ -193,0 +193,4 @@
/**
* Select nodes that are paired to a selected node.
*/
void node_select_paired(bNodeTree *node_tree);
Member

Use a reference rather than a pointer if node_tree is expected to be non-null.

Use a reference rather than a pointer if `node_tree` is expected to be non-null.
LukasTonne marked this conversation as resolved
@ -310,1 +310,4 @@
void node_select_paired(bNodeTree *node_tree)
{
for (bNode *node : node_tree->all_nodes()) {
Member

Rather than looping over all nodes, this could use nodes_by_type at the start too. That makes sense, since there are plenty of large node trees that don't use simulation nodes (or any paired nodes) at all, and it reduces reliance on bNode::type, which would be good to remove eventually.

Rather than looping over all nodes, this could use `nodes_by_type` at the start too. That makes sense, since there are plenty of large node trees that don't use simulation nodes (or any paired nodes) at all, and it reduces reliance on `bNode::type`, which would be good to remove eventually.
LukasTonne marked this conversation as resolved
@ -311,0 +311,4 @@
void node_select_paired(bNodeTree *node_tree)
{
for (bNode *node : node_tree->all_nodes()) {
if (node->flag & NODE_SELECT) {
Member

It usually makes sense to flip the condition and use continue rather than indenting the rest of the function, I'd say that applies here too.

It usually makes sense to flip the condition and use `continue` rather than indenting the rest of the function, I'd say that applies here too.
LukasTonne marked this conversation as resolved
@ -311,0 +313,4 @@
for (bNode *node : node_tree->all_nodes()) {
if (node->flag & NODE_SELECT) {
if (node->type == GEO_NODE_SIMULATION_INPUT) {
NodeGeometrySimulationInput *storage = static_cast<NodeGeometrySimulationInput *>(
Member

NodeGeometrySimulationInput * -> const NodeGeometrySimulationInput *

Here and below

`NodeGeometrySimulationInput *` -> `const NodeGeometrySimulationInput *` Here and below
LukasTonne marked this conversation as resolved
Hans Goudey changed title from Remove simulation inputs when deleting outputs and vice versa. to Remove simulation inputs when deleting outputs and vice versa 2023-04-05 17:38:25 +02:00
Lukas Tönne added 3 commits 2023-04-05 18:01:19 +02:00
Jacques Lucke approved these changes 2023-04-05 18:25:56 +02:00
Jacques Lucke requested review from Hans Goudey 2023-04-05 18:26:06 +02:00
Lukas Tönne merged commit c6d8da0e97 into geometry-nodes-simulation 2023-04-05 18:28:47 +02:00
Lukas Tönne deleted branch geometry-nodes-simulation-remove-paired 2023-04-05 18:28:49 +02:00
Sign in to join this conversation.
No reviewers
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#106597
No description provided.