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>2014-04-21 12:20:44 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-04-21 12:47:57 +0400
commit11cddaa5d9d69ed04b56243c11698db625acf96d (patch)
tree88120b5f170b15a968d5ddd8ed5bac85dbacb4b0 /source/blender
parent43d695e82e8f39b143f56d8f93c061d58bdddfbc (diff)
Split Normals: more fix for EditMode shading and modifiers (subsurf special case, this time).
CCGDM did not generate a valid tessellated loop normals CD layer...
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 252d5138dd2..e826b120501 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -2965,6 +2965,39 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
return origindex;
}
+ if (type == CD_TESSLOOPNORMAL) {
+ /* Create tessloopnormal on demand to save memory. */
+ /* Note that since tessellated face corners are the same a loops in CCGDM, and since all faces have four
+ * loops/corners, we can simplify the code here by converting tessloopnormals from 'short (*)[4][3]'
+ * to 'short (*)[3]'.
+ */
+ short (*tlnors)[3];
+
+ /* Avoid re-creation if the layer exists already */
+ tlnors = DM_get_tessface_data_layer(dm, CD_TESSLOOPNORMAL);
+ if (!tlnors) {
+ float (*lnors)[3];
+ short (*tlnors_it)[3];
+ const int numLoops = ccgDM_getNumLoops(dm);
+ int i;
+
+ lnors = dm->getLoopDataArray(dm, CD_NORMAL);
+ if (!lnors) {
+ return NULL;
+ }
+
+ DM_add_tessface_layer(dm, CD_TESSLOOPNORMAL, CD_CALLOC, NULL);
+ tlnors = tlnors_it = (short (*)[3])DM_get_tessface_data_layer(dm, CD_TESSLOOPNORMAL);
+
+ /* With ccgdm, we have a simple one to one mapping between loops and tessellated face corners. */
+ for (i = 0; i < numLoops; ++i, ++tlnors_it, ++lnors) {
+ normal_float_to_short_v3(*tlnors_it, *lnors);
+ }
+ }
+
+ return tlnors;
+ }
+
return DM_get_tessface_data_layer(dm, type);
}
@@ -3026,8 +3059,8 @@ static void *ccgDM_get_edge_data(DerivedMesh *dm, int index, int type)
static void *ccgDM_get_tessface_data(DerivedMesh *dm, int index, int type)
{
- if (type == CD_ORIGINDEX) {
- /* ensure creation of CD_ORIGINDEX layer */
+ if (ELEM(type, CD_ORIGINDEX, CD_TESSLOOPNORMAL)) {
+ /* ensure creation of CD_ORIGINDEX/CD_TESSLOOPNORMAL layers */
ccgDM_get_tessface_data_layer(dm, type);
}