Cleanup: remove BKE_mesh_calc_normals_tessface
This was used for versioning, now normals are calculated after initializing MPoly data.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user