Fix #114760: new attribute does not get active for some domains #114797

Merged
Philipp Oeser merged 5 commits from lichtwerk/blender:114760 into main 2023-12-07 15:33:38 +01:00
Member

Problem here is that BKE_id_attribute_to_index [which
BKE_id_attributes_active_set uses] does not match
BKE_id_attribute_from_index which can lead to "wrong" indices (there
are "wrong" layers included while iterating such as ".corner_vert" or
".corner_edge" for faces).

Deeper reason is that get_domains_types swaps ATTR_DOMAIN_FACE and
ATTR_DOMAIN_CORNER (originally introduced in eae36be372 -- but unclear
at this point why this was done). Historically, this was used for operators
[vertex color rotate/inverse] introduced in c75e1598dd & 771a4dee0b,
assumption is that eae36be372 was trying to make this more generic and make
it work for other domains as well (ATTR_DOMAIN_MASK_COLOR -- the tootip
was also changed from "Rotate vertex colors inside faces" to "Rotate color
attributes inside faces"), however, at this point in time the tools clearly only work
for the corner domain (and this was made more specific in ee18b625ca as well).

So now, remove the swapping all together and make
BKE_id_attribute_from_index & BKE_id_attribute_to_index in sync.

Also change the tooltip of said operators to use "face corner color attribute".

Problem here is that `BKE_id_attribute_to_index` [which `BKE_id_attributes_active_set` uses] does not match `BKE_id_attribute_from_index` which can lead to "wrong" indices (there are "wrong" layers included while iterating such as ".corner_vert" or ".corner_edge" for faces). Deeper reason is that `get_domains_types` swaps `ATTR_DOMAIN_FACE` and `ATTR_DOMAIN_CORNER` (originally introduced in eae36be372 -- but unclear at this point why this was done). Historically, this was used for operators [vertex color rotate/inverse] introduced in c75e1598dd & 771a4dee0b, assumption is that eae36be372 was trying to make this more generic and make it work for other domains as well (ATTR_DOMAIN_MASK_COLOR -- the tootip was also changed from "Rotate vertex colors inside faces" to "Rotate color attributes inside faces"), however, at this point in time the tools clearly only work for the corner domain (and this was made more specific in ee18b625ca as well). So now, remove the swapping all together and make `BKE_id_attribute_from_index` & `BKE_id_attribute_to_index` in sync. Also change the tooltip of said operators to use "face corner color attribute".
Philipp Oeser added 1 commit 2023-11-13 15:36:48 +01:00
Problem here is that `BKE_id_attribute_to_index` [which
`BKE_id_attributes_active_set` uses] does not match
`BKE_id_attribute_from_index` which can lead to "wrong" indices (there
are "wrong" layers included while iterating such as ".corner_vert" or
".corner_edge" for faces).

Deeper reason is that `get_domains_types` swaps `ATTR_DOMAIN_FACE` and
`ATTR_DOMAIN_CORNER` (no deeper knowledge what this is for?! -- but
seems dangerous to have in such a "general" looking function like
`BKE_id_attribute_to_index`...

Not wanting to mess with existing behavior too much (mostly used in
color related code), this PR makes the swapping optional and avoids it
from `BKE_id_attributes_active_set`.
Philipp Oeser requested review from Hans Goudey 2023-11-13 15:36:56 +01:00
Philipp Oeser requested review from Brecht Van Lommel 2023-11-13 15:37:04 +01:00
Philipp Oeser added this to the Core project 2023-11-13 15:37:11 +01:00
Philipp Oeser added the
Interest
Modeling
label 2023-11-13 15:37:28 +01:00
Member

Could we just remove the swapping in get_domains_types? Indeed that seems very weird.

Could we just remove the swapping in `get_domains_types`? Indeed that seems very weird.
Author
Member

Could we just remove the swapping in get_domains_types? Indeed that seems very weird.

Hm, while I could not get any particular functionality to misbehave with swapping removed, I dont feel confident enough to do this as part of this bugfix. So this either needs even more investigation or is just for another commit...

> Could we just remove the swapping in `get_domains_types`? Indeed that seems very weird. Hm, while I could not get any particular functionality to misbehave with swapping removed, I dont feel confident enough to do this as part of this bugfix. So this either needs even more investigation or is just for another commit...
Member

Removing the swapping seems reasonable. If we find something misbehaves with that gone, we can fix it in another way, or at worst add it back. But currently no one can understand why it's there, best to remove it.

Removing the swapping seems reasonable. If we find something misbehaves with that gone, we can fix it in another way, or at worst add it back. But currently no one can understand why it's there, best to remove it.
Author
Member

Removing the swapping seems reasonable. If we find something misbehaves with that gone, we can fix it in another way, or at worst add it back. But currently no one can understand why it's there, best to remove it.

OKi, while usually I tend to lean in the "never-change-a-running-system" direction (as opposed to "take-down-and-rebuild-if-neccessary"), I will do the changes

> Removing the swapping seems reasonable. If we find something misbehaves with that gone, we can fix it in another way, or at worst add it back. But currently no one can understand why it's there, best to remove it. OKi, while usually I tend to lean in the "never-change-a-running-system" direction (as opposed to "take-down-and-rebuild-if-neccessary"), I will do the changes
Philipp Oeser added 2 commits 2023-12-07 09:39:07 +01:00
Only purpose was to swap corner and face domains (originally introduced
in eae36be372 -- but unclear at this point why this was done)

Historically, this was used for tools [vertex color rotate/inverse]
introduced in c75e1598dd & 771a4dee0b, assumption is that
eae36be372 was trying to make this more generic and make it work for
other domains as well (ATTR_DOMAIN_MASK_COLOR -- the tootip was also
changed from "Rotate vertex colors inside faces" to "Rotate color
attributes inside faces"), however, at this point in time the tools
clearly only work for the corner domain (and this was made more specific
in ee18b625ca as well).

So now, remove the swapping all together and make
`BKE_id_attribute_from_index` & `BKE_id_attribute_to_index` in sync.

Also change the tooltip back to "Rotate vertex colors inside faces".
Author
Member

Made some more research (updated the PR description), now also more confident that removing the swapping is the right thing to do (and should be safe).

Made some more research (updated the PR description), now also more confident that removing the swapping is the right thing to do (and should be safe).
Hans Goudey reviewed 2023-12-07 13:45:57 +01:00
@ -3262,3 +3262,3 @@
ot->name = "Rotate Colors";
ot->idname = "MESH_OT_colors_rotate";
ot->description = "Rotate color attributes inside faces";
ot->description = "Rotate vertex colors inside faces";
Member

"Vertex colors" isn't a concept in Blender anymore (ideally anyway). How about "face corner color attribute"?

"Vertex colors" isn't a concept in Blender anymore (ideally anyway). How about "face corner color attribute"?
Author
Member

Well, it is still all over the place:

image

Maybe make this a cleanup afterwards?

Well, it is still all over the place: ![image](/attachments/4c9fba22-1621-403b-80c1-c0d9290f555c) Maybe make this a cleanup afterwards?
Member

Well, it is still all over the place:

Agh, good point. That transition was so incomplete :/
I'd still suggest to use the new terms in new code.

>Well, it is still all over the place: Agh, good point. That transition was so incomplete :/ I'd still suggest to use the new terms in new code.
Philipp Oeser added 1 commit 2023-12-07 15:03:56 +01:00
Hans Goudey approved these changes 2023-12-07 15:08:47 +01:00
@ -839,2 +823,2 @@
for (int i = 0; i < ATTR_DOMAIN_NUM; i++) {
if (!(domain_mask & (1 << domains[i])) || !info[domains[i]].customdata) {
for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) {
CustomData *customdata = info[domain].customdata;
Member

const CustomData

`const CustomData`
Philipp Oeser added 1 commit 2023-12-07 15:24:26 +01:00
Philipp Oeser merged commit 481094ff5c into main 2023-12-07 15:33:38 +01:00
Philipp Oeser deleted branch 114760 2023-12-07 15:33:39 +01:00
First-time contributor

Thanks a lot for fixing this! ❤️
Will it be added in 4.0.3?

Thanks a lot for fixing this! ❤️ Will it be added in 4.0.3?
Author
Member

I have added it to #114706

I have added it to #114706
Sign in to join this conversation.
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
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
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
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
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#114797
No description provided.