Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/preprocess_visibility_internal.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/preprocess_visibility_internal.sh	(revision 2211)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/preprocess_visibility_internal.sh	(revision 2227)
@@ -14,5 +14,5 @@
 
 NUM_SAMPLE_RAYS=200000000
-#NUM_SAMPLE_RAYS=50000000
+NUM_SAMPLE_RAYS=50000000
 
 $PREPROCESSOR -total_samples=$NUM_SAMPLE_RAYS \
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h	(revision 2224)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h	(revision 2227)
@@ -40,5 +40,7 @@
 	/** Evaluate this candidate and put results into queue for further traversal.
 	*/
-	virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet, SubdivisionCandidateContainer &dirtyList) = 0;
+	virtual bool Apply(SplitQueue &splitQueue, 
+					   bool terminationCriteriaMet, 
+					   SubdivisionCandidateContainer &dirtyList) = 0;
 	
 	/** Returns true of the global termination criteria of this split were met,
@@ -74,7 +76,23 @@
 	}
 	
+	/** The average ray contribution of this candidate .
+		This is somewhat of a confidence value into the computed values. If
+		it is high, there is likely to be a lot of undersampling.
+	*/
+	inline void SetAvgRaysPerObject(const float raysPerObject)
+	{
+		mAvgRaysPerObject = raysPerObject;
+
+	}
 	inline float GetAvgRayContribution() const
 	{
 		return mAvgRayContribution;
+	}
+
+	/** Returns average rays per object.
+	*/
+	float GetAvgRaysPerObject() const
+	{
+		return (float)mAvgRaysPerObject;
 	}
 
@@ -165,4 +183,7 @@
 	float mAvgRayContribution;
 
+	/// the average ray contribution of this candidate 
+	float mAvgRaysPerObject;
+
 	int mMailbox;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2224)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2227)
@@ -127,4 +127,5 @@
 
 		float mem;
+		float renderCostRatio;
 	};
   
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 2130)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 2227)
@@ -2775,13 +2775,13 @@
 					"true");
 
-	RegisterOption("Hierarchy.Construction.maxAvgRayContri",
-					optFloat,
-					"hierarchy_construction_max_avg_raycontri=",
-					"99999.0");
-	
-	RegisterOption("Hierarchy.Construction.minAvgRayContri",
-					optFloat,
-					"hierarchy_construction_min_avg_raycontri=",
-					"99990.0");
+	RegisterOption("Hierarchy.Construction.maxAvgRaysPerObject",
+					optFloat,
+					"hierarchy_construction_max_avg_rays_per_object=",
+					"2");
+	
+	RegisterOption("Hierarchy.Construction.minAvgRaysPerObject",
+					optFloat,
+					"hierarchy_construction_min_avg_rays_per_object=",
+					"1");
 	
 	RegisterOption("Hierarchy.useTraversalTree",
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 2224)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 2227)
@@ -47,5 +47,10 @@
 
 #define COUNT_ORIGIN_OBJECTS 1
-#define USE_AVGRAYCONTRI 1
+#define USE_AVGRAYCONTRI 0
+
+#define BOUND_RENDERCOST 0
+
+static const float MIN_RENDERCOST = 100.0f;
+
 
 
@@ -308,5 +313,5 @@
 	float EvalCorrectedPvs(const float pvsFront, 
 						   const float totalPvs,
-						   const float avgRayContri) const;
+						   const float raysPerObjects) const;
 
 
@@ -607,7 +612,9 @@
 	float mInitialRenderCost;
 	
-	float mMaxAvgRayContri;
-
-	float mMinAvgRayContri;
+	//float mMaxAvgRayContri;
+	//float mMinAvgRayContri;
+
+	float mMaxAvgRaysPerObject;
+	float mMinAvgRaysPerObject;
 
 	// quick hack:
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 2224)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 2227)
@@ -12,5 +12,5 @@
 #include "SubdivisionCandidate.h"
 #include "HierarchyManager.h"
