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-03-08 13:42:45 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-03-08 19:53:31 +0300
commit2a40c6ee2bba46b4e4475c45c2d2332cb417a541 (patch)
tree85de7902067e4e79e4b992d00baa339810f559a1 /source/blender/blenkernel/intern/DerivedMesh.c
parenta8acf31181eaec62d9e838ed5879dad4285db376 (diff)
Modifier eval: add support for request poly normals layer.
Ensure we do get poly normals if they are requested in given cddata mask.
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.c')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 1fe72ce95a7..574333be70c 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1178,6 +1178,10 @@ static void mesh_calc_modifiers(
const bool do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
const bool do_loop_normals = ((((Mesh *)ob->data)->flag & ME_AUTOSMOOTH) != 0 ||
(dataMask->lmask & CD_MASK_NORMAL) != 0);
+ /* Some modifiers may need this info from their target (other) object, simpler to generate it here as well.
+ * Note that they will always be generated when no loop normals are comptuted,
+ * since they are needed by drawing code. */
+ const bool do_poly_normals = ((dataMask->pmask & CD_MASK_NORMAL) != 0);
VirtualModifierData virtualModifierData;
@@ -1580,6 +1584,12 @@ static void mesh_calc_modifiers(
}
if (do_loop_normals) {
+ /* In case we also need poly normals, add the layer here, then BKE_mesh_calc_normals_split() will fill it. */
+ if (do_poly_normals) {
+ if (!CustomData_has_layer(&(*r_final)->pdata, CD_NORMAL)) {
+ CustomData_add_layer(&(*r_final)->pdata, CD_NORMAL, CD_CALLOC, NULL, (*r_final)->totpoly);
+ }
+ }
/* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */
BKE_mesh_calc_normals_split(*r_final);
BKE_mesh_tessface_clear(*r_final);
@@ -1708,6 +1718,8 @@ static void editbmesh_calc_modifiers(
const bool do_loop_normals = ((((Mesh *)(ob->data))->flag & ME_AUTOSMOOTH) != 0 ||
(dataMask->lmask & CD_MASK_NORMAL) != 0);
+ /* Some modifiers may need this info from their target (other) object, simpler to generate it here as well. */
+ const bool do_poly_normals = ((dataMask->pmask & CD_MASK_NORMAL) != 0);
modifiers_clearErrors(ob);
@@ -1920,6 +1932,17 @@ static void editbmesh_calc_modifiers(
}
if (do_loop_normals) {
+ /* In case we also need poly normals, add the layer here, then BKE_mesh_calc_normals_split() will fill it. */
+ if (do_poly_normals) {
+ if (!CustomData_has_layer(&(*r_final)->pdata, CD_NORMAL)) {
+ CustomData_add_layer(&(*r_final)->pdata, CD_NORMAL, CD_CALLOC, NULL, (*r_final)->totpoly);
+ }
+ if (r_cage && *r_cage && (*r_cage != *r_final)) {
+ if (!CustomData_has_layer(&(*r_cage)->pdata, CD_NORMAL)) {
+ CustomData_add_layer(&(*r_cage)->pdata, CD_NORMAL, CD_CALLOC, NULL, (*r_cage)->totpoly);
+ }
+ }
+ }
/* Compute loop normals */
BKE_mesh_calc_normals_split(*r_final);
BKE_mesh_tessface_clear(*r_final);