Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/DerivedMesh.cc
| Show First 20 Lines • Show All 622 Lines • ▼ Show 20 Lines | static void mesh_calc_modifier_final_normals(const Mesh *mesh_input, | ||||
| const CustomData_MeshMasks *final_datamask, | const CustomData_MeshMasks *final_datamask, | ||||
| const bool sculpt_dyntopo, | const bool sculpt_dyntopo, | ||||
| Mesh *mesh_final) | Mesh *mesh_final) | ||||
| { | { | ||||
| /* Compute normals. */ | /* Compute normals. */ | ||||
| const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 || | const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 || | ||||
| (final_datamask->lmask & CD_MASK_NORMAL) != 0); | (final_datamask->lmask & CD_MASK_NORMAL) != 0); | ||||
| /* Needed as `final_datamask` is not preserved outside modifier stack evaluation. */ | |||||
| mesh_final->runtime.subsurf_do_loop_normals = do_loop_normals; | |||||
brecht: I think we should we do the same in `editbmesh_calc_modifier_final_normals`? | |||||
| if (do_loop_normals) { | if (do_loop_normals) { | ||||
Done Inline ActionsCould we skip computing loop normals here for the subdiv wrapper? It seems like a waste of time if they are going to be recomputed later, and also is not consistent with the modifier being evaluated as part of the stack, since loop normals would then always be computed after the subdiv modifier. brecht: Could we skip computing loop normals here for the subdiv wrapper? It seems like a waste of time… | |||||
| /* Compute loop normals (NOTE: will compute poly and vert normals as well, if needed!). */ | /* Compute loop normals (NOTE: will compute poly and vert normals as well, if needed!). In case | ||||
| * of deferred CPU subdivision, this will be computed when the wrapper is generated. */ | |||||
| if (mesh_final->runtime.subsurf_resolution != 0) { | |||||
| BKE_mesh_calc_normals_split(mesh_final); | BKE_mesh_calc_normals_split(mesh_final); | ||||
| } | } | ||||
| } | |||||
| else { | else { | ||||
| if (sculpt_dyntopo == false) { | if (sculpt_dyntopo == false) { | ||||
| /* without this, drawing ngon tri's faces will show ugly tessellated face | /* without this, drawing ngon tri's faces will show ugly tessellated face | ||||
| * normals and will also have to calculate normals on the fly, try avoid | * normals and will also have to calculate normals on the fly, try avoid | ||||
| * this where possible since calculating polygon normals isn't fast, | * this where possible since calculating polygon normals isn't fast, | ||||
| * note that this isn't a problem for subsurf (only quads) or editmode | * note that this isn't a problem for subsurf (only quads) or editmode | ||||
| * which deals with drawing differently. */ | * which deals with drawing differently. */ | ||||
| BKE_mesh_ensure_normals_for_display(mesh_final); | BKE_mesh_ensure_normals_for_display(mesh_final); | ||||
| ▲ Show 20 Lines • Show All 626 Lines • ▼ Show 20 Lines | if (mesh_final->runtime.wrapper_type != ME_WRAPPER_TYPE_MDATA) { | ||||
| /* Generated at draw time. */ | /* Generated at draw time. */ | ||||
| mesh_final->runtime.wrapper_type_finalize = (1 << mesh_final->runtime.wrapper_type); | mesh_final->runtime.wrapper_type_finalize = (1 << mesh_final->runtime.wrapper_type); | ||||
| return; | return; | ||||
| } | } | ||||
| const bool do_loop_normals = ((mesh_final->flag & ME_AUTOSMOOTH) != 0 || | const bool do_loop_normals = ((mesh_final->flag & ME_AUTOSMOOTH) != 0 || | ||||
| (final_datamask->lmask & CD_MASK_NORMAL) != 0); | (final_datamask->lmask & CD_MASK_NORMAL) != 0); | ||||
| mesh_final->runtime.subsurf_do_loop_normals = do_loop_normals; | |||||
| if (do_loop_normals) { | if (do_loop_normals) { | ||||
| /* Compute loop normals */ | /* Compute loop normals. In case of deferred CPU subdivision, this will be computed when the | ||||
| * wrapper is generated. */ | |||||
| if (mesh_final->runtime.subsurf_resolution != 0) { | |||||
| BKE_mesh_calc_normals_split(mesh_final); | BKE_mesh_calc_normals_split(mesh_final); | ||||
| } | } | ||||
| } | |||||
| else { | else { | ||||
| /* Same as mesh_calc_modifiers. If using loop normals, poly nors have already been computed. */ | /* Same as mesh_calc_modifiers. If using loop normals, poly nors have already been computed. */ | ||||
| BKE_mesh_ensure_normals_for_display(mesh_final); | BKE_mesh_ensure_normals_for_display(mesh_final); | ||||
| /* Some modifiers, like data-transfer, may generate those data, we do not want to keep them, | /* Some modifiers, like data-transfer, may generate those data, we do not want to keep them, | ||||
| * as they are used by display code when available (i.e. even if autosmooth is disabled). */ | * as they are used by display code when available (i.e. even if autosmooth is disabled). */ | ||||
| if (CustomData_has_layer(&mesh_final->ldata, CD_NORMAL)) { | if (CustomData_has_layer(&mesh_final->ldata, CD_NORMAL)) { | ||||
| CustomData_free_layers(&mesh_final->ldata, CD_NORMAL, mesh_final->totloop); | CustomData_free_layers(&mesh_final->ldata, CD_NORMAL, mesh_final->totloop); | ||||
| ▲ Show 20 Lines • Show All 759 Lines • Show Last 20 Lines | |||||
I think we should we do the same in editbmesh_calc_modifier_final_normals?