-#include "PerfTimer.h"
+#include "Timer/PerfTimer.h"
 
 
@@ -393,4 +393,11 @@
 
 
+		/** Returns average rays per object.
+		*/
+		float GetAvgRaysPerObject() const
+		{
+			return (float)mRays->size() / ((float)mPvs + Limits::Small);
+		}
+
 		VspTraversalData():
 			mNode(NULL),
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 2224)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 2227)
@@ -634,4 +634,10 @@
 
 
+static float AvgRaysPerObject(const int pvs, const int nRays)
+{
+	return (float)nRays / ((float)pvs + Limits::Small);
+}
+
+
 void BvHierarchy::EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitCandidate, 
 										   const bool computeSplitPlane,
@@ -689,8 +695,9 @@
 	// avg contribution of a ray to a pvs
 	const float pvs = (float)CountViewCells(*tData.mSampledObjects);
-	const float avgRayContri = AvgRayContribution((int)pvs, tData.mNumRays);
+	//const float avgRayContri = AvgRayContribution((int)pvs, tData.mNumRays);
+	const float avgRaysPerObject = AvgRaysPerObject((int)pvs, tData.mNumRays);
 
 	// high avg ray contri, the result is influenced by undersampling
-	splitCandidate.SetAvgRayContribution(avgRayContri);
+	splitCandidate.SetAvgRaysPerObject(avgRaysPerObject);
 	const float viewSpaceVol = GetViewSpaceVolume();
 
@@ -699,4 +706,5 @@
 	const float parentVol = tData.mCorrectedVolume * oldRatio;
 
+	//cout << "h " << avgRaysPerObject << " ";
 	// this leaf is a pvs entry in all the view cells
 	// that see one of the objects.
@@ -708,8 +716,8 @@
 
 	splitCandidate.mCorrectedFrontVolume = 
-		mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeFrontViewCells, parentVol, avgRayContri);
+		mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeFrontViewCells, parentVol, avgRaysPerObject);
 	
 	splitCandidate.mCorrectedBackVolume = 
-		mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeBackViewCells, parentVol, avgRayContri);
+		mHierarchyManager->EvalCorrectedPvs(splitCandidate.mVolumeBackViewCells, parentVol, avgRaysPerObject);
 	
 	const float relfrontCost = splitCandidate.mCorrectedFrontVolume * 
@@ -727,5 +735,5 @@
 	// increase in pvs entries
 	const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate, 
-												  avgRayContri, 
+												  avgRaysPerObject, 
 												  (int)pvs, 
 												  splitCandidate.mNumFrontViewCells, 
