[Bf-blender-cvs] [ed38d0c25da] master: Cleanup: split BKE_mesh_calc_normals_poly function in two
Campbell Barton
noreply at git.blender.org
Fri Aug 13 05:34:13 CEST 2021
Commit: ed38d0c25da27c8fe6b3db76dbe024f33f82e338
Author: Campbell Barton
Date: Fri Aug 13 13:23:45 2021 +1000
Branches: master
https://developer.blender.org/rBed38d0c25da27c8fe6b3db76dbe024f33f82e338
Cleanup: split BKE_mesh_calc_normals_poly function in two
Remove the 'only_face_normals' argument.
- BKE_mesh_calc_normals_poly for polygon normals.
- BKE_mesh_calc_normals_poly_and_vertex for poly and vertex normals.
Order arguments logically:
- Pair array and length arguments.
- Position normal array arguments (to be filled) last.
===================================================================
M source/blender/blenkernel/BKE_mesh.h
M source/blender/blenkernel/intern/DerivedMesh.cc
M source/blender/blenkernel/intern/data_transfer.c
M source/blender/blenkernel/intern/key.c
M source/blender/blenkernel/intern/mesh.c
M source/blender/blenkernel/intern/mesh_mirror.c
M source/blender/blenkernel/intern/mesh_normals.cc
M source/blender/blenkernel/intern/mesh_remap.c
M source/blender/editors/mesh/mesh_data.c
M source/blender/modifiers/intern/MOD_normal_edit.c
M source/blender/modifiers/intern/MOD_solidify_extrude.c
M source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
M source/blender/modifiers/intern/MOD_weighted_normal.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index ef1384c804b..4eb3e6a3136 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -305,15 +305,21 @@ void BKE_mesh_calc_normals_mapping_ex(struct MVert *mverts,
const int *origIndexFace,
float (*r_faceNors)[3],
const bool only_face_normals);
-void BKE_mesh_calc_normals_poly(struct MVert *mverts,
- float (*r_vertnors)[3],
- int numVerts,
+void BKE_mesh_calc_normals_poly(const struct MVert *mvert,
+ int mvert_len,
const struct MLoop *mloop,
- const struct MPoly *mpolys,
- int numLoops,
- int numPolys,
- float (*r_polyNors)[3],
- const bool only_face_normals);
+ int mloop_len,
+ const struct MPoly *mpoly,
+ int mpoly_len,
+ float (*r_poly_normals)[3]);
+void BKE_mesh_calc_normals_poly_and_vertex(struct MVert *mvert,
+ int mvert_len,
+ const struct MLoop *mloop,
+ int mloop_len,
+ const struct MPoly *mpolys,
+ int mpoly_len,
+ float (*r_poly_normals)[3],
+ float (*r_vert_normals)[3]);
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);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index 4480b0d34fc..59e81938e79 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -816,15 +816,14 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input,
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(mesh_final->mvert,
- nullptr,
- mesh_final->totvert,
- mesh_final->mloop,
- mesh_final->mpoly,
- mesh_final->totloop,
- mesh_final->totpoly,
- polynors,
- false);
+ 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);
}
}
@@ -1536,15 +1535,14 @@ static void editbmesh_calc_modifier_final_normals(Mesh *mesh_final,
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(mesh_final->mvert,
- nullptr,
- mesh_final->totvert,
- mesh_final->mloop,
- mesh_final->mpoly,
- mesh_final->totloop,
- mesh_final->totpoly,
- polynors,
- false);
+ 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);
}
}
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 605061570b8..b83621e8b79 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -301,14 +301,12 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
}
if (dirty_nors_dst || do_poly_nors_dst) {
BKE_mesh_calc_normals_poly(verts_dst,
- NULL,
num_verts_dst,
loops_dst,
- polys_dst,
num_loops_dst,
+ polys_dst,
num_polys_dst,
- poly_nors_dst,
- true);
+ poly_nors_dst);
}
/* Cache loop nors into a temp CDLayer. */
loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL);
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 0f8c9bad798..724216bee6c 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -2281,15 +2281,8 @@ void BKE_keyblock_mesh_calc_normals(struct KeyBlock *kb,
r_polynors = MEM_mallocN(sizeof(float[3]) * me.totpoly, __func__);
free_polynors = true;
}
- BKE_mesh_calc_normals_poly(me.mvert,
- r_vertnors,
- me.totvert,
- me.mloop,
- me.mpoly,
- me.totloop,
- me.totpoly,
- r_polynors,
- false);
+ BKE_mesh_calc_normals_poly_and_vertex(
+ me.mvert, me.totvert, me.mloop, me.totloop, me.mpoly, me.totpoly, r_polynors, r_vertnors);
if (r_loopnors) {
short(*clnors)[2] = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL); /* May be NULL. */
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 4aef0f346c3..b32d58de1e2 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1890,15 +1890,14 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
}
else {
polynors = MEM_malloc_arrayN(mesh->totpoly, sizeof(float[3]), __func__);
- BKE_mesh_calc_normals_poly(mesh->mvert,
- NULL,
- mesh->totvert,
- mesh->mloop,
- mesh->mpoly,
- mesh->totloop,
- mesh->totpoly,
- polynors,
- false);
+ BKE_mesh_calc_normals_poly_and_vertex(mesh->mvert,
+ mesh->totvert,
+ mesh->mloop,
+ mesh->totloop,
+ mesh->mpoly,
+ mesh->totpoly,
+ polynors,
+ NULL);
free_polynors = true;
}
diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c
index 9aeaa1ada52..b20d81e7b9c 100644
--- a/source/blender/blenkernel/intern/mesh_mirror.c
+++ b/source/blender/blenkernel/intern/mesh_mirror.c
@@ -393,15 +393,14 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
/* calculate custom normals into loop_normals, then mirror first half into second half */
- BKE_mesh_calc_normals_poly(result->mvert,
- NULL,
- result->totvert,
- result->mloop,
- result->mpoly,
- totloop,
- totpoly,
- poly_normals,
- false);
+ BKE_mesh_calc_normals_poly_and_vertex(result->mvert,
+ result->totvert,
+ result->mloop,
+ totloop,
+ result->mpoly,
+ totpoly,
+ poly_normals,
+ NULL);
BKE_mesh_normals_loop_split(result->mvert,
result->totvert,
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc
index b86332097fa..fe28f10d2db 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -102,7 +102,9 @@ static void add_v3_v3_atomic(float r[3], const float a[3])
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Mesh Normal Calculation
+/** \name Public Utility Functions
+ *
+ * Related to managing normals but not directly related to calculating normals.
* \{ */
void BKE_mesh_normals_tag_dirty(Mesh *mesh)
@@ -111,6 +113,205 @@ void BKE_mesh_norm
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list