BKE_lib_query: Add a partial ID usage iterator system. #121018
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#121018
Loading…
Reference in New Issue
No description provided.
Delete Branch "mont29/blender:tmp-libquery-subdata-foreachid"
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?
The idea is to allow iterating over e.g. all ID usages of a node from a
whole nodetree, using the same generic handling as existing 'whole ID'
foreach_id
code.This is necessary in some cases wher a sub-data needs to processed
independently from any 'owner ID', e.g. in some copy/paste handling.
This is a pre-requirement for proper fix of nodes copy/paste (see
e.g. #120103).
@blender-bot build
@ -1420,0 +1424,4 @@
*
* See BKE_lib_query.hh and #IDTypeInfo.foreach_id for more details.
*/
void node_node_foreach_id(bNode *node, LibraryForeachIDData *data);
Not very happy with this name, but since the
node_
prefix is used everywhere when processing a whole nodetree...@ -0,0 +290,4 @@
}
return IDWALK_RET_NOP;
};
BKELibraryForeachSubdataID().operator()<bNode>(context.test_data.bmain,
Not sure why, but the implicit template type deduction does not work here.
Makes me wonder if keeping the 'function call' operator is worth it, or if it would not be better to use a 'normal' template method.
All review is of course welcome, but am mostly looking for validation of the 'template' approach here, and/or for better ideas?
The idea of using a templated function (instead of just passing
void *
pointers around) is to improve type safety and such, but I was a bit disappointed to find out how much of a pain it was to get it to work... And I can't say I find current code nice & elegant at all.I think it's possible to simplify this by just using a function:
It's kind of unnecessary to have the template parameter in the current code, because
self_id_subdata
is only forwarded intosubdata_foreach_id
anyway. Instead,self_id_subdata
could just be captured as part of theFunctionRef
already.a5c162dd40
to9ba27dd216
@JacquesLucke Not sure I understand your suggestion... How would the sub-data parameter be captured here?
I can see how to do it if using a 'wrapping' lambda, but this would be moving more work (and 'obfuscation' of code) to caller code, which I would rather avoid...
I can't seem to find any doc or example of how a
FunctionRef
itself could capture and forward parameters?I indeed mean the approach with the wrapping lambda. Seems like a more general solution. The current code expects a very specific signature of the
node_node_foreach_id
function, which also doesn't seem very obvious.I think
BKE_library_foreach_subdata
(or similar) does not have to know about the exact sub-data that one wants to iterate over. E.g. I imagine that a single call to that function could be used to iterate over all IDs referenced by multiple nodes, or some other potentially more complex filter where a single pointer to the sub-data is not enough.9ba27dd216
to9daceb581c
@JacquesLucke Ah in that sens it makes sense... Updated the PR now.
WIP: BKE_lib_query: Add a partial ID usage iterator system.to BKE_lib_query: Add a partial ID usage iterator system.9daceb581c
to026357c3c7
@ -271,2 +271,4 @@
/**
* Loop over all of the ID's this data-block links to.
*
* @param bmain The Main data-base containing `owner_id`, may be null.
@param bmain
->\param bmain:
@param bmain
->\param bmain:
That's the syntax used elsewhere in Blender, might as well be consistent.
@ -278,1 +285,4 @@
int flag);
/**
* Apply `callback` to all ID usages of the data as dfined by `subdata_foreach_id`. Useful to e.g.
dfined
->defined
@blender-bot build
@ -402,0 +411,4 @@
BLI_assert((flag & (IDWALK_RECURSE | IDWALK_DO_INTERNAL_RUNTIME_POINTERS |
IDWALK_DO_LIBRARY_POINTER | IDWALK_INCLUDE_UI)) == 0);
LibraryForeachIDData data;
While testing #121122 I found that this is missing
{}
to zero initialize the data.The issue was that
cb_flag_clear
is uninitialized which caused wrong behavior sometimes.To clarify,
LibraryForeachIDData data{};
is enough to default initialize everything in the struct.@blender-bot build