WIP: Make ComponentAttributeAccessor handle active/default_color_attribute #109083
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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 project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109083
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Baardaap/blender:addremovetrigger"
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?
When Geometry Nodes created or deleted attributes it didn't handle
the active/default_color_attribute strings on Mesh. This lead to
Meshes with color attributes but without active/default_color_attribute
set, which is a regression from previous blender versions where newly
created color attributes are always set to active/default if they were the
first created color attribute.
When using GN to colorize point cloud data, for example, it's very
convenient if the created color_attribute is also used in solid mode attribute
coloring.
I think this is a better way to do what #109067 did as well.
Iliya suggested (i the chat) to use 'handler' instead of 'trigger' for the function names. Which is better I agree.
Also I have my doubts about the delete handler because:
But is does seem more 'correct' this way and I'm afraid not clearing those strings on attrib delete will come back to bite us in the ass later.
Now that I think of it... I'm not really sure the delete handler is even correct. As it uses the AttributeIDRef which points to the just deleted attribute. And it's name_ member probably points into the name of the deleted layer. Which could be the wrong layer name now that I think of it (because of the reordering of CD layers on remove). The delete handler would need to be called before deleting the layer, which is a bit more hard to integrate..
ok. back to the drawing board I guess. But I'd still very much appreciate some feedback on if this approach seems feasible and if it's something we want to have (setting the first created layer to active)
I think I solved the issue with the remove handler being wrong.
@ -1082,6 +1082,38 @@ class VertexGroupsAttributeProvider final : public DynamicAttributesProvider {
*/
static ComponentAttributeProviders create_attribute_providers_for_mesh()
{
static AttributeAddHandler mesh_add_handler =
To me the need for a concept like "Trigger" suggests the system is getting a bit too complex. Seems like it might fit a bit better in the existing
CustomDataAttributeProvider::try_delete()
function.I thought about that. But the problem is that the active/default is set on the mesh, and not on the CustomData level
I'll look at it again, but I think CustomDataAttributeProvider just links to the CustomDataLayer and has no easy way to get back to the owning mesh.
Furthermore CustomDataAttributeProvider is also used for Curves and PointClouds, but this functionality is only needed for Mesh.
@ -1085,0 +1087,4 @@
Mesh *mesh = static_cast<Mesh *>(owner);
if ((type == CD_PROP_COLOR || type == CD_PROP_BYTE_COLOR) && !attribute_id.is_anonymous()) {
if (mesh->active_color_attribute == nullptr) {
mesh->active_color_attribute = static_cast<char *>(
Shouldn't need to cast this to
char *
, that's the return type.@ -1085,0 +1100,4 @@
static AttributeRemoveHandler mesh_remove_handler =
[](void *owner, AttributeIDRef const &attribute_id) -> void {
Mesh *mesh = static_cast<Mesh *>(owner);
if (mesh->active_color_attribute && !strncmp(mesh->active_color_attribute,
Looks much better as
StringRef(mesh->active_color_attribute) == attribute_id.name()
IMO@ -1085,0 +1104,4 @@
attribute_id.name().data(),
attribute_id.name().size()))
{
MEM_SAFE_FREE(mesh->active_color_attribute);
So far we've decided not to remove the active name when removing the corresponding attribute. The idea is that the name might not always match an attribute on the geometry, since they might be created/set at different times. I'm not totally tied to that, but it does seem reasonable to me too.
ok, that's good I could just remove the delete handler.
The basic idea of setting the first created color attribute active seems somewhat reasonable I guess. But the alternative is to add a "Set Active Color Attribute" node, which is probably a bit more explicit (and therefore intuitive?). The remaining question we had about that when we discussed it is what name to use. But something like "active_color" might be fine Or it could be specified too.
There is the "Remove Named Attribute" node.
Also, as a high level design goal, personally I think the whole concept of an active color attribute in a procedural context is more of a crutch than a design goal. It just means connections are more implicit, and means you need to keep track of even more state. But it's the only way we have to create reusable materials that use color attributes, so we're sort of stuck with it for now.
Creating a an Active Color node might be better/more intuitive.
Though a bit strange that an 'Active Color' node would set the 'default_color_attribute' and not the 'active_color_attribute'.
I don't really disagree. But there are numerous bugreports because GN behaves differently in this respect than all other modifiers.
For backwards compatibility I think it would still be nice to always set a default, even if we have an explicit node as well.
Checkout
From your project repository, check out a new branch and test the changes.