[Bf-blender-cvs] [81aedf5] cycles-ptex-06: Deduplicate code

Nicholas Bishop noreply at git.blender.org
Thu Jan 15 20:12:56 CET 2015


Commit: 81aedf53ae58db8af1e415c98db970f71cbda0ac
Author: Nicholas Bishop
Date:   Wed Jan 7 16:25:13 2015 +0100
Branches: cycles-ptex-06
https://developer.blender.org/rB81aedf53ae58db8af1e415c98db970f71cbda0ac

Deduplicate code

===================================================================

M	source/blender/blenkernel/intern/subsurf_ccg.c

===================================================================

diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index cb7b69a..6c33cb1 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -3755,25 +3755,23 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
 			/*interpolate per-face data*/
 			for (y = 0; y < gridFaces; y++) {
 				for (x = 0; x < gridFaces; x++) {
-					w2 = w + s * numVerts * g2_wid * g2_wid + (y * g2_wid + x) * numVerts;
-					CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
-					                  loopidx, w2, NULL, numVerts, loopindex2);
-					loopindex2++;
-
-					w2 = w + s * numVerts * g2_wid * g2_wid + ((y + 1) * g2_wid + (x)) * numVerts;
-					CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
-					                  loopidx, w2, NULL, numVerts, loopindex2);
-					loopindex2++;
-
-					w2 = w + s * numVerts * g2_wid * g2_wid + ((y + 1) * g2_wid + (x + 1)) * numVerts;
-					CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
-					                  loopidx, w2, NULL, numVerts, loopindex2);
-					loopindex2++;
-					
-					w2 = w + s * numVerts * g2_wid * g2_wid + ((y) * g2_wid + (x + 1)) * numVerts;
-					CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
-					                  loopidx, w2, NULL, numVerts, loopindex2);
-					loopindex2++;
+					int x2, y2;
+					for (x2 = 0; x2 <= 1; x2++) {
+						for (y2 = 0; y2 <= 1; y2++) {
+							/* This gives the (x,y) pattern:
+							 * (0,0) (0,1) (1,1) (1,0) */
+							int y3 = (x2 == 0) ? y2 : 1 - y2;
+
+							/* Pointer arithmetic */
+							w2 = w + (s * numVerts * g2_wid * g2_wid +
+							          ((y + y3) * g2_wid +
+							           (x + x2)) * numVerts);
+
+							CustomData_interp(&dm->loopData, &ccgdm->dm.loopData,
+							                  loopidx, w2, NULL, numVerts, loopindex2);
+							loopindex2++;
+						}
+					}
 
 					/*copy over poly data, e.g. mtexpoly*/
 					CustomData_copy_data(&dm->polyData, &ccgdm->dm.polyData, origIndex, faceNum, 1);




More information about the Bf-blender-cvs mailing list