@@ -737,5 +745,5 @@
 	{
 		cout << "bvh volume cost"
-		 << " avg ray contri: " << avgRayContri << " ratio: " << oldRatio 
+		 << " avg rays per object: " << avgRaysPerObject << " ratio: " << oldRatio 
 		 << " parent: " << parentVol << " old vol: " << oldVolume 
 		 << " frontvol: " << splitCandidate.mVolumeFrontViewCells << " corr. " << splitCandidate.mCorrectedFrontVolume 
@@ -766,5 +774,5 @@
 
 int BvHierarchy::EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, 
-									const float avgRayContri,
+									const float avgRaysPerObjects,
 									const int numParentViewCells,
 									const int numFrontViewCells,
@@ -780,11 +788,11 @@
 	
 	splitCandidate.mCorrectedFrontPvs = 
-		mHierarchyManager->EvalCorrectedPvs((float)frontViewCells, parentPvs, avgRayContri);
+		mHierarchyManager->EvalCorrectedPvs((float)frontViewCells, parentPvs, avgRaysPerObjects);
 	splitCandidate.mCorrectedBackPvs =
-		mHierarchyManager->EvalCorrectedPvs((float)backViewCells, parentPvs, avgRayContri);
+		mHierarchyManager->EvalCorrectedPvs((float)backViewCells, parentPvs, avgRaysPerObjects);
 
 	if (0)
 	cout << "bvh pvs"
-		 << " avg ray contri: " << avgRayContri << " ratio: " << oldPvsRatio 
+		 << " avg ray contri: " << avgRaysPerObjects << " ratio: " << oldPvsRatio 
 		 << " parent: " << parentPvs << " " << " old vol: " << oldPvsSize
 		 << " frontpvs: " << frontViewCells << " corr. " << splitCandidate.mCorrectedFrontPvs 
@@ -1014,5 +1022,4 @@
 #endif
 
-#if 1
 
 float BvHierarchy::EvalSah(const BvhTraversalData &tData,
@@ -1111,6 +1118,13 @@
 		ar = rbox.SurfaceArea();
 
+#if BOUND_RENDERCOST
 		const float sum = noValidSplit ? 1e25f : objectsLeft * al + objectsRight * ar;
-      
+#else
+		const float rcLeft = std::max(objectsLeft, MIN_RENDERCOST);
+		const float rcRight = std::max(objectsRight, MIN_RENDERCOST);
+
+		const float sum = noValidSplit ? 1e25f : objectsLeft * al + objectsRight * ar;
+
+#endif
 		/*cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=(" 
 			 << lbox.SurfaceArea() << "," << rbox.SurfaceArea() << ")" << endl;
@@ -1153,10 +1167,10 @@
 }
 
-#else
-
-float BvHierarchy::EvalSah(const BvhTraversalData &tData,
-						   const int axis,
-						   ObjectContainer &objectsFront,
-						   ObjectContainer &objectsBack)
+
+
+float BvHierarchy::EvalSahWithTigherBbox(const BvhTraversalData &tData,
+										 const int axis,
+										 ObjectContainer &objectsFront,
+										 ObjectContainer &objectsBack)
 {
 	// go through the lists, count the number of objects left and right
@@ -1294,5 +1308,4 @@
 }
 
-#endif
 
 static bool PrepareOutput(const int axis,
@@ -1423,8 +1436,18 @@
 		const bool noValidSplit = (nObjectsRight <= Limits::Small);
 
+#if BOUND_RENDERCOST
 		// the heuristics
 	    const float sum = noValidSplit ? 
 			1e25f : volLeft * (float)nObjectsLeft + volRight * (float)nObjectsRight;
-
+#else
+		const float rcLeft = max(nObjectsLeft, MIN_RENDERCOST);
+		const float rcRight = max(nObjectsRight, MIN_RENDERCOST);
+
+		// the heuristics
+	    const float sum = noValidSplit ? 
+			1e25f : volLeft * (float)rcLeft + volRight * (float)rcRight;
+
+#endif
+		
 #ifdef GTP_DEBUG
 		if (printStats)
@@ -1842,4 +1865,5 @@
 float BvHierarchy::EvalAbsCost(const ObjectContainer &objects)
 {
+	float result;
 #if USE_BETTER_RENDERCOST_EST
 	ObjectContainer::const_iterator oit, oit_end = objects.end();
@@ -1847,9 +1871,15 @@
 	for (oit = objects.begin(); oit != oit_end; ++ oit)
 	{
-		objRenderCost += ViewCellsManager::GetRendercost(*oit);
+		result += ViewCellsManager::GetRendercost(*oit);
 	}
 #else
-	return (float)objects.size();
+	result = (float)objects.size();
 #endif
+
+#if BOUND_RENDERCOST
+	result = max(result, MIN_RENDERCOST);
+#endif
+
+	return result;
 }
 
@@ -1875,4 +1905,5 @@
 	///////////////
 	//-- render cost heuristics
+
 	const float objRenderCost = EvalAbsCost(objects);
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2224)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2227)
@@ -24,5 +24,5 @@
 #include "SamplingStrategy.h"
 #include "SceneGraph.h"
-#include "PerfTimer.h"
+#include "Timer/PerfTimer.h"
 
 
@@ -2517,5 +2517,5 @@
   s<<"#AVG_REL_PVS_INCREASE\n"<<pvsStat.avgRelPvsIncrease<<endl;
   s<<"#DEV_REL_PVS_INCREASE\n"<<pvsStat.devRelPvsIncrease<<endl;
-  s<<"#MEMROY\n"<<pvsStat.mem<<endl;
+  s<<"#MEMORY\n"<<pvsStat.mem<<endl;
 
   s<<"#CONTRIBUTING_RAYS\n"<<mSamplesStat.mContributingRays<<endl;
@@ -6019,5 +6019,5 @@
 
 	ResetViewCells();
-	Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl;
+	//Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl;
 
 	//////////////
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 2210)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 2227)
@@ -1766,5 +1766,5 @@
 float ViewCellsTree::GetPvsCostForLeafStorage(ViewCell *vc) const
 {
-	// pvs is always stored directly in leaves
+	// pvs is already stored in the leaves
 	if (vc->IsLeaf())
 	{
@@ -1772,4 +1772,6 @@
 	}
 	
+	/////////////////////////////////
+
 	// interior nodes: pvs is either stored as a 
 	// scalar or has to be reconstructed from the leaves
@@ -1958,5 +1960,4 @@
 	////////////////////////////////////////////////
 	//-- for interiors, pvs can be stored using different methods
-	//
 
 	switch (mViewCellsStorage)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 2224)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 2227)
@@ -14,5 +14,5 @@
 #include "IntersectableWrapper.h"
 #include "HierarchyManager.h"
-#include "PerfTimer.h"
+#include "Timer/PerfTimer.h"
 
 
@@ -736,4 +736,8 @@
 				  ObjectContainer &objectsBack);
 
+	float EvalSahWithTigherBbox(const BvhTraversalData &tData,
+								const int axis,
+								ObjectContainer &objectsFront,
+								ObjectContainer &objectsBack);
 
 	/** Evaluates render cost of the bv induced by these objects
@@ -910,5 +914,5 @@
 	*/
 	int EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, 
-						   const float avgRayContri,
+						   const float raysPerObjects,
 						   const int numParentViewCells,
 						   const int numFrontViewCells,
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp	(revision 2105)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp	(revision 2227)
@@ -1,4 +1,5 @@
 #include "Halton.h"
-#include "PerfTimer.h"
+#include "Timer/PerfTimer.h"
+
 
 #define PREGENERATE_HALTON 0
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 2210)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 2227)
@@ -559,5 +559,4 @@
 		|| (data.mPvs <= mTermMinPvs)
 		|| (data.mProbability <= mTermMinProbability)
