Index: trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env	(revision 544)
+++ trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env	(revision 545)
@@ -30,5 +30,5 @@
 	samplesPerPass  100000
 	initialSamples 300000
-	vssSamples 1000000
+	vssSamples 1200000
 	vssSamplesPerPass 100000
 	useImportanceSampling true
@@ -259,5 +259,5 @@
 VspBspTree {
 	Construction {
-		samples 600000
+		samples 100000
 		epsilon 0.005
 		randomize false
@@ -298,10 +298,10 @@
 		#minArea 		0.0001
 		minArea 		-1
-		maxRayContribution	0.2
+		maxRayContribution	0.3
 		maxCostRatio		0.9
 		missTolerance		3
 		#maxAccRayLength	100
 		
-		maxViewCells		6001
+		maxViewCells		501
 		
 		# used for pvs criterium
Index: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h	(revision 544)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h	(revision 545)
@@ -61,5 +61,6 @@
 	/** Computes mass center of bsp node geometry.
 	*/
-	Vector3 ComputeMassCenter() const;
+	Vector3 CenterOfMass() const;
+
 	/** The polygons the geometry consists of.
 	*/
Index: trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp	(revision 544)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp	(revision 545)
@@ -605,6 +605,8 @@
 										   mEpsilon);
 		
-			frontData.mArea = frontData.mGeometry->GetArea();
-			backData.mArea = backData.mGeometry->GetArea();
+			//frontData.mArea = frontData.mGeometry->GetArea();
+			//backData.mArea = backData.mGeometry->GetArea();
+			frontData.mArea = frontData.mGeometry->GetVolume();
+			backData.mArea = backData.mGeometry->GetVolume();
 		}
 	}
@@ -851,5 +853,5 @@
 	int bestAxis = -1;
 
-	// create bounding box of node extent
+	// create bounding box of node geometry
 	AxisAlignedBox3 box;
 	box.Initialize();
@@ -877,5 +879,5 @@
 		nBackGeom[axis] = new BspNodeGeometry();
 
-		if (!mOnlyDrivingAxis || axis == sAxis)
+		if (!mOnlyDrivingAxis || (axis == sAxis))
 		{
 			if (!useCostHeuristics)
@@ -894,9 +896,9 @@
 					
 					pos = box.Max(); pos[axis] = nPosition[axis];
-					AxisAlignedBox3 backBox(box.Min(), pos);
+					const AxisAlignedBox3 backBox(box.Min(), pos);
 					backBox.ExtractPolys(nBackGeom[axis]->mPolys);
 					
 					pos = box.Min(); pos[axis] = nPosition[axis];
-					AxisAlignedBox3 frontBox(pos, box.Max());
+					const AxisAlignedBox3 frontBox(pos, box.Max());
 					frontBox.ExtractPolys(nFrontGeom[axis]->mPolys);
 
@@ -1107,9 +1109,9 @@
 		// we can do this because we always save the
 		// computed values from the axis aligned splits
-		/*frontData.mGeometry = fGeom;
+		frontData.mGeometry = fGeom;
 		backData.mGeometry = bGeom;
 		frontData.mArea = fArea;
 		backData.mArea = bArea;
-*/
+
 		//! error also computed if cost ratio is missed
 		++ mStat.splits[axis];
@@ -1301,28 +1303,13 @@
 										  mBox,
 										  mEpsilon);
-#if 0
-			AxisAlignedBox3 fbox;
-			AxisAlignedBox3 bbox;
-			AxisAlignedBox3 box;
-			fbox.Initialize();
-			bbox.Initialize();
-			box.Initialize();
-
-			geomFront.IncludeInBox(fbox);
-			geomBack.IncludeInBox(bbox);
-			data.mGeometry->IncludeInBox(box);
-
-			areaFront = fbox.GetVolume();
-			areaBack = bbox.GetVolume();
-
-			pOverall = box.GetVolume();
-#else
-			areaFront = geomFront.GetArea();
-			areaBack = geomBack.GetArea();
+
+			
+			pFront = geomFront.GetVolume();
+			pBack = geomBack.GetVolume();
+			//areaFront = geomFront.GetArea();
+			//areaBack = geomBack.GetArea();
 
 			pOverall = data.mArea;
-#endif
-			pBack = areaBack;
-			pFront = areaFront;
+
 		}
 		else // use number of rays to approximate volume
Index: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 544)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 545)
@@ -1167,4 +1167,5 @@
 }
 
+
 Plane3 BspTree::SelectPlane(BspLeaf *leaf, BspTraversalData &data)
 {
@@ -1553,5 +1554,5 @@
 	}
 			
-	bool useRand;;
+	bool useRand;
 	int limit;
 
@@ -2559,22 +2560,27 @@
 	PolygonContainer::const_iterator pit, pit_end = mPolys.end();
 
+	// note: can take arbitrary point, e.g., the origin. However,
+	// center of mass prevents precision errors
+	const Vector3 center = CenterOfMass();
+
 	for (pit = mPolys.begin(); pit != pit_end; ++ pit)
 	{
 		Polygon3 *poly = *pit;
-		const Vector3 v = poly->mVertices[0];
+		const Vector3 v0 = poly->mVertices[0] - center;
 
 		for (int i = 1; i < (int)poly->mVertices.size() - 1; ++ i)
 		{
-			volume += f * (DotProd(v, 
-				CrossProd(poly->mVertices[i], poly->mVertices[i + 1])));
-		}
-	}
-
-	Debug << "volume: " << volume << endl;
+			const Vector3 v1 = poly->mVertices[i] - center;
+			const Vector3 v2 = poly->mVertices[i + 1] - center;
+
+			volume += f * (DotProd(v0, CrossProd(v1, v2)));
+		}
+	}
+
 	return volume;
 }
 
 
