Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 1146)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 1193)
@@ -455,5 +455,4 @@
 	getRenderQueue()->clear(); // finally clear render queue
 	if (0) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ...
-
 	if (0) WriteLog(); // write out stats
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 1189)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 1193)
@@ -793,5 +793,6 @@
 	
 		// if this a valid split => subdivide this node further
-		if (splitFurther) //-- continue subdivision
+
+		if (splitFurther)
 		{
 			newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData, coincident);
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1189)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1193)
@@ -60,8 +60,7 @@
 {
 	MailablePvsData *vdata = obj->mViewCellPvs.Find(vc);
-
+//return false;
 	if (vdata)
 	{
-		//Debug << "sumpdf: " << vdata->mSumPdf << endl;
 		// more than one view cell sees this object inside different kd cells
 		if (!checkOnlyMailed || !vdata->Mailed())
@@ -69,5 +68,5 @@
 			if (checkOnlyMailed)
 				vdata->Mail();
-
+			//Debug << "sumpdf: " << vdata->mSumPdf << endl;
 			if (vdata->mSumPdf > 1.5f) 
 				return true;
@@ -3218,4 +3217,5 @@
 	FilterRays(back, *tData.mRays, *backData.mRays);
 
+	++ mOspStats.splits[splitPlane.mAxis];
 
 	//-- eval view cells pvs
@@ -3467,4 +3467,5 @@
 	const float minBox = box.Min(axis);
 	const float maxBox = box.Max(axis);
+	Debug << "min: " << minBox << " max: " << maxBox << endl;
 
 	const float sizeBox = maxBox - minBox;
@@ -3473,12 +3474,15 @@
 	float maxBand = minBox + (1.0f - mSplitBorder) * (maxBox - minBox);
 
+	const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume();
+
 	//-- sort so we can use a sweep
 	SortSplitCandidates(tData, axis, minBand, maxBand);
 
-	float totalVol = 0;//PrepareHeuristics(tData);
+	float totalVol = 0;
 	float voll = 0;
 	float volr = totalVol;
 
 	ViewCellContainer touchedViewCells;
+	
 	const float totalRenderCost = PrepareHeuristics(tData, touchedViewCells);
 	float renderCost = totalRenderCost;
@@ -3491,4 +3495,7 @@
 
 	float sum = (float)totalVol * sizeBox;
+
+
+	Debug << "here82 render cost: " << renderCost / viewSpaceVol << endl;
 
 	/////////////////////////////////
@@ -3511,5 +3518,5 @@
 
 	debugVol = 0;
-	const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume();
+
 
 
@@ -3517,10 +3524,9 @@
 	// the sweep heuristics
 
-	Intersectable::NewMail();
-	ViewCell::NewMail();
-		
+	
 	//-- traverse through events and find best split plane
 	
 	vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end();
+	//minRenderCost = RandomValue(0,viewSpaceVol);
 
 	for (ci = mSplitCandidates->begin(); ci != ci_end; ++ ci)
@@ -3535,11 +3541,11 @@
 
 		// Note: sufficient to compare size of bounding boxes of front and back side?
-
 		if (((*ci).mPos >= minBand) && ((*ci).mPos <= maxBand))
 		{
 			float currentPos;
-			
+			Debug << "here29 : " << minRenderCost / viewSpaceVol << endl;
+
 			// HACK: current positition is BETWEEN visibility events
-			if (1 && ((*ci).mType == SortableEntry::BOX_INTERSECT) && ((ci + 1) != ci_end))
+			if (1 && /*((*ci).mType == SortableEntry::BOX_INTERSECT) &&*/ ((ci + 1) != ci_end))
 				currentPos = ((*ci).mPos + (*(ci + 1)).mPos) * 0.5f;
 			else
@@ -3549,14 +3555,14 @@
 			{
 				splitPlaneFound = true;
-				Debug << "pos: " << position << endl;
 				minRenderCost = renderCost;
 				position = currentPos;
-			}
-		}
-	}
-	
+				Debug << "pos: " << position << endl;
+			}
+		}
+	}
+//splitPlaneFound = true;
 	if (splitPlaneFound)
 	{
-		ratio = totalRenderCost / minRenderCost;
+		ratio = minRenderCost / totalRenderCost;
 	}
 
