Support for simulation zones in copy operators #106812
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#106812
Loading…
Reference in New Issue
No description provided.
Delete Branch "LukasTonne/blender:geometry-nodes-simulation-copy-support"
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?
Copying a simulation zone should keep the 1:1 pairing intact (see
remap_pairing
functions)output_node_id
property of the simulation input node, so that it is paired with the output copy.There are a couple of places where copies happen:
These copy operators do mostly the same thing, but in slightly different ways, which makes the code incompatible (e.g. using a
Map<const bNode *, bNode *> node_map
vs.Map<bNode *, bNode *> node_map
). That's why there are 3remap_pairing
implementations.Dynamic node declarations are problematic:
Copying nodes invokes
nodeDeclarationEnsure
to generate declarations for new nodes. It does not, however, change the socket lists. If a dynamic declaration for a node copy alters the sockets (in this case: remove all because the node is unpaired), the subsequentupdate_socket_declarations
will crash because it expects sockets to match the declaration.At the end of operators there is usually a
BKE_ntree_update_main
or similar, which invokesupdate_node_declaration_and_sockets
. This method does update the socket lists as well (see #106732), but only if a node is tagged for a respective update.The solution here is to use
update_node_declaration_and_sockets
for dynamic declarations instead of justbuild_node_declaration_dynamic
.Fixes #106732
@ -3819,3 +3819,2 @@
BLI_assert(node != nullptr);
node->runtime->declaration = new blender::nodes::NodeDeclaration();
blender::nodes::build_node_declaration_dynamic(*ntree, *node, *node->runtime->declaration);
blender::nodes::update_node_declaration_and_sockets(*ntree, *node);
This is to ensure sockets are updated to match dynamic declarations.
@ -237,10 +266,6 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
}
}
for (bNode *new_node : node_map.values()) {
Changing socket layout too early causes the
socket_map
to become invalid. So this section has been moved down beyond the link remapping section.This section was originally in
node_copy_with_mapping
(see f36dd0660983). It was moved out of the primary node duplication loop so that the simulation input could build its declaration based on the copy of the output node.Same applies in "Duplicate" and "Group Separate" operators below.
"Group Separate" operator is technically not correct because it copies nodes from the group tree, then potentially updates their ID values, then uses the old ID values to reconstruct links in the new tree. In practice this is unlikely to cause problems because IDs are random
uint32_t
numbers and almost never collide, so the copied nodes will almost always have the same IDs as the original nodes."Make Group" and "Ungroup" operators will currently unpair simulation nodes because they simply move the nodes to a different tree. Then the nodes get new random IDs, which means the
output_node_id
will almost certainly be incorrect, effectively un-pairing the simulation nodes.Worked perfectly in all my tests. Feels much better now than before :)
@ -185,0 +188,4 @@
{
/* We don't have the old tree for looking up output nodes by ID,
* so have to build a map first to find copied output nodes in the new tree. */
Map<uint32_t, bNode *> dst_output_node_map;
Use
int32_t
instead ofuint32_t
for node identifiers.Oh, somehow thought the identifiers were
uint32_t
, my bad.@ -439,0 +444,4 @@
dst_node->storage);
/* XXX Technically this is not correct because the output_node_id is only valid
* in the original node group tree and we'd have map old IDs to new nodes first.
* The ungroup operator does not build a node map, it just expects node IDs to
Based on the comment it sounds like the proper solution would be to build the node map. Is there a reason for not just doing that instead of using a solution you already know might not work?
I'd consider that a separate task, to fix the group separate operator. Ideally would also unify all the other copy operators. It is extremely unlikely this would cause problems in practice because of the randomness of identifiers. Relying on randomness and expecting that the identifier method remains unchanged is bad of course.
I've added a new task for this #106852
The patch still uses
uint32_t
in two places (one of those is in a comment), that should still be fixed.I'm not sure how I feel about adding three implementations of
remap_pairing
. It seems like they could be unified by creating aMap<int32_t, int32_t>
when copying node groups instead of the various set/map types we currently use. If you plan to work on #106852 in the near future, we could still commit this now, but otherwise I think it would make more sense for that unification to happen first, better not to leave it like this longer term.I'll give the copy unification #106852 a go and see if i run into any major obstacles.