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/makesrna/intern/rna_mesh_api.c
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/makesrna/intern/rna_mesh_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c36
1 files changed, 2 insertions, 34 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index 444831cb75d..7bedd110947 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -112,43 +112,11 @@ static void rna_Mesh_calc_smooth_groups(Mesh *mesh, bool use_bitflags, int *r_po
static void rna_Mesh_normals_split_custom_do(Mesh *mesh, float (*custom_loopnors)[3], const bool use_vertices)
{
- float (*polynors)[3];
- short (*clnors)[2];
- const int numloops = mesh->totloop;
- bool free_polynors = false;
-
- clnors = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);
- if (clnors) {
- memset(clnors, 0, sizeof(*clnors) * numloops);
- }
- else {
- clnors = CustomData_add_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL, CD_DEFAULT, NULL, numloops);
- }
-
- if (CustomData_has_layer(&mesh->pdata, CD_NORMAL)) {
- polynors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
- }
- else {
- polynors = MEM_mallocN(sizeof(float[3]) * mesh->totpoly, __func__);
- BKE_mesh_calc_normals_poly(
- mesh->mvert, NULL, mesh->totvert,
- mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, polynors, false);
- free_polynors = true;
- }
-
if (use_vertices) {
- BKE_mesh_normals_loop_custom_from_vertices_set(
- mesh->mvert, custom_loopnors, mesh->totvert, mesh->medge, mesh->totedge, mesh->mloop, mesh->totloop,
- mesh->mpoly, (const float (*)[3])polynors, mesh->totpoly, clnors);
+ BKE_mesh_set_custom_normals_from_vertices(mesh, custom_loopnors);
}
else {
- BKE_mesh_normals_loop_custom_set(
- mesh->mvert, mesh->totvert, mesh->medge, mesh->totedge, mesh->mloop, custom_loopnors, mesh->totloop,
- mesh->mpoly, (const float (*)[3])polynors, mesh->totpoly, clnors);
- }
-
- if (free_polynors) {
- MEM_freeN(polynors);
+ BKE_mesh_set_custom_normals(mesh, custom_loopnors);
}
}