Maniphest T57133

Auto Smooth option corrupts mesh data
Closed, Duplicate

Assigned To
Bastien Montagne (mont29)
Authored By
maylog (maylog)
Oct 10 2018, 9:52 AM
Tags
  • BF Blender
Subscribers
Bastien Montagne (mont29)
Brecht Van Lommel (brecht)
Clément Foucault (fclem)
maylog (maylog)

Description

System Information
Operating system and graphics card

Blender Version
Broken: 2.80 Alpha2 2018.10.09
Worked: (optional)

Short description of error

Exact steps for others to reproduce the error
Based on a (as simple as possible) attached .blend file with minimum amount of steps
There is no problem when opening with version 2.79.
I recorded a video
This is the problem scene file

Event Timeline

maylog (maylog) created this task.Oct 10 2018, 9:52 AM
Brecht Van Lommel (brecht) renamed this task from Blender2.8 will cause an error when opening a file that has already been UV to UVs display issue in UV editor.Oct 10 2018, 5:36 PM
Brecht Van Lommel (brecht) assigned this task to Clément Foucault (fclem).
Brecht Van Lommel (brecht) lowered the priority of this task from 90 to 50.
Brecht Van Lommel (brecht) added a subscriber: Brecht Van Lommel (brecht).

I can confirm some of the UVs are drawn in the wrong position in the UV editor. At least as far as I can tell it's just a UV editor issue, textures appears to be mapped ok.

Clément Foucault (fclem) added a comment.Oct 12 2018, 5:45 PM

It is not just a drawing issue. The edit mesh normals is all wrong and the texture is NOT mapped correctly.

The edit UVs are selectable at their displayed position and editable so it's not a display problem (since selection and edition are not using OGL).
And since the same file is read correctly by 2.79 I think it might be something wrong in the version update of the mesh data.

Clément Foucault (fclem) added a comment.EditedOct 16 2018, 12:31 PM

Ok so it seems that the drawing code is somehow corrupting the data. If you load the file and go into edit mode without a 3D view opened the UVs are displayed correctly.
But If you go into edit mode with a 3D view opened, then the UV data is being corrupted. The normals of the mesh are also not correct.

EDIT: After further investigation it's caused by the auto smooth option on the mesh.
The corruption happens when mesh_render_data_create_ex is called with types MR_DATATYPE_LOOP and the mesh uses the auto smooth feature. The culprit function is bm_mesh_loops_calc_normals().

Clément Foucault (fclem) renamed this task from UVs display issue in UV editor to Auto Smooth option corrupts mesh data.Oct 16 2018, 1:18 PM
Clément Foucault (fclem) reassigned this task from Clément Foucault (fclem) to Bastien Montagne (mont29).Oct 16 2018, 2:23 PM
Clément Foucault (fclem) added subscribers: Bastien Montagne (mont29), Clément Foucault (fclem).

After more investigation it seems that this patch fix this issue. So I guess it's a problem about clnor not being correct.
@Bastien Montagne (mont29) Since you wrote most of this function assigning to you.

diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 8833564e486..aa1dbc1379b 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -915,8 +915,10 @@ static void bm_mesh_loops_calc_normals(
 
 								while ((clnor = BLI_SMALLSTACK_POP(clnors))) {
 									//print_v2("org clnor", clnor);
+	#if 0
 									clnor[0] = (short)clnors_avg[0];
 									clnor[1] = (short)clnors_avg[1];
+	#endif
 								}
 								//print_v2("new clnors", clnors_avg);
 							}
Bastien Montagne (mont29) updated the task description.Oct 16 2018, 4:47 PM
Bastien Montagne (mont29) added a comment.Oct 16 2018, 4:50 PM

Did not touch that code since ages, so that’s probably normal editing GSoC issue… will check.

Bastien Montagne (mont29) closed this task as a duplicate of T56735: Blender2.8 Autosmooth option corrupts UVs.