[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12673] branches/cloth/blender/intern/ elbeem/intern/isosurface.cpp: ccherrett pre-alpha subsurf openmp code

Daniel Genrich daniel.genrich at gmx.net
Mon Nov 26 01:26:29 CET 2007


Revision: 12673
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12673
Author:   genscher
Date:     2007-11-26 01:26:29 +0100 (Mon, 26 Nov 2007)

Log Message:
-----------
ccherrett pre-alpha subsurf openmp code

Modified Paths:
--------------
    branches/cloth/blender/intern/elbeem/intern/isosurface.cpp

Modified: branches/cloth/blender/intern/elbeem/intern/isosurface.cpp
===================================================================
--- branches/cloth/blender/intern/elbeem/intern/isosurface.cpp	2007-11-25 21:14:52 UTC (rev 12672)
+++ branches/cloth/blender/intern/elbeem/intern/isosurface.cpp	2007-11-26 00:26:29 UTC (rev 12673)
@@ -156,13 +156,6 @@
 		mpEdgeVerticesZ[i] = -1;
 	}
 
-	ntlVec3Gfx pos[8];
-	float value[8];
-	int cubeIndex;      // index entry of the cube 
-	int triIndices[12]; // vertex indices 
-	int *eVert[12];
-	IsoLevelVertex ilv;
-
 	// edges between which points?
 	const int mcEdges[24] = { 
 		0,1,  1,2,  2,3,  3,0,
@@ -189,7 +182,12 @@
 				px = mStart[0]-gsx*0.5;
 				for(int i=1;i<(mSizex-2);i++) {
 					px += gsx;
-
+					int cubeIndex;      // index entry of the cube 
+					float value[8];
+					int triIndices[12]; // vertex indices 
+					int *eVert[12];
+					IsoLevelVertex ilv;
+					
 					value[0] = *getData(i  ,j  ,k  );
 					value[1] = *getData(i+1,j  ,k  );
 					value[2] = *getData(i+1,j+1,k  );
@@ -235,6 +233,7 @@
 					eVert[11] = &mpEdgeVerticesZ[ ISOLEVEL_INDEX( i+0, j+1, edgek+0) ];
 
 					// grid positions
+					ntlVec3Gfx pos[8];
 					pos[0] = ntlVec3Gfx(px    ,py    ,pz);
 					pos[1] = ntlVec3Gfx(px+gsx,py    ,pz);
 					pos[2] = ntlVec3Gfx(px+gsx,py+gsy,pz);
@@ -340,10 +339,7 @@
 		if(mUseFullEdgeArrays) {
 			errMsg("IsoSurface::triangulate","Disabling mUseFullEdgeArrays!");
 		}
-
-		// subdiv local arrays
-		gfxReal orgval[8];
-		gfxReal subdAr[2][11][11]; // max 10 subdivs!
+		
 		ParticleObject* *arppnt = new ParticleObject*[mSizez*mSizey*mSizex];
 
 		// construct pointers
@@ -404,13 +400,27 @@
 
 		debMsgStd("IsoSurface::triangulate",DM_MSG,"Starting. Parts in use:"<<pInUse<<", Subdivs:"<<mSubdivs, 9);
 		pz = mStart[2]-(double)(0.*gsz)-0.5*orgGsz;
+/*
+#pragma omp parallel
+{
+	vector<IsoLevelVertex> mPoints;
+	*/
+#pragma omp parallel for
 		for(int ok=1;ok<(mSizez-2)*mSubdivs;ok++) {
 			pz += gsz;
 			const int k = ok/mSubdivs;
 			if(k<=0) continue; // skip zero plane
 			for(int j=1;j<(mSizey-2);j++) {
 				for(int i=1;i<(mSizex-2);i++) {
-
+					float value[8];
+					ntlVec3Gfx pos[8];
+					int cubeIndex;      // index entry of the cube 
+					int triIndices[12]; // vertex indices 
+					int *eVert[12];
+					IsoLevelVertex ilv;
+					gfxReal orgval[8];
+					gfxReal subdAr[2][11][11]; // max 10 subdivs!
+					
 					orgval[0] = *getData(i  ,j  ,k  );
 					orgval[1] = *getData(i+1,j  ,k  );
 					orgval[2] = *getData(i+1,j+1,k  ); // with subdivs
@@ -422,6 +432,7 @@
 
 					// prebuild subsampled array slice
 					const int sdkOffset = ok-k*mSubdivs; 
+
 					for(int sdk=0; sdk<2; sdk++) 
 						for(int sdj=0; sdj<mSubdivs+1; sdj++) 
 							for(int sdi=0; sdi<mSubdivs+1; sdi++) {
@@ -576,8 +587,11 @@
 
 										// init isolevel vertex
 										ilv.v = p1 + (p2-p1)*mu; // with subdivs
+#pragma omp critical 
+										{
 										mPoints.push_back( ilv );
 										triIndices[e] = (mPoints.size()-1);
+										}
 										// store vertex 
 										*eVert[ e ] = triIndices[e]; 
 									}	else {
@@ -587,7 +601,8 @@
 								} // along all edges 
 							}
 							// removed cutoff treatment...
-
+#pragma omp critical 
+							{
 							// Create the triangles... 
 							for(int e=0; mcTriTable[cubeIndex][e]!=-1; e+=3) {
 								mIndices.push_back( triIndices[ mcTriTable[cubeIndex][e+0] ] );
@@ -595,7 +610,7 @@
 								mIndices.push_back( triIndices[ mcTriTable[cubeIndex][e+2] ] );
 								//errMsg("TTT"," i1"<<mIndices[mIndices.size()-3]<<" "<< " i2"<<mIndices[mIndices.size()-2]<<" "<< " i3"<<mIndices[mIndices.size()-1]<<" "<< mIndices.size() );
 							}
-
+							}
 							} // triangles in edge table?
 							
 						}//si
@@ -603,7 +618,9 @@
 
 				}//i
 			}// j
-
+#pragma omp barrier
+#pragma omp critical 
+			{
 			// copy edge arrays
 			for(int j=0;j<(mSizey-0)*mSubdivs;j++) 
 				for(int i=0;i<(mSizex-0)*mSubdivs;i++) {
@@ -617,9 +634,13 @@
 					mpEdgeVerticesY[ src ]=-1; // with subdivs
 					mpEdgeVerticesZ[ src ]=-1;
 				}
+			}
 			// */
 
 		} // ok, k subdiv loop
+		
+		// push_back()'s
+// }
 
 		//delete [] subdAr;
 		delete [] arppnt;





More information about the Bf-blender-cvs mailing list