-		//|| (data.GetAvgRayContribution() > mTermMaxRayContribution)
 		|| (data.mDepth >= mTermMaxDepth)
 		);
@@ -811,5 +810,11 @@
 
 	splitCandidate.SetAvgRayContribution(avgRayContri);
-	
+
+	const float avgRaysPerObject = 
+		(float)splitCandidate.mParentData.mRays->size() / ((float)pvs + Limits::Small);
+
+	splitCandidate.SetAvgRayContribution(avgRayContri);
+	splitCandidate.SetAvgRaysPerObject(avgRaysPerObject);
+
 	// compute global decrease in render cost
 	float oldRenderCost;
@@ -875,9 +880,9 @@
 		mHierarchyManager->EvalCorrectedPvs(fPvsSize, 
 											correctedOldPvs, 
-											splitCandidate.GetAvgRayContribution());
+											splitCandidate.GetAvgRaysPerObject());
 	splitCandidate.mCorrectedBackPvs = 
 		mHierarchyManager->EvalCorrectedPvs(bPvsSize, 
 											correctedOldPvs, 
-											splitCandidate.GetAvgRayContribution());
+											splitCandidate.GetAvgRaysPerObject());
 	
 	splitCandidate.mFrontPvs = fPvsSize;
@@ -1536,5 +1541,6 @@
 	
 	const AxisAlignedPlane &candidatePlane = sc.mSplitPlane;
-	const float avgRayContri = sc.GetAvgRayContribution();
+	//const float avgRayContri = sc.GetAvgRayContribution();
+	const float avgRaysPerObject = sc.GetAvgRaysPerObject();
 
 	//////////////////////////////////////////////
@@ -1563,4 +1569,5 @@
 		// and back pvs with respect to the classification
 		UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs);
