Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 1179)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 1180)
@@ -1011,5 +1011,6 @@
 
 protected:
-#if 0
+
+#if 1
 	virtual void EvalViewCellPartition();
 #endif
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1179)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1180)
@@ -606,7 +606,7 @@
 	float sampCon = 0.0f;
 
-	//-- update pvs
 	if (updatePvs)
 	{
+		//-- update pvs of view cell
 		AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp);
 
@@ -715,6 +715,7 @@
 		float sampCon = 0.0f;
 
-
+#if 0
 		//-- store pvs optained from rays
+
 		AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp);
 
@@ -725,5 +726,5 @@
 		mVspStats.contributingSamples += conSamp;
 		mVspStats.sampleContributions += (int)sampCon;
-
+#endif
 		//-- store additional info
 		if (mStoreRays)
@@ -974,7 +975,7 @@
 
 void VspTree::AddSamplesToPvs(VspLeaf *leaf,
-							 const RayInfoContainer &rays,
-							 float &sampleContributions,
-							 int &contributingSamples)
+							  const RayInfoContainer &rays,
+							  float &sampleContributions,
+							  int &contributingSamples)
 {
 	sampleContributions = 0;
@@ -2940,4 +2941,5 @@
 	mBoundingBox = kdTree.GetBox();
 	mRoot = kdTree.GetRoot();
+
 	mSplitCandidates = new vector<SortableEntry>;
 }
@@ -2946,4 +2948,5 @@
 OspTree::~OspTree()
 {
+	// delete kd intersectables
 	KdIntersectableMap::iterator it, it_end = mKdIntersectables.end();
 
@@ -3478,8 +3481,7 @@
 
 	const float oldRenderCost = (float)totalPvs * totalVol + Limits::Small;
-	const float newRenderCost = 
-		(float)pvsFront * volFront + 
-		(float)pvsBack * volBack +
-		(float)totalPvs * frontAndBackVol;
+	const float newRenderCost = (float)pvsFront * volFront + 
+								(float)pvsBack * volBack +
+								(float)totalPvs * frontAndBackVol;
 
 
@@ -4492,4 +4494,38 @@
 
 
+float OspTree::EvalViewCellsVolume(const RayInfoContainer &rays) const
+{
+	float vol = 0;
+	ViewCell::NewMail();
+
+	RayInfoContainer::const_iterator rit, rit_end = rays.end();
+
+	for (rit = rays.begin(); rit != rays.end(); ++ rit)
+	{
+		VssRay *ray = (*rit).mRay;
+
+		if (!ray->mTerminationObject && !ray->mOriginObject)
+			continue;
+		
+		ViewCellContainer viewCells;
+		mVspTree->CastLineSegment(ray->mOrigin, ray->mTermination, viewCells);
+
+		ViewCellContainer::const_iterator vit, vit_end = viewCells.end();
+			
+		for (vit = viewCells.begin(); vit != vit_end; ++ vit)
+		{
+			ViewCell *vc = *vit;
+
+			if (!vc->Mailed())
+			{
+				vc->Mail();
+				vol += vc->GetVolume();
+			}
+		}		
+	}
+
+	return vol;
+}
+
 
 /********************************************************************/
@@ -4632,5 +4668,7 @@
 	mOspTree.EvalSplitCandidate(*oSplitCandidate);
 
-	mOspTree.mTotalCost = (float)objects.size();
+	const float vol = mOspTree.EvalViewCellsVolume(rays);
+
+	mOspTree.mTotalCost = (float)objects.size() * vol;
 	mOspTree.EvalSubdivisionStats(*oSplitCandidate);
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1179)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1180)
@@ -4884,4 +4884,5 @@
 
 	VssRayContainer::const_iterator vit, vit_end = constructionRays.end();
+
 	for (vit = constructionRays.begin(); vit != vit_end; ++ vit)
 	{
@@ -4901,5 +4902,4 @@
 
 	cout << "Computing remaining ray contributions ... ";
-
 
 	// recast rest of rays
@@ -5688,5 +5688,5 @@
 					else
 					{
-						/// get current leaf the point
+						// get current leaf the point is located in
 						KdLeaf *leaf = mOspTree->GetLeaf(ray.mTermination);
 						KdIntersectable *entry = mOspTree->GetOrCreateKdIntersectable(leaf);
@@ -5726,21 +5726,16 @@
 }
 
-#if 0
+#if 1
 void VspOspViewCellsManager::EvalViewCellPartition()
 {
 	int samplesPerPass;
 	int numSamples;
-	int castSamples = 0;
+	int castSamples = (int)storedRays.size();
 
 	char s[64]; 
-
-	Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass);
-	Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samples", numSamples);
-
 	char statsPrefix[100];
+
 	Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix);
 
-	Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl;
-	Debug << "view cell evaluation samples: " << numSamples << endl;
 	Debug << "view cell stats prefix: " << statsPrefix << endl;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h	(revision 1178)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h	(revision 1180)
@@ -1406,6 +1406,6 @@
 
 
-	/** Compute "pvs size of this object container
-		@ note bot relly pvs size just weighted sum of object taking their
+	/** Compute "pvs size" of this object container
+		@note not really pvs size just weighted sum of object taking their
 		appearances in pvss into account
 	*/
@@ -1704,4 +1704,7 @@
 		float &volRight);
 
+	float EvalViewCellsVolume(const RayInfoContainer &rays) const;
+
+
 protected:
 