@@ -3676,5 +3682,4 @@
 								ViewCellContainer &touchedViewCells)
 {
-
 	// collect view cells and set mail + counter
 	ViewCellContainer viewCells;
@@ -3754,4 +3759,5 @@
 						  float &renderCost)
 {
+	//Debug << "add contri to obj: " << obj->mMailbox - Intersectable::sMailId << endl;
 	obj->Mail(2); // set as belonging to both leafs
 
@@ -3761,9 +3767,10 @@
 	{
 		ViewCell *vc = *vit;
+		//Debug << "here30 vc mail " << vc->mMailbox - ViewCell::sMailId << endl;
 
 		// if obj not previously associated with this view cell => increase render cost
-		if (vc->Mailed(1) && 
-			!ViewCellHasMultipleReferences(obj, vc, false))
-		{
+		if (vc->Mailed(1) && !ViewCellHasMultipleReferences(obj, vc, false))
+		{	
+			//Debug << "add to rendercost: " << vc->GetVolume() / mVspTree->GetBoundingBox().GetVolume() << endl;
 			renderCost += vc->GetVolume();
 		}
@@ -3777,16 +3784,19 @@
 								float &renderCost)
 {
+	//Debug << "subtract contri from obj: " << obj->mMailbox - Intersectable::sMailId << endl;
     obj->Mail(1); // set as belonging to back leaf
 	ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end();
-	
+    	
 	for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit)
 	{
 		ViewCell *vc = *vit;
+
+		//Debug << "here6 " << vc->mMailbox - ViewCell::sMailId << endl;
 
 		// if obj was previously associated with this view cell but is not now 
 		// => decrease render cost
-		if (vc->Mailed() && 
-			!ViewCellHasMultipleReferences(obj, vc, false))
-		{
+		if (vc->Mailed() &&	!ViewCellHasMultipleReferences(obj, vc, false))
+		{
+			//Debug << "subtract from rendercost: " << vc->GetVolume() / mVspTree->GetBoundingBox().GetVolume() << endl;
 			renderCost -= vc->GetVolume();
 		}
@@ -3803,9 +3813,9 @@
 	mVspTree->GetViewCells(VssRay(ray), viewCells);
 
-	/// classify view cells and compute volume contri accordingly
-	/// possible view cell classifications:
-	/// view cell mailed => view cell can be seen from left child node
-	/// view cell counter > 0 view cell can be seen from right child node
-	/// combined: view cell volume belongs to both nodes
+	// classify view cells and compute volume contri accordingly
+	// possible view cell classifications:
+	// view cell mailed => view cell can be seen from left child node
+	// view cell counter > 0 view cell can be seen from right child node
+	// combined: view cell volume belongs to both nodes
 	ViewCellContainer::const_iterator vit, vit_end = viewCells.end();
 	
@@ -3821,10 +3831,12 @@
 									   float &renderCost)
 {
-	// view cells can also be seen from left child node
+	//Debug << "**************" << endl;
+	//Debug << "vc contri: " << renderCost / mVspTree->GetBoundingBox().GetVolume() << " " << viewCell->mMailbox - ViewCell::sMailId << " counter: " << viewCell->mCounter << endl;
+
 	const float vol = viewCell->GetVolume();
 
 	if (viewCell->Mailed())
 	{
-		viewCell->NewMail(2); // view cell can be seen from both nodes
+		viewCell->Mail(2); // view cell can be seen from both nodes
 
         // we now see view cell from both nodes => add contri
@@ -3836,8 +3848,9 @@
 
 			// was render cost already added?
-			if (!ViewCellHasMultipleReferences(obj, viewCell, false) ||
+			if (!ViewCellHasMultipleReferences(obj, viewCell, false) &&
 				obj->Mailed(1))
 			{
-				renderCost += viewCell->GetVolume();
+				//Debug << "obj mail 1!! " << vol / mVspTree->GetBoundingBox().GetVolume() << endl;
+				renderCost += vol;
 			}
 		}
@@ -3846,5 +3859,5 @@
 	if (-- viewCell->mCounter == 0)
 	{
-		ViewCell::NewMail(1); // view cell can be seen from back node only
+		viewCell->Mail(1); // view cell can be seen from back node only
 
 		//MailablePvsData::NewMail();
@@ -3856,11 +3869,12 @@
 
 			// can render cost be be reduced?
-			if (!ViewCellHasMultipleReferences(obj, viewCell, false) ||
-				obj->Mailed())
-			{
-				renderCost -= viewCell->GetVolume();
-			}
-		}
-	}
+			if (!ViewCellHasMultipleReferences(obj, viewCell, false) &&	obj->Mailed())
+			{
+				renderCost -= vol;
+			}
+		}
+	}
+	//Debug << "new rc: " << renderCost / mVspTree->GetBoundingBox().GetVolume() << " counter2: " << viewCell->mCounter << endl;
+	//Debug << "**************"<<endl;
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h	(revision 1184)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h	(revision 1193)
@@ -34,5 +34,6 @@
   /// kd leaves that this intersectable belongs to
   //set<KdLeaf *> mKdLeaves;
-VssRayContainer mVssRays;
+  VssRayContainer mVssRays;
+
   /// # of object references
   int mReferences;