-Vector3 BspNodeGeometry::ComputeMassCenter() const
+Vector3 BspNodeGeometry::CenterOfMass() const
 {
 	int n = 0;
Index: trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp	(revision 542)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp	(revision 545)
@@ -2038,47 +2038,47 @@
 	polys.push_back(face1);   
 
-    face1->mVertices.push_back(Vector3(mMin.x,mMin.y,mMax.z));
-	face1->mVertices.push_back(Vector3(mMin.x,mMax.y,mMax.z));
-	face1->mVertices.push_back(Vector3(mMin.x,mMax.y,mMin.z));
-	face1->mVertices.push_back(Vector3(mMin.x,mMin.y,mMin.z));
+    face1->mVertices.push_back(Vector3(mMin.x, mMin.y, mMax.z));
+	face1->mVertices.push_back(Vector3(mMin.x, mMax.y, mMax.z));
+	face1->mVertices.push_back(Vector3(mMin.x, mMax.y ,mMin.z));
+	face1->mVertices.push_back(Vector3(mMin.x, mMin.y, mMin.z));
 
 	Polygon3 *face2 = new Polygon3();  
 	polys.push_back(face2);
-
-    face2->mVertices.push_back(Vector3(mMax.x,mMin.y,mMin.z));
-    face2->mVertices.push_back(Vector3(mMax.x,mMax.y,mMin.z));
-    face2->mVertices.push_back(Vector3(mMax.x,mMax.y,mMax.z));
-    face2->mVertices.push_back(Vector3(mMax.x,mMin.y,mMax.z));
+    
+    face2->mVertices.push_back(Vector3(mMax.x, mMin.y, mMin.z));
+    face2->mVertices.push_back(Vector3(mMax.x, mMax.y, mMin.z));
+    face2->mVertices.push_back(Vector3(mMax.x, mMax.y, mMax.z));
+    face2->mVertices.push_back(Vector3(mMax.x, mMin.y, mMax.z));
   
 	Polygon3 *face3 = new Polygon3();  
 	polys.push_back(face3);
 
-    face3->mVertices.push_back(Vector3(mMax.x,mMin.y,mMin.z));
-	face3->mVertices.push_back(Vector3(mMax.x,mMin.y,mMax.z));
-	face3->mVertices.push_back(Vector3(mMin.x,mMin.y,mMax.z));
-	face3->mVertices.push_back(Vector3(mMin.x,mMin.y,mMin.z));
+    face3->mVertices.push_back(Vector3(mMax.x, mMin.y ,mMin.z));
+	face3->mVertices.push_back(Vector3(mMax.x, mMin.y, mMax.z));
+	face3->mVertices.push_back(Vector3(mMin.x, mMin.y, mMax.z));
+	face3->mVertices.push_back(Vector3(mMin.x, mMin.y, mMin.z));
 
 	Polygon3 *face4 = new Polygon3();  
 	polys.push_back(face4);
 
-	face4->mVertices.push_back(Vector3(mMin.x,mMax.y,mMin.z));
-	face4->mVertices.push_back(Vector3(mMin.x,mMax.y,mMax.z));
-	face4->mVertices.push_back(Vector3(mMax.x,mMax.y,mMax.z));
-	face4->mVertices.push_back(Vector3(mMax.x,mMax.y,mMin.z));
+	face4->mVertices.push_back(Vector3(mMin.x, mMax.y, mMin.z));
+	face4->mVertices.push_back(Vector3(mMin.x, mMax.y, mMax.z));
+	face4->mVertices.push_back(Vector3(mMax.x, mMax.y, mMax.z));
+	face4->mVertices.push_back(Vector3(mMax.x, mMax.y, mMin.z));
     
 	Polygon3 *face5 = new Polygon3();  
 	polys.push_back(face5);
 
-	face5->mVertices.push_back(Vector3(mMin.x,mMax.y,mMin.z));
-    face5->mVertices.push_back(Vector3(mMax.x,mMax.y,mMin.z));
-    face5->mVertices.push_back(Vector3(mMax.x,mMin.y,mMin.z));
-	face5->mVertices.push_back(Vector3(mMin.x,mMin.y,mMin.z));
+	face5->mVertices.push_back(Vector3(mMin.x, mMax.y, mMin.z));
+    face5->mVertices.push_back(Vector3(mMax.x, mMax.y, mMin.z));
+    face5->mVertices.push_back(Vector3(mMax.x, mMin.y, mMin.z));
+	face5->mVertices.push_back(Vector3(mMin.x, mMin.y, mMin.z));
 
 	Polygon3 *face6 = new Polygon3();  
 	polys.push_back(face6);  
   
-    face6->mVertices.push_back(Vector3(mMin.x,mMin.y,mMax.z));
-    face6->mVertices.push_back(Vector3(mMax.x,mMin.y,mMax.z));
-    face6->mVertices.push_back(Vector3(mMax.x,mMax.y,mMax.z));
-    face6->mVertices.push_back(Vector3(mMin.x,mMax.y,mMax.z));
-}
+    face6->mVertices.push_back(Vector3(mMin.x, mMin.y, mMax.z));
+    face6->mVertices.push_back(Vector3(mMax.x, mMin.y, mMax.z));
+    face6->mVertices.push_back(Vector3(mMax.x, mMax.y, mMax.z));
+    face6->mVertices.push_back(Vector3(mMin.x, mMax.y, mMax.z));
+}
