[Bf-blender-cvs] [1e55222] temp-derivedmesh-looptri: Fix for DM_draw_attrib_vertex which was temp disabled

Campbell Barton noreply at git.blender.org
Wed Jul 15 09:30:48 CEST 2015


Commit: 1e55222709bd0190b60f520c2d21e9078324318b
Author: Campbell Barton
Date:   Wed Jul 15 17:25:39 2015 +1000
Branches: temp-derivedmesh-looptri
https://developer.blender.org/rB1e55222709bd0190b60f520c2d21e9078324318b

Fix for DM_draw_attrib_vertex which was temp disabled

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

M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/cdderivedmesh.c
M	source/blender/blenkernel/intern/subsurf_ccg.c

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

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index c8068c2..d8b5a22 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -758,7 +758,7 @@ void DM_vertex_attributes_from_gpu(
         DerivedMesh *dm,
         struct GPUVertexAttribs *gattribs, DMVertexAttribs *attribs);
 
-void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert);
+void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert, int loop);
 
 void DM_add_tangent_layer(DerivedMesh *dm);
 void DM_calc_auto_bump_scale(DerivedMesh *dm);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index a75442e..94f3489 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -3339,14 +3339,15 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
 	}
 }
 
-#if 0
-/* Set vertex shader attribute inputs for a particular tessface vert
+/**
+ * Set vertex shader attribute inputs for a particular tessface vert
  *
- * a: tessface index
- * index: vertex index
- * vert: corner index (0, 1, 2, 3)
+ * \param a: tessface index
+ * \param index: vertex index
+ * \param vert: corner index (0, 1, 2, 3)
+ * \param loop: absolute loop corner index
  */
-void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert)
+void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert, int loop)
 {
 	const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 	int b;
@@ -3366,9 +3367,10 @@ void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert)
 	for (b = 0; b < attribs->tottface; b++) {
 		const float *uv;
 
+
 		if (attribs->tface[b].array) {
-			MTFace *tf = &attribs->tface[b].array[a];
-			uv = tf->uv[vert];
+			MLoopUV *mloopuv = &attribs->tface[b].array[loop];
+			uv = mloopuv->uv;
 		}
 		else {
 			uv = zero;
@@ -3385,8 +3387,8 @@ void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert)
 		GLubyte col[4];
 
 		if (attribs->mcol[b].array) {
-			MCol *cp = &attribs->mcol[b].array[a * 4 + vert];
-			col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a;
+			MLoopCol *cp = &attribs->mcol[b].array[loop];
+			col[0] = cp->r; col[1] = cp->g; col[2] = cp->b; col[3] = cp->a;
 		}
 		else {
 			col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0;
@@ -3402,14 +3404,6 @@ void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert)
 		glVertexAttrib4fvARB(attribs->tang.gl_index, tang);
 	}
 }
-#else
-
-void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert)
-{
-	UNUSED_VARS(attribs, a, index, vert);
-}
-
-#endif
 
 /* Set object's bounding box based on DerivedMesh min/max data */
 void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 1f87483..51552a9 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -841,10 +841,11 @@ static void cdDM_drawMappedFacesTex(
 	cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData, flag);
 }
 
-static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, const MVert *mvert, int a, int index, int vert,
-                                    const float *lnor, const bool smoothnormal)
+static void cddm_draw_attrib_vertex(
+        DMVertexAttribs *attribs, const MVert *mvert, int a, int index, int loop, int vert,
+        const float *lnor, const bool smoothnormal)
 {
-	DM_draw_attrib_vertex(attribs, a, index, vert);
+	DM_draw_attrib_vertex(attribs, a, index, vert, loop);
 
 	/* vertex normal */
 	if (lnor) {
@@ -967,9 +968,9 @@ static void cdDM_drawMappedFacesGLSL(
 				ln3 = lnors[ltri[2]];
 			}
 			
-			cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[0], 0, ln1, smoothnormal);
-			cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[1], 1, ln2, smoothnormal);
-			cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[2], 2, ln3, smoothnormal);
+			cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[0], ltri[0], 0, ln1, smoothnormal);
+			cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[1], ltri[1], 1, ln2, smoothnormal);
+			cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[2], ltri[2], 2, ln3, smoothnormal);
 		}
 		glEnd();
 	}
@@ -1230,9 +1231,9 @@ static void cdDM_drawMappedFacesMat(
 		}
 
 		/* vertices */
-		cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[0], 0, ln1, smoothnormal);
-		cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[1], 1, ln2, smoothnormal);
-		cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[2], 2, ln3, smoothnormal);
+		cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[0], ltri[0], 0, ln1, smoothnormal);
+		cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[1], ltri[1], 1, ln2, smoothnormal);
+		cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[2], ltri[2], 2, ln3, smoothnormal);
 	}
 	glEnd();
 
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 5489e6d..21ec0ea 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -2299,7 +2299,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
 		index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize);   \
 	else                                                                      \
 		index = 0;                                                            \
-	DM_draw_attrib_vertex(&attribs, a, index, vert);                          \
+	DM_draw_attrib_vertex(&attribs, a, index, vert, (a * 4) + vert);          \
 } (void)0
 
 	totface = ccgSubSurf_getNumFaces(ss);
@@ -2426,7 +2426,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
 						glVertex3fv(bco);
 						PASSATTRIB(0, 0, 0);
 						glVertex3fv(aco);
-						
+
 						a++;
 					}
 				}
@@ -2470,7 +2470,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
 		index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize);   \
 	else                                                                      \
 		index = 0;                                                            \
-	DM_draw_attrib_vertex(&attribs, a, index, vert);                          \
+	DM_draw_attrib_vertex(&attribs, a, index, vert, (a * 4) + vert);          \
 } (void)0
 
 	totface = ccgSubSurf_getNumFaces(ss);




More information about the Bf-blender-cvs mailing list