+
 #if COUNT_ORIGIN_OBJECTS
 		UpdateContributionsToPvs(*ray, false, cf, pvsFront, pvsBack, totalPvs);
@@ -1585,11 +1592,10 @@
 	//-- evaluate render cost heuristics
 
-	const float oldRenderCostRatio = (tData.mRenderCost > 0)? 
-		(totalPvs / tData.mRenderCost) : 1;
+	const float oldRenderCostRatio = (tData.mRenderCost > 0)? (totalPvs / tData.mRenderCost) : 1;
 
 	const float penaltyOld = tData.mCorrectedRenderCost * oldRenderCostRatio;
 
-	sc.mCorrectedFrontRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsFront, penaltyOld, avgRayContri);
-	sc.mCorrectedBackRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsBack, penaltyOld, avgRayContri);
+	sc.mCorrectedFrontRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsFront, penaltyOld, avgRaysPerObject);
+	sc.mCorrectedBackRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsBack, penaltyOld, avgRaysPerObject);
 
 	sc.mFrontRenderCost = pvsFront;
@@ -1608,5 +1614,5 @@
 	if (0)
 	cout << "vsp render cost"
-		 << " avg ray contri: " << avgRayContri << " ratio: " << oldRenderCostRatio
+		 << " avg rays per object: " << avgRaysPerObject << " ratio: " << oldRenderCostRatio
 		 << " parent: " << penaltyOld << " " << " old vol: " << totalPvs 
 		 << " front cost: " << sc.mCorrectedFrontRenderCost << " corr. " << sc.mCorrectedFrontRenderCost
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h	(revision 2176)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h	(revision 2227)
@@ -10,5 +10,5 @@
 #include <hash_map>
 
-#include "PerfTimer.h"
+#include "Timer/PerfTimer.h"
 
 namespace GtpVisibilityPreprocessor {
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 2224)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 2227)
@@ -155,8 +155,8 @@
 
 	Environment::GetSingleton()->GetFloatValue(
-		"Hierarchy.Construction.maxAvgRayContri", mMaxAvgRayContri);
+		"Hierarchy.Construction.maxAvgRaysPerObject", mMaxAvgRaysPerObject);
 
 	Environment::GetSingleton()->GetFloatValue(
-		"Hierarchy.Construction.minAvgRayContri", mMinAvgRayContri);
+		"Hierarchy.Construction.minAvgRaysPerObject", mMinAvgRaysPerObject);
 
 	Environment::GetSingleton()->GetBoolValue(
@@ -177,5 +177,6 @@
 	Debug << "max steps of same kind: " << mMaxStepsOfSameType << endl;
 	Debug << "max repairs: " << mMaxRepairs << endl;
-	Debug << "max avg ray contribution: " << mMaxAvgRayContri << endl;
+	Debug << "max avg rays per object: " << mMaxAvgRaysPerObject << endl;
+	Debug << "mín avg rays per object: " << mMinAvgRaysPerObject << endl;
 
 	// for comparing it with byte - value
@@ -830,22 +831,25 @@
 float HierarchyManager::EvalCorrectedPvs(const float childPvs, 
 										 const float totalPvs, 
-										 const float avgRayContri) const
+										 const float avgRaysPerObjects) const
 {
 	// assume pvs sampled sufficiently => take child pvs
-	if (avgRayContri < mMinAvgRayContri)
+	if (avgRaysPerObjects > mMaxAvgRaysPerObject)
 	{
 		return childPvs;
 	}
-
 	// assume pvs not sampled sufficiently => take total pvs
-	if (avgRayContri >= mMaxAvgRayContri)
-	{
+	else if (avgRaysPerObjects <= mMinAvgRaysPerObject)
+	{
+		cout << "b ";// << avgRaysPerObjects << " ";
 		return totalPvs;
 	}
 
-	const float alpha = (mMaxAvgRayContri - avgRayContri) / 
-						(mMaxAvgRayContri - mMinAvgRayContri);
-
-	const float beta = (1.0f - alpha) * (totalPvs - childPvs);
+	const float alpha = (mMaxAvgRaysPerObject - avgRaysPerObjects) / 
+						(mMaxAvgRaysPerObject - mMinAvgRaysPerObject);
+
+	/// rays per object == max threshold => alpha == 0 => newPvs is childPvs
+	/// rays per object == min threshold => alpha == 1 => newPvs is totalPvs
+	
+	const float beta = alpha * (totalPvs - childPvs);
 #if 1
 	const float newPvs = childPvs + beta;
@@ -853,9 +857,10 @@
 	const float newPvs = alpha * childPvs + (1.0f - alpha) * totalPvs;
 #endif
-cout<<"a";
+cout << "c ";// << avgRaysPerObjects << " ";
 	//cout << "alpha " << alpha << " beta: " << beta << " child: " << childPvs << " parent: " << totalPvs << endl;
 	
 	if ((newPvs < childPvs - Limits::Small) || (newPvs > totalPvs + Limits::Small))
-		cout << "Error!! " << newPvs << endl;
+		cout << "Error! " << newPvs << " smaller than child pvs or larger than parent pvs" << endl;
+
 	return newPvs;
 }
@@ -892,6 +897,4 @@
 	}
 	
