Correctly setting active UV maps during "Realize Instances" #116452
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#116452
Loading…
Reference in New Issue
No description provided.
Delete Branch "Eugene-Kuznetsov/blender:ek_uv_map_geonodes"
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?
As currently implemented, Blender sometimes incorrectly sets active/render UV maps during the "realize instances" operation. This also comes into play if you try to modify the mesh with geonodes: e.g., if you use geonodes to split a mesh into two pieces, transform one of them, and then "join geometry", join operation internally performs "realize instances", triggering the same bug. I believe it's the same bug as reported in #112181 and possibly some other issues. See attached blend file for a reproducer.
The root cause is that "realize instances" copies both UV map layers and the active/render layer index, but it reorders layers (possibly in alphabetical order?) during this process, so the index that was correct in the original mesh is now wrong in the modified mesh.
This patch corrects indexes by explicitly checking layer names.
5daf20ce3d
to3ddb84f7a3
Not sure if index is make sense at all, it is not a string of activa layer currently?
3ddb84f7a3
tocab84e19cc
The same bug independently affects "Separate Geometry" and "Delete Geometry" (reproducer attached). I've pushed an updated fix that covers those cases as well.
@ -1172,6 +1172,13 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options,
dst_attributes.lookup_or_add_for_write_only_span(attribute_id, domain, data_type));
}
CustomData_set_layer_active(&dst_mesh->corner_data, CD_PROP_FLOAT2,
It seems like some error handling is missing here for the case when there is no active/render attribute. Or am I missing something?
Is it even possible for a mesh to have no active/render attribute?
If the mesh has no CD_PROP_FLOAT2 layers, CustomData_get_active_layer_name calls CustomData_get_active_layer_index and receives -1, it returns nullptr, CustomData_get_named_layer returns -1, and CustomData_set_layer_active iterates through layers, finds no CD_PROP_FLOAT2 layers and therefore does nothing.
If it does have CD_PROP_FLOAT2 layers but somehow none of them are marked as active/render (layers[layer_index].active set to -1 in https://projects.blender.org/blender/blender/src/branch/main/source/blender/blenkernel/intern/customdata.cc#L2611), then there might be a problem because there will be a strcmp with null inside CustomData_get_named_layer_index. It might be cleaner to fix this by
`@@ -2584,6 +2584,9 @@ int CustomData_get_named_layer_index(const CustomData *data,
const eCustomDataType type,
const char *name)
{
if (data->layers[i].type == type) {
if (STREQ(data->layers[i].name, name)) {
`
I don't think that
CustomData_set_layer_active
is intentionally written in a way that would allow passing in-1
. There should probably be an assert at some point.I'd prefer more explicit handling of this case on the call-site.
cab84e19cc
toffc146addc
ffc146addc
toa989813e2d
Generally looks good now. Needs one small cleanup.
@ -2584,6 +2584,9 @@ int CustomData_get_named_layer_index(const CustomData *data,
const eCustomDataType type,
const char *name)
{
if(name == nullptr)
This change seems unnecssary.
@blender-bot build
a989813e2d
to3760a9522a
I'm sorry to say it, but this is actually not quite working yet and is failing tests (also because of the removed check that I requested earlier, but I still think it's correct that it is removed).
The reason tests are failing is that it can happen that
dst_mesh
does not have the attribute that's active onfirst_mesh
. Might be reasonable to add a new function likeCustomData_copy_active/render_layer
that handles the different failure cases. I can understand if you are not motivated to work on this patch anymore. I can finish it up myself if you want.3760a9522a
toff7980c710
@blender-bot build