Fix #112331: Add update tags directly in bNodeTreeInterface API methods #111741

Merged
Lukas Tönne merged 11 commits from LukasTonne/blender:tree-interface-update-tags into main 2023-09-14 14:13:15 +02:00
Member

Calling an API function after the node panels patch does not internally
tag the node tree with NTREE_CHANGED_INTERFACE any more, because the
node tree is not directly accessible from bNodeTreeInterface. Before
node panels the API functions for interfaces could tag the tree directly
for later update consideration, which now requires explicit tagging
calls.

The fix is to add a flag and mutex directly to bNodeTreeInterface, so
API methods can tag after updates. This mostly copies runtime data
concepts from bNodeTree. The ensure_interface_cache method is
equivalent to ensure_topology_cache and should be called before
accessing interface_inputs and similar cache data.

Calling an API function after the node panels patch does not internally tag the node tree with `NTREE_CHANGED_INTERFACE` any more, because the node tree is not directly accessible from `bNodeTreeInterface`. Before node panels the API functions for interfaces could tag the tree directly for later update consideration, which now requires explicit tagging calls. The fix is to add a flag and mutex directly to `bNodeTreeInterface`, so API methods can tag after updates. This mostly copies runtime data concepts from `bNodeTree`. The `ensure_interface_cache` method is equivalent to `ensure_topology_cache` and should be called before accessing `interface_inputs` and similar cache data.
Lukas Tönne added 1 commit 2023-08-31 14:06:36 +02:00
Calling an API function after the node panels patch does not internally
tag the node tree with `NTREE_CHANGED_INTERFACE` any more, because the
node tree is not directly accessible from `bNodeTreeInterface`. Before
node panels the API functions for interfaces could tag the tree directly
for later update consideration, which now requires explicit tagging
calls.

The fix is to add a flag and mutex directly to `bNodeTreeInterface`, so
API methods can tag after updates. This mostly copies runtime data
concepts from `bNodeTree`. The `ensure_interface_cache` method is
equivalent to `ensure_topology_cache` and should be called before
accessing `interface_inputs` and similar cache data.
Lukas Tönne added this to the Nodes & Physics project 2023-08-31 14:06:42 +02:00
Lukas Tönne requested review from Hans Goudey 2023-08-31 14:06:59 +02:00
Lukas Tönne added 2 commits 2023-08-31 15:53:39 +02:00
Lukas Tönne added 1 commit 2023-08-31 15:54:38 +02:00
Merge branch 'main' into tree-interface-update-tags
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.
0cc278785f
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey requested changes 2023-08-31 15:58:30 +02:00
Hans Goudey left a comment
Member

Generally looks nice! My one large comment is that it probably makes more sense for bNodeTreeInterfaceRuntime to just be a storage of runtime data. It shouldn't need any methods of its own. That's how MeshRuntime and CurvesGeometryRuntime are handled, and I think it makes sense, because the only reason we have a separate runtime struct is because DNA doesn't handle storing the data directly in the struct.

Generally looks nice! My one large comment is that it probably makes more sense for `bNodeTreeInterfaceRuntime` to just be a _storage_ of runtime data. It shouldn't need any methods of its own. That's how `MeshRuntime` and `CurvesGeometryRuntime` are handled, and I think it makes sense, because the only reason we have a separate runtime struct is because DNA doesn't handle storing the data directly in the struct.
@ -1109,2 +1131,4 @@
parent->insert_item(new_socket->item, position);
}
tag_items_changed();
Member

Functions in the class should be prefixed with this-> to make that clear (same reason we use the this-> prefix for non-private class variables).

Functions in the class should be prefixed with `this->` to make that clear (same reason we use the `this->` prefix for non-private class variables).
LukasTonne marked this conversation as resolved
@ -1270,27 +1312,70 @@ void bNodeTreeInterface::foreach_id(LibraryForeachIDData *cb)
item_types::item_foreach_id(cb, root_panel.item);
}
Member

This indirection doesn't seem necessary IMO. It would probably be simpler to just put the contents of bNodeTreeInterfaceRuntime::ensure_items_cache in here. That's also how it works for the geometry caches. The runtime struct just serves as storage for the cached data, it doesn't contain any functionality.

EDIT: I wrote more about this in the top-level review comment.

