Fix #121366: Invalid mat_nr after exact boolean #121380

Merged
YimingWu merged 3 commits from ChengduLittleA/blender:fix-121366 into main 2024-05-04 13:29:45 +02:00
Member

Material index of faces could be a invalid value after booleaning in
exact boolean in "Index Based" mode against objects with no material
slots, this is caused by the lack of initilization material remapping
array. Now all initilized to 0.

Assigning 0 explicitly in Fast mode as well for consistency.

Material index of faces could be a invalid value after booleaning in exact boolean in "Index Based" mode against objects with no material slots, this is caused by the lack of initilization material remapping array. Now all initilized to 0. Assigning 0 explicitly in Fast mode as well for consistency.
YimingWu added the
Module
Modeling
label 2024-05-03 06:07:07 +02:00
YimingWu added 1 commit 2024-05-03 06:07:18 +02:00
Material index of faces could be a invalid value after booleaning in
exact boolean in "Index Based" mode against objects with no material
slots, this is caused by the lack of initilization material remapping
array. Now all initilized to 0.

Assigning 0 explicitly in Fast mode as well for consistency.
YimingWu requested review from Hans Goudey 2024-05-03 06:08:08 +02:00
Hans Goudey requested changes 2024-05-03 14:30:33 +02:00
Dismissed
Hans Goudey left a comment
Member

Thanks! Indeed I see how this isn't initializing the attribute!

Thanks! Indeed I see how this isn't initializing the attribute!
@ -378,6 +381,7 @@ static Array<short> get_material_remap_index_based(Object *dest_ob, Object *src_
n = 1;
}
Array<short> remap(n);
remap.fill(0);
Member

Seems to be the same inside BKE_object_material_remap_calc

Seems to be the same inside `BKE_object_material_remap_calc`
Author
Member

Looks like BKE_object_material_remap_calc returns directly when src->totcol==0 so in that case the sole element inside remap is not written to.

I now changed this to return a 1-value array directly.

Looks like `BKE_object_material_remap_calc` returns directly when `src->totcol==0` so in that case the sole element inside `remap` is not written to. I now changed this to return a 1-value array directly.
@ -390,6 +394,7 @@ static Array<short> get_material_remap_transfer(Object &object,
{
const int material_num = mesh.totcol;
Array<short> map(material_num);
map.fill(0);
Member

This one seems unnecessary, since the whole array is filled in the next loop

This one seems unnecessary, since the whole array is filled in the next loop
ChengduLittleA marked this conversation as resolved
YimingWu added 1 commit 2024-05-03 18:07:02 +02:00
Hans Goudey reviewed 2024-05-03 18:26:40 +02:00
@ -375,7 +378,9 @@ static Array<short> get_material_remap_index_based(Object *dest_ob, Object *src_
{
int n = src_ob->totcol;
Member

n can be const now :)

`n` can be const now :)
ChengduLittleA marked this conversation as resolved
@ -378,1 +381,3 @@
n = 1;
Array<short> remap(1);
remap[0] = 0;
return remap;
Member

return Array<short>(1, 0); is a bit simpler.

`return Array<short>(1, 0);` is a bit simpler.
ChengduLittleA marked this conversation as resolved
YimingWu added 1 commit 2024-05-04 06:43:51 +02:00
Hans Goudey approved these changes 2024-05-04 13:24:45 +02:00
YimingWu merged commit 3be6dbb02a into main 2024-05-04 13:29:45 +02:00
YimingWu deleted branch fix-121366 2024-05-04 13:29:47 +02:00
Sign in to join this conversation.
No reviewers
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
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#121380
No description provided.