Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-02-28 22:40:21 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-02-28 22:47:50 +0300
commit993f43dc9ed30a674628299f661df0c6e6e63e36 (patch)
tree7d36f030e796392080ba8d71479098056621086a /source/blender/modifiers
parent090b8c14d2fc7e90e905906e5a7bb552583b7563 (diff)
Cleanup/refactor clnor code: add high-level helpers to set custom normals.
Now it will be simpler for code jsut wanting to preserve custom normals around to set them, without having to add same boiler plate code all the time around actual code.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 4f6276492ea..94910fbe80e 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -66,42 +66,23 @@ static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_
if (keep_clnors) {
- bool free_pnors = false;
- float (*pnors)[3] = CustomData_get_layer(&result->pdata, CD_NORMAL);
- if (pnors == NULL) {
- pnors = MEM_mallocN(sizeof(*pnors) * result->totpoly, __func__);
- BKE_mesh_calc_normals_poly(
- result->mvert, NULL, result->totvert,
- result->mloop, result->mpoly, result->totloop, result->totpoly, pnors, false);
- free_pnors = true;
- }
-
float (*lnors)[3] = CustomData_get_layer(&result->ldata, CD_NORMAL);
- short (*clnors)[2] = CustomData_get_layer(&result->ldata, CD_CUSTOMLOOPNORMAL);
- if (clnors == NULL) {
- clnors = CustomData_add_layer(&result->ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, result->totloop);
- }
+ BLI_assert(lnors != NULL);
- BKE_mesh_normals_loop_custom_set(
- result->mvert, result->totvert,
- result->medge, result->totedge,
- result->mloop, lnors, result->totloop,
- result->mpoly, pnors, result->totpoly, clnors);
+ BKE_mesh_set_custom_normals(result, lnors);
/* Do some cleanup, we do not want those temp data to stay around. */
CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
CustomData_set_layer_flag(&result->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
- if (free_pnors) {
- MEM_freeN(pnors);
- }
}
total_edges = result->totedge;
me = result->medge;
/* force drawing of all edges (seems to be omitted in CDDM_from_bmesh) */
- for (i = 0; i < total_edges; i++, me++)
+ for (i = 0; i < total_edges; i++, me++) {
me->flag |= ME_EDGEDRAW | ME_EDGERENDER;
+ }
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;