This indirection doesn't seem necessary IMO. It would probably be simpler to just put the contents of `bNodeTreeInterfaceRuntime::ensure_items_cache` in here. That's also how it works for the geometry caches. The runtime struct just serves as storage for the cached data, it doesn't contain any functionality. EDIT: I wrote more about this in the top-level review comment.
LukasTonne marked this conversation as resolved
@ -396,0 +414,4 @@
*/
void tag_items_changed();
protected:
Member

Maybe private instead of protected? Not sure this will be used as a base class ever.

Maybe `private` instead of `protected`? Not sure this will be used as a base class ever.
Member

Seems to still say protected here

Seems to still say `protected` here
LukasTonne marked this conversation as resolved
Lukas Tönne changed title from Add update tags directly to bNodeTreeInterface to enable tagging by API to Fix #111741: Add update tags directly in bNodeTreeInterface API methods 2023-09-13 17:18:45 +02:00
Lukas Tönne changed title from Fix #111741: Add update tags directly in bNodeTreeInterface API methods to Fix #112331: Add update tags directly in bNodeTreeInterface API methods 2023-09-13 17:19:11 +02:00
Lukas Tönne added 1 commit 2023-09-13 17:33:09 +02:00
Lukas Tönne added 1 commit 2023-09-13 18:04:20 +02:00
Author
Member

My one large comment is that it probably makes more sense for bNodeTreeInterfaceRuntime to just be a storage of runtime data.

I moved almost all methods out of the runtime into the bNodeTreeInterface itself now. I've kept the items/inputs/outputs span accessors because of the interface_items/interface_inputs/interface_outputs methods in bNodeTree. This way i can keep the runtime private with friend access only for the bNodeTreeInterface.

> My one large comment is that it probably makes more sense for bNodeTreeInterfaceRuntime to just be a storage of runtime data. I moved almost all methods out of the runtime into the `bNodeTreeInterface` itself now. I've kept the `items`/`inputs`/`outputs` span accessors because of the `interface_items`/`interface_inputs`/`interface_outputs` methods in `bNodeTree`. This way i can keep the runtime private with friend access only for the `bNodeTreeInterface`.
Hans Goudey reviewed 2023-09-13 19:23:53 +02:00
@ -27,0 +27,4 @@
/**
* Keeps track of what changed in the node tree until the next update.
* Should not be changed directly, instead use the functions in `BKE_node_tree_update.h`.
* #eNodeTreeChangedFlag.
Member

NodeTreeInterfaceChangedFlag

`NodeTreeInterfaceChangedFlag`
LukasTonne marked this conversation as resolved
@ -27,0 +44,4 @@
Vector<bNodeTreeInterfaceSocket *> outputs_;
public:
blender::Span<bNodeTreeInterfaceItem *> items() const
Member

Are the public methods still necessary with friend bNodeTreeInterface? I'd think they could just be accessed directly there.

Are the public methods still necessary with `friend bNodeTreeInterface`? I'd think they could just be accessed directly there.
Author
Member

They are accessed from bNodeTree::interface_inputs etc. Of course i can also make bNodeTree a friend too ...

They are accessed from `bNodeTree::interface_inputs` etc. Of course i can also make bNodeTree a friend too ...
Member

Ah I see, I think that makes sense

Ah I see, I think that makes sense
LukasTonne marked this conversation as resolved
@ -1049,1 +1066,4 @@
item_types::item_read_data(reader, this->root_panel.item);
this->runtime = MEM_new<blender::bke::bNodeTreeInterfaceRuntime>(__func__);
tag_missing_runtime_data();
Member

Missing this-> for member function calls.

Missing `this->` for member function calls.
LukasTonne marked this conversation as resolved
Lukas Tönne added 4 commits 2023-09-14 10:40:19 +02:00
Lukas Tönne added 1 commit 2023-09-14 10:41:47 +02:00
Merge branch 'main' into tree-interface-update-tags
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.
db908e9fae
Author
Member

@blender-bot build

@blender-bot build
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey approved these changes 2023-09-14 13:49:42 +02:00
Lukas Tönne merged commit d2f4ebcd6a into main 2023-09-14 14:13:15 +02:00
Lukas Tönne deleted branch tree-interface-update-tags 2023-09-14 14:13:16 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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 Assignees
2 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#111741
No description provided.