diff options
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.cc')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.cc | 64 |
1 files changed, 4 insertions, 60 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index 73785e2ee2b..f25c0044c7d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -775,28 +775,6 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input, /* Compute normals. */ const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 || (final_datamask->lmask & CD_MASK_NORMAL) != 0); - /* Some modifiers may need this info from their target (other) object, - * simpler to generate it here as well. - * Note that they will always be generated when no loop normals are computed, - * since they are needed by drawing code. */ - const bool do_poly_normals = ((final_datamask->pmask & CD_MASK_NORMAL) != 0); - - /* In case we also need poly normals, add the layer and compute them here - * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */ - if (do_poly_normals) { - if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { - float(*polynors)[3] = (float(*)[3])CustomData_add_layer( - &mesh_final->pdata, CD_NORMAL, CD_CALLOC, nullptr, mesh_final->totpoly); - BKE_mesh_calc_normals_poly_and_vertex(mesh_final->mvert, - mesh_final->totvert, - mesh_final->mloop, - mesh_final->totloop, - mesh_final->mpoly, - mesh_final->totpoly, - polynors, - nullptr); - } - } if (do_loop_normals) { /* Compute loop normals (NOTE: will compute poly and vert normals as well, if needed!). */ @@ -814,11 +792,7 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input, * normals and will also have to calculate normals on the fly, try avoid * this where possible since calculating polygon normals isn't fast, * note that this isn't a problem for subsurf (only quads) or editmode - * which deals with drawing differently. - * - * Only calc vertex normals if they are flagged as dirty. - * If using loop normals, poly nors have already been computed. - */ + * which deals with drawing differently. */ if (!do_loop_normals) { BKE_mesh_ensure_normals_for_display(mesh_final); } @@ -927,6 +901,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, * constructive modifier is executed, or a deform modifier needs normals * or certain data layers. */ Mesh *mesh_input = (Mesh *)ob->data; + BKE_mesh_assert_normals_dirty_or_calculated(mesh_input); Mesh *mesh_final = nullptr; Mesh *mesh_deform = nullptr; /* This geometry set contains the non-mesh data that might be generated by modifiers. */ @@ -1458,26 +1433,6 @@ static void editbmesh_calc_modifier_final_normals(Mesh *mesh_final, const bool do_loop_normals = ((mesh_final->flag & ME_AUTOSMOOTH) != 0 || (final_datamask->lmask & CD_MASK_NORMAL) != 0); - /* Some modifiers may need this info from their target (other) object, - * simpler to generate it here as well. */ - const bool do_poly_normals = ((final_datamask->pmask & CD_MASK_NORMAL) != 0); - - /* In case we also need poly normals, add the layer and compute them here - * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */ - if (do_poly_normals) { - if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { - float(*polynors)[3] = (float(*)[3])CustomData_add_layer( - &mesh_final->pdata, CD_NORMAL, CD_CALLOC, nullptr, mesh_final->totpoly); - BKE_mesh_calc_normals_poly_and_vertex(mesh_final->mvert, - mesh_final->totvert, - mesh_final->mloop, - mesh_final->totloop, - mesh_final->mpoly, - mesh_final->totpoly, - polynors, - nullptr); - } - } if (do_loop_normals) { /* Compute loop normals */ @@ -1808,14 +1763,6 @@ static void mesh_build_extra_data(struct Depsgraph *depsgraph, Object *ob, Mesh } } -static void mesh_runtime_check_normals_valid(const Mesh *mesh) -{ - UNUSED_VARS_NDEBUG(mesh); - BLI_assert(!(mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL)); - BLI_assert(!(mesh->runtime.cd_dirty_loop & CD_MASK_NORMAL)); - BLI_assert(!(mesh->runtime.cd_dirty_poly & CD_MASK_NORMAL)); -} - static void mesh_build_data(struct Depsgraph *depsgraph, Scene *scene, Object *ob, @@ -1890,7 +1837,6 @@ static void mesh_build_data(struct Depsgraph *depsgraph, } } - mesh_runtime_check_normals_valid(mesh_eval); mesh_build_extra_data(depsgraph, ob, mesh_eval); } @@ -1923,8 +1869,6 @@ static void editbmesh_build_data(struct Depsgraph *depsgraph, BKE_object_boundbox_calc_from_mesh(obedit, em->mesh_eval_final); em->lastDataMask = *dataMask; - - mesh_runtime_check_normals_valid(em->mesh_eval_final); } static void object_get_datamask(const Depsgraph *depsgraph, @@ -2181,8 +2125,7 @@ struct MappedUserData { static void make_vertexcos__mapFunc(void *userData, int index, const float co[3], - const float UNUSED(no_f[3]), - const short UNUSED(no_s[3])) + const float UNUSED(no[3])) { MappedUserData *mappedData = (MappedUserData *)userData; @@ -2229,6 +2172,7 @@ void DM_calc_loop_tangents(DerivedMesh *dm, calc_active_tangent, tangent_names, tangent_names_len, + (const float(*)[3])CustomData_get_layer(&dm->vertData, CD_NORMAL), (const float(*)[3])CustomData_get_layer(&dm->polyData, CD_NORMAL), (const float(*)[3])dm->getLoopDataArray(dm, CD_NORMAL), (const float(*)[3])dm->getVertDataArray(dm, CD_ORCO), /* may be nullptr */ |