Fix #109565: Array modifier changes the Root vertex of Skin modifier #109627

Merged
Germano Cavalcante merged 1 commits from mano-wii/blender:fix_109565 into main 2023-07-06 15:05:39 +02:00

The merging behavior of the Array, Mirror, Screw modifiers has changed
since 4369627e71.

Before, only the customdata of the destination vertex was kept. Source
vertices were completely removed.

With 4369627e71, all vertices in the merge group (whether source or
destination) now have their customdata interpolated.

But this can cause problems for example with the root vertex customdata
of the skin modifier, where if only one of the vertices of the group of
vertices has this flag, the resulting one will also have it.

This commit restores the behavior for the vertices customdata and does
not interpolate it if mix_data is false.

The merging behavior of the Array, Mirror, Screw modifiers has changed since 4369627e71. Before, only the customdata of the destination vertex was kept. Source vertices were completely removed. With 4369627e71, all vertices in the merge group (whether source or destination) now have their customdata interpolated. But this can cause problems for example with the root vertex customdata of the skin modifier, where if only one of the vertices of the group of vertices has this flag, the resulting one will also have it. This commit restores the behavior for the vertices customdata and does not interpolate it if `mix_data` is false.
Germano Cavalcante added the
Module
Modeling
label 2023-07-02 23:53:46 +02:00
Germano Cavalcante requested review from Hans Goudey 2023-07-02 23:54:06 +02:00
Germano Cavalcante force-pushed fix_109565 from a30e53dea1 to 4f247a36a5 2023-07-05 02:49:47 +02:00 Compare
Author
Member
  • Fix unnecessary array copy
- Fix unnecessary array copy
Hans Goudey requested changes 2023-07-05 20:38:43 +02:00
@ -53,6 +53,9 @@ std::optional<Mesh *> mesh_merge_by_distance_connected(const Mesh &mesh,
*
* \param vert_dest_map_len: The number of non '-1' values in `vert_dest_map`. (not the size)
Member

Add a description for mix_data, something like mentioning that mentions which element the final data comes from.

Add a description for `mix_data`, something like mentioning that mentions which element the final data comes from.
mano-wii marked this conversation as resolved
@ -1547,2 +1549,3 @@
MutableSpan<int> vert_dest_map,
const int removed_vertex_count)
const int removed_vertex_count,
bool mix_data)
Member

bool -> const bool

Also, this only seems to control mixing for vertex data. Maybe the name should reflect that?

`bool` -> `const bool` Also, this only seems to control mixing for vertex data. Maybe the name should reflect that?
mano-wii marked this conversation as resolved
@ -1580,2 +1585,2 @@
* This map will be used to adjust edges and loops to point to new vertex indices. */
MutableSpan<int> vert_final_map = vert_group_map;
MutableSpan<int> vert_final_map;
Array<int> vert_final_map_stack;
Member

"stack" isn't quite right, since the array will be allocated on the heap. I'd suggest _local instead of _stack.

"stack" isn't quite right, since the array will be allocated on the heap. I'd suggest `_local` instead of `_stack`.
mano-wii marked this conversation as resolved
@ -1605,2 +1619,4 @@
count = *(wgroup + 1) - *wgroup;
}
else {
src_indices = &i;
Member

Would be better in my opinion to use a separate loop for the "no mixing" case. The goals are very different, and a performant implementation that copies a single index at a time would probably look quite different from one that mixes the data of multiple elements together.

Even if this causes some code duplication, that's okay I think.

Would be better in my opinion to use a separate loop for the "no mixing" case. The goals are very different, and a performant implementation that copies a single index at a time would probably look quite different from one that mixes the data of multiple elements together. Even if this causes some code duplication, that's okay I think.
Author
Member

Unfortunately the code duplication would be more than seems appropriate. But I improved the readability by:

  • Checking do_mix_vert_data instead of vert_groups_map.is_empty();
  • Using CustomData_copy_data instead of customdata_weld if do_mix_vert_data is false;
  • Moving vert_groups_map to WeldMesh (its usage becomes clearer).
Unfortunately the code duplication would be more than seems appropriate. But I improved the readability by: - Checking `do_mix_vert_data` instead of `vert_groups_map.is_empty()`; - Using `CustomData_copy_data` instead of `customdata_weld` if `do_mix_vert_data` is false; - Moving `vert_groups_map` to `WeldMesh` (its usage becomes clearer).
@ -1876,0 +1893,4 @@
Mesh *mesh_merge_verts(const Mesh &mesh,
MutableSpan<int> vert_dest_map,
int vert_dest_map_len,
bool mix_data)
Member

bool -> const bool

`bool` -> `const bool`
mano-wii marked this conversation as resolved
Author
Member

Not sure if my reply got notified. So I'm copying it here:

Unfortunately the code duplication would be more than seems appropriate. But I improved the readability by:

  • Checking do_mix_vert_data instead of vert_groups_map.is_empty();
  • Using CustomData_copy_data instead of customdata_weld if do_mix_vert_data is false;
  • Moving vert_groups_map to WeldMesh (its usage becomes clearer).
Not sure if my reply got notified. So I'm copying it here: > Unfortunately the code duplication would be more than seems appropriate. But I improved the readability by: > - Checking `do_mix_vert_data` instead of `vert_groups_map.is_empty()`; > - Using `CustomData_copy_data` instead of `customdata_weld` if `do_mix_vert_data` is false; > - Moving `vert_groups_map` to `WeldMesh` (its usage becomes clearer).
Hans Goudey approved these changes 2023-07-06 02:25:49 +02:00
Hans Goudey left a comment
Member

Just two things noted inline

Just two things noted inline
@ -54,1 +54,4 @@
* \param vert_dest_map_len: The number of non '-1' values in `vert_dest_map`. (not the size)
* \param do_mix_vert_data: If true, the groups of vertices in the `vert_dest_map_len`, defined by
* source vertices with the same target plus the target vertex, will have their custom data
* interpolated into the resulting vertex.If false, only the custom data of the target vertex will
Member

Missing space after "vertex."

Missing space after "vertex."
@ -1377,2 +1379,2 @@
MutableSpan<int> r_vert_group_map,
WeldMesh *r_weld_mesh)
WeldMesh *r_weld_mesh,
const bool do_vert_group)
Member

Return arguments should be ordered last

Return arguments should be ordered last
Germano Cavalcante force-pushed fix_109565 from f053c460e2 to 53862b39bc 2023-07-06 15:04:35 +02:00 Compare
Germano Cavalcante merged commit 74772c6920 into main 2023-07-06 15:05:39 +02:00
Germano Cavalcante deleted branch fix_109565 2023-07-06 15:05:40 +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 project
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#109627
No description provided.