[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36169] trunk/blender/source/blender/ blenkernel/intern/DerivedMesh.c: no functional change, avoid making stack arrays for the purpose of indexing.

Campbell Barton ideasman42 at gmail.com
Thu Apr 14 19:06:56 CEST 2011


Revision: 36169
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36169
Author:   campbellbarton
Date:     2011-04-14 17:06:55 +0000 (Thu, 14 Apr 2011)
Log Message:
-----------
no functional change, avoid making stack arrays for the purpose of indexing.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c

Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2011-04-14 16:41:17 UTC (rev 36168)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2011-04-14 17:06:55 UTC (rev 36169)
@@ -2513,9 +2513,8 @@
 {
 	//assert(vert_index>=0 && vert_index<4);
 	SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
-	unsigned int indices[] = {	pMesh->mface[face_num].v1, pMesh->mface[face_num].v2,
-								pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 };
-	VECCOPY(fPos, pMesh->mvert[indices[vert_index]].co);
+	const float *co= pMesh->mvert[(&pMesh->mface[face_num].v1)[vert_index]].co;
+	VECCOPY(fPos, co);
 }
 
 static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[], const int face_num, const int vert_index)
@@ -2528,12 +2527,9 @@
 		float * uv = pMesh->mtface[face_num].uv[vert_index];
 		fUV[0]=uv[0]; fUV[1]=uv[1];
 	}
-	else
-	{
-		unsigned int indices[] = {	pMesh->mface[face_num].v1, pMesh->mface[face_num].v2,
-									pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 };
-
-		map_to_sphere( &fUV[0], &fUV[1],pMesh->orco[indices[vert_index]][0], pMesh->orco[indices[vert_index]][1], pMesh->orco[indices[vert_index]][2]);
+	else {
+		const float *orco= pMesh->orco[(&pMesh->mface[face_num].v1)[vert_index]];
+		map_to_sphere( &fUV[0], &fUV[1], orco[0], orco[1], orco[2]);
 	}
 }
 
@@ -2541,36 +2537,30 @@
 {
 	//assert(vert_index>=0 && vert_index<4);
 	SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
-	unsigned int indices[] = {	pMesh->mface[face_num].v1, pMesh->mface[face_num].v2,
-								pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 };
 
 	const int smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH);
 	if(!smoothnormal)	// flat
 	{
-		if(pMesh->precomputedFaceNormals)
-		{
+		if(pMesh->precomputedFaceNormals) {
 			VECCOPY(fNorm, &pMesh->precomputedFaceNormals[3*face_num]);
 		}
-		else
-		{
-			float nor[3];
-			float * p0, * p1, * p2;
-			const int iGetNrVerts = pMesh->mface[face_num].v4!=0 ? 4 : 3;
-			p0 = pMesh->mvert[indices[0]].co; p1 = pMesh->mvert[indices[1]].co; p2 = pMesh->mvert[indices[2]].co;
-			if(iGetNrVerts==4)
-			{
-				float * p3 = pMesh->mvert[indices[3]].co;
-				normal_quad_v3( nor, p0, p1, p2, p3);
+		else {
+			MFace *mf= &pMesh->mface[face_num];
+			float *p0= pMesh->mvert[mf->v1].co;
+			float *p1= pMesh->mvert[mf->v2].co;
+			float *p2= pMesh->mvert[mf->v3].co;
+
+			if(mf->v4) {
+				float *p3 = pMesh->mvert[mf->v4].co;
+				normal_quad_v3(fNorm, p0, p1, p2, p3);
 			}
 			else {
-				normal_tri_v3(nor, p0, p1, p2);
+				normal_tri_v3(fNorm, p0, p1, p2);
 			}
-			VECCOPY(fNorm, nor);
 		}
 	}
-	else
-	{
-		short *no = pMesh->mvert[indices[vert_index]].no;
+	else {
+		const short *no= pMesh->mvert[(&pMesh->mface[face_num].v1)[vert_index]].no;
 		normal_short_to_float_v3(fNorm, no);
 		normalize_v3(fNorm); /* XXX, is this needed */
 	}




More information about the Bf-blender-cvs mailing list