Node Tools: Basic support for data-block inputs #121148

Merged
Hans Goudey merged 3 commits from HooglyBoogly/blender:node-tools-id-inputs into main 2024-04-29 03:47:46 +02:00
Member

Currently support for data-block inputs is disabled because pointer
properties in operator properties aren't properly handled in Blender
(for more info, see 871c717c6e). This commit brings basic
support for them by storing strings (data-block names) in the operator
properties instead. The main downside of using strings compared other
theoretical solutions is that data-blocks from different library files
can have the same name. This solution won't work well for those cases.
However, it still brings a lot of utility to node tools for a relatively
simple code change.

I investigated two other solutions for this that didn't work out. Using
the recently added enum custom property support didn't work because
the data-block names would still have to be unique. Plus generating an
enum would require a bunch of boilerplate code. Extending the existing
button search code to handle integer session UID backed data-blocks was
much trickier than I expected. The code there is already quite spagetti-
like, and things got out of hand quickly. That's still valid future work
though. The implementation can be changed without breaking
compatibility of files.


image

Currently support for data-block inputs is disabled because pointer properties in operator properties aren't properly handled in Blender (for more info, see 871c717c6ec2b869c8de). This commit brings basic support for them by storing strings (data-block names) in the operator properties instead. The main downside of using strings compared other theoretical solutions is that data-blocks from different library files can have the same name. This solution won't work well for those cases. However, it still brings a lot of utility to node tools for a relatively simple code change. I investigated two other solutions for this that didn't work out. Using the recently added enum custom property support didn't work because the data-block names would still have to be unique. Plus generating an enum would require a bunch of boilerplate code. Extending the existing button search code to handle integer session UID backed data-blocks was much trickier than I expected. The code there is already quite spagetti- like, and things got out of hand quickly. That's still valid future work though. The implementation can be changed without breaking compatibility of files. --- ![image](/attachments/a4470be3-69d8-4bc9-bba2-43dc6eedbe01)
Hans Goudey added 1 commit 2024-04-26 23:02:17 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
02a276b2ee
Node Tools: Basic support for data-block inputs
Currently support for data-block inputs is disabled because pointer
properties in operator properties aren't properly handled in Blender
(for more info, see 871c717c6e). This commit brings basic
support for them by storing strings (data-block names) in the operator
properties instead. The main downside of using strings compared other
theoretical solutions is that data-blocks from different library files
can have the same name. This solution won't work well for those cases.
However, it still brings a lot of utility to node tools for a relatively
simple code change.

I investigated two other solutions for this that didn't work out. Using
the recently added enum custom property support didn't work because
the data-block names would still have to be unique. Plus generating an
enum would require a bunch of boilerplate code. Extending the existing
button search code to handle integer session UID backed data-blocks was
much trickier than I expected. The code there is already quite spagetti-
like, and things got out of hand quickly. That's still valid future work
though.
Hans Goudey added the
Interest
Geometry Nodes
label 2024-04-26 23:02:33 +02:00
Hans Goudey added this to the Nodes & Physics project 2024-04-26 23:02:39 +02:00
Hans Goudey requested review from Jacques Lucke 2024-04-26 23:02:44 +02:00
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke approved these changes 2024-04-28 00:55:34 +02:00
Jacques Lucke left a comment
Member

Overall seems fine. The limitation with unique data-block names is not great, but maybe fine for now. Maybe a warning could be shown in this case?

It would be good to mention in the description that this can be changed to using e.g. session uids in the future without breaking compatibility of files.

I assume you could also pass in data-blocks when calling the operator from Python by just passing in the name?

Overall seems fine. The limitation with unique data-block names is not great, but maybe fine for now. Maybe a warning could be shown in this case? It would be good to mention in the description that this can be changed to using e.g. session uids in the future without breaking compatibility of files. I assume you could also pass in data-blocks when calling the operator from Python by just passing in the name?
@ -306,0 +332,4 @@
case SOCK_MATERIAL:
return ID_MA;
}
BLI_assert_unreachable();
Member

I wonder if, in the interest of forward compatibility, we should avoid tagging such places as unreachable. We ran into issues before when new socket types are added in the future.

I wonder if, in the interest of forward compatibility, we should avoid tagging such places as unreachable. We ran into issues before when new socket types are added in the future.
HooglyBoogly marked this conversation as resolved
@ -323,1 +323,3 @@
auto property = bke::idprop::create(identifier, reinterpret_cast<ID *>(value->value));
ID *id = reinterpret_cast<ID *>(value->value);
if (use_name_for_ids) {
return bke::idprop::create(identifier, id ? id->name + 2 : "");
Member

Looks like bke::idprop::create(identifier, id ? id->name + 2 : "") could be deduplicated a bit.

Looks like `bke::idprop::create(identifier, id ? id->name + 2 : "")` could be deduplicated a bit.
HooglyBoogly marked this conversation as resolved
Hans Goudey added 2 commits 2024-04-29 03:42:58 +02:00
Author
Member

The limitation with unique data-block names is not great, but maybe fine for now. Maybe a warning could be shown in this case?

A warning could be added for sure. I'm not sure it's worth a loop over all data-blocks though. Seems like a last resort sort of thing, but maybe I'm being paranoid.

I assume you could also pass in data-blocks when calling the operator from Python by just passing in the name?

Recalling now, passing in group inputs from Python has never worked AFAIK. Not sure if the way they're stored on the operator would need to change for that or if something else would have to change. Sort of surprising but now I'm remembering figuring that out last year too...

>The limitation with unique data-block names is not great, but maybe fine for now. Maybe a warning could be shown in this case? A warning could be added for sure. I'm not sure it's worth a loop over all data-blocks though. Seems like a last resort sort of thing, but maybe I'm being paranoid. >I assume you could also pass in data-blocks when calling the operator from Python by just passing in the name? Recalling now, passing in group inputs from Python has never worked AFAIK. Not sure if the way they're stored on the operator would need to change for that or if something else would have to change. Sort of surprising but now I'm remembering figuring that out last year too...
Hans Goudey merged commit 65803f262f into main 2024-04-29 03:47:46 +02:00
Hans Goudey deleted branch node-tools-id-inputs 2024-04-29 03:47: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 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#121148
No description provided.