Geometry Nodes: Update node tool menus dynamically #112166

Merged
Hans Goudey merged 11 commits from HooglyBoogly/blender:node-operator-catalog-update into main 2023-09-14 17:43:40 +02:00
Member

See #101778

Remove the requirement of restarting Blender to refresh the
extended 3D view menus for node group changes. Also avoid
rebuilding the tree of relevant assets and catalogs on every
redraw, since parsing asset libraries, etc. could become more
expensive than we want. Those two goals combined mean we
have to be more rigorous in how we invalidate the cached
catalog tree.

The first main change required is to clear the tree as asset libraries
are being read, similar to other dynamic asset menus. This is done
with a 3D view header listener rather than a menu listener in this case.

However, that isn't enough, because there is an issue with the asset
system where the "all" library isn't updated when the current file library
changes. The solution here needs iteration, but two options are calling
AS_asset_library_load, or eagerly rebuilding the all library after asset
catalog changes.

The other necessity for dynamic updates is clearing the catalog tree
to be rebuilt when the node group "asset traits" are changed. This is
done with a new notifier type (with the goal of being a bit selective
about when we re-read assets). This also requires running the
"presave" callback that builds asset metadata when updating the
property. Otherwise saving the file and sending the notifier is
necessary, which is too confusing.


I would like feedback on the two solutions to the issue with the "all"
asset library and on the method of updating asset metadata on
property changes.

See #101778 Remove the requirement of restarting Blender to refresh the extended 3D view menus for node group changes. Also avoid rebuilding the tree of relevant assets and catalogs on every redraw, since parsing asset libraries, etc. could become more expensive than we want. Those two goals combined mean we have to be more rigorous in how we invalidate the cached catalog tree. The first main change required is to clear the tree as asset libraries are being read, similar to other dynamic asset menus. This is done with a 3D view header listener rather than a menu listener in this case. However, that isn't enough, because there is an issue with the asset system where the "all" library isn't updated when the current file library changes. The solution here needs iteration, but two options are calling `AS_asset_library_load`, or eagerly rebuilding the all library after asset catalog changes. The other necessity for dynamic updates is clearing the catalog tree to be rebuilt when the node group "asset traits" are changed. This is done with a new notifier type (with the goal of being a bit selective about when we re-read assets). This _also_ requires running the "presave" callback that builds asset metadata when updating the property. Otherwise saving the file and sending the notifier is necessary, which is too confusing. --- I would like feedback on the two solutions to the issue with the "all" asset library and on the method of updating asset metadata on property changes.
Hans Goudey added 4 commits 2023-09-09 00:27:46 +02:00
Hans Goudey requested review from Julian Eisel 2023-09-09 00:29:23 +02:00
Hans Goudey added this to the 4.0 milestone 2023-09-09 00:29:27 +02:00
Hans Goudey added this to the Nodes & Physics project 2023-09-09 00:30:17 +02:00
Member

The first main change required is to clear the tree as asset libraries are being read, similar to other dynamic asset menus. This is done with a 3D view header listener rather than a menu listener in this case.

Seems reasonable. The UI should listen to updates and redraw when needed.

However, that isn't enough, because there is an issue with the asset system where the "all" library isn't updated when the current file library changes. The solution here needs iteration, but two options are calling AS_asset_library_load, or eagerly rebuilding the all library after asset catalog changes.

Think this should be handled by the asset system internally. So the all library should be updated to reflect the changes. We only need to rebuild the catalog tree, right? Should be fine.

The other necessity for dynamic updates is clearing the catalog tree to be rebuilt when the node group "asset traits" are changed. This is done with a new notifier type (with the goal of being a bit selective about when we re-read assets).

Seems fine as well.

This also requires running the "presave" callback that builds asset metadata when updating the property. Otherwise saving the file and sending the notifier is necessary, which is too confusing.

Instead of calling the presave callback, it's nicer to just have a regular function doing this that the presave callback can call.

> The first main change required is to clear the tree as asset libraries are being read, similar to other dynamic asset menus. This is done with a 3D view header listener rather than a menu listener in this case. Seems reasonable. The UI should listen to updates and redraw when needed. > However, that isn't enough, because there is an issue with the asset system where the "all" library isn't updated when the current file library changes. The solution here needs iteration, but two options are calling AS_asset_library_load, or eagerly rebuilding the all library after asset catalog changes. Think this should be handled by the asset system internally. So the all library should be updated to reflect the changes. We only need to rebuild the catalog tree, right? Should be fine. > The other necessity for dynamic updates is clearing the catalog tree to be rebuilt when the node group "asset traits" are changed. This is done with a new notifier type (with the goal of being a bit selective about when we re-read assets). Seems fine as well. > This also requires running the "presave" callback that builds asset metadata when updating the property. Otherwise saving the file and sending the notifier is necessary, which is too confusing. Instead of calling the presave callback, it's nicer to just have a regular function doing this that the presave callback can call.
Hans Goudey added 3 commits 2023-09-12 23:16:54 +02:00
Member

The AS_asset_library_rebuild_all() calls is not exactly what I meant. I think when calling functions affecting the catalog tree the asset system (as in, code under blender/asset_system) should make sure this is respected somehow. Not sure if it would immediately rebuild the tree, or set some flag to do the update later (some lazy update?).
I much prefer this to be handled internally as this is a data-update (not UI). I rather avoid explicit update function calls, they are brittle.

The `AS_asset_library_rebuild_all()` calls is not exactly what I meant. I think when calling functions affecting the catalog tree the asset system (as in, code under `blender/asset_system`) should make sure this is respected somehow. Not sure if it would immediately rebuild the tree, or set some flag to do the update later (some lazy update?). I much prefer this to be handled internally as this is a data-update (not UI). I rather avoid explicit update function calls, they are brittle.
Hans Goudey added 2 commits 2023-09-14 14:47:24 +02:00
Julian Eisel reviewed 2023-09-14 15:32:52 +02:00
@ -198,0 +198,4 @@
void AssetLibraryService::rebuild_all_library()
{
if (all_library_) {
rebuild_all_library_ex(*all_library_, true);
Member

I don't think catalogs should be reloaded after these changes? Keeping the catalog data updated is already done, I think we just care about updating the tree.

I don't think catalogs should be reloaded after these changes? Keeping the catalog data updated is already done, I think we just care about updating the tree.
HooglyBoogly marked this conversation as resolved
Hans Goudey added 1 commit 2023-09-14 15:56:16 +02:00
Julian Eisel approved these changes 2023-09-14 17:33:22 +02:00
Hans Goudey added 1 commit 2023-09-14 17:42:15 +02:00
Hans Goudey merged commit cc83951951 into main 2023-09-14 17:43:40 +02:00
Hans Goudey deleted branch node-operator-catalog-update 2023-09-14 17:43:42 +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 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#112166
No description provided.