diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-08-25 07:08:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-08-25 08:49:26 +0300 |
commit | bada34c766029b1054b7255fd471b0f90cdda8ce (patch) | |
tree | 375332f04582b7cea36442f981e909a2b4e8474a | |
parent | 4ab50eb7facec7561bfb04838a74c5040d26a5e4 (diff) |
Cleanup: remove BKE_mesh_calc_normals_tessface
This was used for versioning, now normals are calculated after
initializing MPoly data.
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_evaluate.c | 58 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 5 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 11 |
4 files changed, 11 insertions, 68 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 4233c140dad..ef897755985 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -313,11 +313,6 @@ void BKE_mesh_calc_normals_poly(struct MVert *mverts, void BKE_mesh_calc_normals(struct Mesh *me); void BKE_mesh_ensure_normals(struct Mesh *me); void BKE_mesh_ensure_normals_for_display(struct Mesh *mesh); -void BKE_mesh_calc_normals_tessface(struct MVert *mverts, - int numVerts, - const struct MFace *mfaces, - int numFaces, - float (*r_faceNors)[3]); void BKE_mesh_calc_normals_looptri(struct MVert *mverts, int numVerts, const struct MLoop *mloop, diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index ad06f4b7da1..7430bc14858 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -448,64 +448,6 @@ void BKE_mesh_calc_normals(Mesh *mesh) mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL; } -void BKE_mesh_calc_normals_tessface( - MVert *mverts, int numVerts, const MFace *mfaces, int numFaces, float (*r_faceNors)[3]) -{ - float(*tnorms)[3] = MEM_calloc_arrayN((size_t)numVerts, sizeof(*tnorms), "tnorms"); - float(*fnors)[3] = (r_faceNors) ? - r_faceNors : - MEM_calloc_arrayN((size_t)numFaces, sizeof(*fnors), "meshnormals"); - int i; - - if (!tnorms || !fnors) { - goto cleanup; - } - - for (i = 0; i < numFaces; i++) { - const MFace *mf = &mfaces[i]; - float *f_no = fnors[i]; - float *n4 = (mf->v4) ? tnorms[mf->v4] : NULL; - const float *c4 = (mf->v4) ? mverts[mf->v4].co : NULL; - - if (mf->v4) { - normal_quad_v3( - f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co); - } - else { - normal_tri_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co); - } - - accumulate_vertex_normals_v3(tnorms[mf->v1], - tnorms[mf->v2], - tnorms[mf->v3], - n4, - f_no, - mverts[mf->v1].co, - mverts[mf->v2].co, - mverts[mf->v3].co, - c4); - } - - /* following Mesh convention; we use vertex coordinate itself for normal in this case */ - for (i = 0; i < numVerts; i++) { - MVert *mv = &mverts[i]; - float *no = tnorms[i]; - - if (UNLIKELY(normalize_v3(no) == 0.0f)) { - normalize_v3_v3(no, mv->co); - } - - normal_float_to_short_v3(mv->no, no); - } - -cleanup: - MEM_freeN(tnorms); - - if (fnors != r_faceNors) { - MEM_freeN(fnors); - } -} - void BKE_mesh_calc_normals_looptri(MVert *mverts, int numVerts, const MLoop *mloop, diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index fe9235ba59a..2a036d7f4ea 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4898,6 +4898,11 @@ static void lib_link_mesh(FileData *fd, Main *main) /* Deprecated, only kept for conversion. */ BKE_mesh_tessface_clear(me); + /* Moved from do_versions because we need updated polygons for calculating normals. */ + if (MAIN_VERSION_OLDER(main, 256, 6)) { + BKE_mesh_calc_normals(me); + } + me->id.tag &= ~LIB_TAG_NEED_LINK; } } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 6a5cfc45628..ba4dc2d33c7 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -2080,11 +2080,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } } - if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) { - Mesh *me; - - for (me = bmain->meshes.first; me; me = me->id.next) { - BKE_mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL); + if (0) { + if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) { + for (Mesh *me = bmain->meshes.first; me; me = me->id.next) { + /* Vertex normal calculation from legacy 'MFace' has been removed. + * update after calculating polygons in file reading code instead. */ + } } } |