-	cout << sc->Type() << " ";
-		
 	/////////////
 	// update stats
@@ -907,7 +910,9 @@
 	float mem = (float)ObjectPvs::GetEntrySizeByte() * pvsEntriesIncr;
 
+#if USE_AVGRAYCONTRI
 	// high avg ray contri, the result is influenced by undersampling
 	// => decrease priority
-	if (0 && USE_AVGRAYCONTRI && (sc->GetAvgRayContribution() > mMaxAvgRayContri))
+
+	if (sc->GetAvgRayContribution() > mMaxAvgRayContri)
 	{
 		const float factor = 1.0f + sc->GetAvgRayContribution() - mMaxAvgRayContri;
@@ -916,5 +921,6 @@
 		mem *= factor;
 	}
-	
+#endif
+
 	mHierarchyStats.mMemory += mem;
 	mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease();
@@ -1148,10 +1154,13 @@
 
 		SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue); 
+
+		const bool success = ApplySubdivisionCandidate(sc, splitQueue, dirtyCandidates);
+
+		if (success)
+		{
+			//sc->CollectDirtyCandidates(dirtyCandidates, true);
+			//if (steps % 10 == 0)
+				cout << sc->Type() << " ";
 			
-		const bool success = ApplySubdivisionCandidate(sc, splitQueue, dirtyCandidates);
-
-		if (success)
-		{
-			//sc->CollectDirtyCandidates(dirtyCandidates, true);
 			++ steps;
 		}
@@ -1490,5 +1499,6 @@
 	SubdivisionCandidateContainer::const_iterator sit, sit_end = dirtyList.end();
 	
-	for (sit = dirtyList.begin(); sit != sit_end; ++ sit)
+	int i = 0;
+	for (sit = dirtyList.begin(); sit != sit_end; ++ sit, ++ i)
 	{
 		// only repair a certain number of candidates
@@ -1507,5 +1517,6 @@
 		
 		++ repaired;
-		cout << ".";
+		//if (i % 10 == 0)
+			cout << ".";
 
 #ifdef GTP_DEBUG
@@ -2360,5 +2371,5 @@
 			{
 				++ subStats.mViewSpaceSplits;
-				cout << "v";
+				//cout << "v";
 				//cout << "vsp t: " << timeStamp << " rc: " << rcDecr << " pvs: " << entriesIncr << endl;
 			}
@@ -2366,5 +2377,5 @@
 			{
 				++ subStats.mObjectSpaceSplits;
-				cout << "o";
+				//cout << "o";
 				//"osp t: " << timeStamp << " rc: " << rcDecr << " pvs: " << entriesIncr << endl;
 			}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2210)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2227)
@@ -7,5 +7,5 @@
 #include "RssTree.h"
 #include "Mutation.h"
-#include "PerfTimer.h"
+#include "Timer/PerfTimer.h"
 
 
