Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1727)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1732)
@@ -283,5 +283,5 @@
 
 	inline bool ConsiderMemory() const { return mConsiderMemory; }
-	inline float GetMemoryConst() const { return mMemoryConst; }
+	//inline float GetMemoryConst() const { return mMemoryConst; }
 
 	
@@ -620,7 +620,4 @@
 	bool mConsiderMemory;
 
-	/// constant value for driving the heuristics
-	float mMemoryConst;
-	
 	bool mConsiderMemory2;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 1705)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 1732)
@@ -192,4 +192,6 @@
 	float GetMergeCost() {return (float)-mTimeStamp; }
 
+	int mTimeStamp;
+
 	/////////
 	//-- mailing options
@@ -203,9 +205,7 @@
 	int mMailbox;
 
-	int mTimeStamp;
-
-	int mPvsEntriesIncr;
-	float mMemoryIncr;
-	float mRenderCostDecr;
+	//int mPvsEntriesIncr;
+	//float mMemoryIncr;
+	//float mRenderCostDecr;
 
 protected:
@@ -333,7 +333,4 @@
 	VssRayContainer mVssRays;
 	
-	/// leaf pvs
-	//ObjectPvs *mPvs;
-
 	/// Probability that the view point lies in this leaf
 	float mProbability;
@@ -1120,4 +1117,7 @@
 
 	int mMaxTests;
+
+	/// constant value for driving the heuristics
+	float mMemoryConst;
 };
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1727)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1732)
@@ -47,7 +47,7 @@
 mParent(NULL), 
 mMailbox(0),
-mRenderCostDecr(0), 
-mMemoryIncr(0),
-mPvsEntriesIncr(0),
+//mRenderCostDecr(0), 
+//mMemoryIncr(0),
+//mPvsEntriesIncr(0),
 mTimeStamp(0)
 {
@@ -59,7 +59,7 @@
 mBoundingBox(bbox), 
 mMailbox(0),
-mMemoryIncr(0),
-mRenderCostDecr(0), 
-mPvsEntriesIncr(0),
+//mMemoryIncr(0),
+//mRenderCostDecr(0), 
+//mPvsEntriesIncr(0),
 mTimeStamp(0)
 {
@@ -71,7 +71,7 @@
 mParent(parent), 
 mMailbox(0),
-mMemoryIncr(0),
-mRenderCostDecr(0), 
-mPvsEntriesIncr(0),
+//mMemoryIncr(0),
+//mRenderCostDecr(0), 
+//mPvsEntriesIncr(0),
 mTimeStamp(0)
 {
@@ -292,6 +292,15 @@
 	Environment::GetSingleton()->GetIntValue("BvHierarchy.maxTests", mMaxTests);
 
-	//mUseBboxAreaForSah = false;
-	mUseBboxAreaForSah = true;
+	//mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(VspViewCell));
+	//mMemoryConst = (float)sizeof(BvhLeaf);
+mMemoryConst = (float)sizeof(ObjectContainer);
+	cout << "bvh memcost: " << mMemoryConst << endl;
+	cout << "triangle: " << sizeof(TriangleIntersectable) << endl;
+	cout << "triangle: " << sizeof(Intersectable) << endl;
+	cout << "triangle: " << sizeof(ObjectContainer) << endl;
+	cout << "triangle: " << sizeof(float) << endl;
+	cout << "triangle: " << sizeof(int) << endl;
+
+    mUseBboxAreaForSah = true;
 
 	/////////////
@@ -317,4 +326,5 @@
 	Debug << "use global sort: " << mUseGlobalSorting << endl;
 	Debug << "minimal rays for visibility: " << mMinRaysForVisibility << endl;
+	Debug << "bvh mem const: " << mMemoryConst << endl;
 
 	Debug << endl;
@@ -503,5 +513,5 @@
 		{
 			BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(currentNode);
-			CollectRays(leaf->mObjects, leaf->mVssRays);
+		//	CollectRays(leaf->mObjects, leaf->mVssRays);
 		}
 		
@@ -584,9 +594,26 @@
 		// otherwise danger of being stuck in a local minimum!
 		const float factor = mRenderCostDecreaseWeight;
-		priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost;
-
-		if (mHierarchyManager->mConsiderMemory2)
-		{
-			priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst);
+
+		if (1)
+		{
+			priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost;
+			if (mHierarchyManager->mConsiderMemory2)
+			{
+				priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst);
+			}
+		}
+		else
+		{
+			if (!mHierarchyManager->mConsiderMemory2)
+			{
+				priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost;
+			}
+			else
+			{
+				const float ratio = 
+					renderCostDecr / ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst);
+
+				priority = factor * ratio + (1.0f - factor) * oldRenderCost;
+			}
 		}
 	}
@@ -2351,6 +2378,6 @@
 		//oldNode->mPvsEntriesIncr += sc->GetPvsEntriesIncr();
 		
-		oldNode->mRenderCostDecr = sc->GetRenderCostDecrease();
-		oldNode->mPvsEntriesIncr = sc->GetPvsEntriesIncr();
+		//oldNode->mRenderCostDecr = sc->GetRenderCostDecrease();
+		//oldNode->mPvsEntriesIncr = sc->GetPvsEntriesIncr();
 		
 		///////////////////////////
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1723)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1732)
@@ -5804,4 +5804,5 @@
 
 			startTime = GetTime();
+			
 			cout << "compute new statistics ... " << endl;
 
@@ -5811,8 +5812,10 @@
 			timeDiff = TimeDiff(startTime, GetTime());
 			cout << "finished in " << timeDiff * 1e-3 << " secs" << endl;
+			cout << "*************************************" << endl;
+
 			Debug << "statistics computed in " << timeDiff * 1e-3 << " secs" << endl;
 
 			// only for debugging purpose
-			if (1)
+			if (0)
 			{
 				ViewCellContainer viewCells;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1727)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1732)
@@ -204,7 +204,7 @@
 	int mTimeStamp;
 
-	int mPvsEntriesIncr;
-	float mMemoryIncr;
-	float mRenderCostDecr;
+	//int mPvsEntriesIncr;
+	//float mMemoryIncr;
+	//float mRenderCostDecr;
 
 	/////////////////////////////////////
@@ -327,5 +327,5 @@
 
 	/// Rays piercing this leaf.
-	VssRayContainer mVssRays;
+	//VssRayContainer mVssRays;
 	/// objects
 	ObjectContainer mObjects;
@@ -954,4 +954,7 @@
 	int mMinRaysForVisibility;
 
+	/// constant value for driving the heuristics
+	float mMemoryConst;
+
 	int mMaxTests;
 };
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h	(revision 1709)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h	(revision 1732)
@@ -388,4 +388,5 @@
 };
 
+
 /** Leaf of the view cell hierarchy corresponding 
 	to a leaf in a spatial hierarchy.
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1727)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1732)
@@ -181,8 +181,8 @@
 mParent(NULL), 
 mTreeValid(true), 
-mTimeStamp(0), 
-mRenderCostDecr(0), 
-mMemoryIncr(0),
-mPvsEntriesIncr(0)
+mTimeStamp(0)
+//,mRenderCostDecr(0)
+//,mMemoryIncr(0)
+//,mPvsEntriesIncr(0)
 {}
 
@@ -191,7 +191,7 @@
 mParent(parent), 
 mTreeValid(true), 
-mMemoryIncr(0),
-mRenderCostDecr(0),
-mPvsEntriesIncr(0),
+//,mMemoryIncr(0)
+//,mRenderCostDecr(0)
+//,mPvsEntriesIncr(0)
 mTimeStamp(0)
 {}
@@ -470,4 +470,10 @@
 	Environment::GetSingleton()->GetBoolValue("VspTree.simulateOctree", mCirculatingAxis);
 
+	//mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(VspViewCell));
+	//mMemoryConst = 50;//(float)(sizeof(VspViewCell));
+
+	//mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(ObjectPvs));
+	mMemoryConst = (float)sizeof(ObjectPvs);
+	cout << "vsp memcost: " << mMemoryConst << endl;
 
 	//////////////
@@ -498,4 +504,6 @@
 	Debug << "maxband: " << mMaxBand << endl;
 
+	Debug << "vsp mem const: " << mMemoryConst << endl;
+
 	Debug << endl;
 }
@@ -838,11 +846,30 @@
 	// otherwise danger of being stuck in a local minimum!
 	const float factor = mRenderCostDecreaseWeight;
-	float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost;
-
-	if (mHierarchyManager->mConsiderMemory2)
-	{
-		priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst);
-	}
-	
+
+	float priority;
+
+	if (1)
+	{
+		priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost;
+		if (mHierarchyManager->mConsiderMemory2)
+		{
+			priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst);
+		}
+	}
+	else
+	{
+		if (!mHierarchyManager->mConsiderMemory2)
+		{
+			priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost;
+		}
+		else
+		{
+			const float ratio = 
+				renderCostDecr / ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst);
+
+			priority = factor * ratio + (1.0f - factor) * oldRenderCost;
+		}
+	}
+
 	splitCandidate.SetPriority(priority);
 }
@@ -3323,6 +3350,6 @@
 		//oldNode->mPvsEntriesIncr += sc->GetPvsEntriesIncr();
 
-		oldNode->mRenderCostDecr = sc->GetRenderCostDecrease();
-		oldNode->mPvsEntriesIncr = sc->GetPvsEntriesIncr();
+		//oldNode->mRenderCostDecr = sc->GetRenderCostDecrease();
+		//oldNode->mPvsEntriesIncr = sc->GetPvsEntriesIncr();
 
 		/////////////
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1731)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1732)
@@ -151,15 +151,4 @@
 	Environment::GetSingleton()->GetIntValue(
 		"Hierarchy.Construction.maxRepairs", mMaxRepairs);
-
-	if (1 && mConsiderMemory2)
-	{
-		mMemoryConst = (float)(sizeof(VspLeaf *) + sizeof (VspViewCell *));
-	}
-	else
-	{
-		Environment::GetSingleton()->GetFloatValue(
-			"Hierarchy.Termination.memoryConst", mMemoryConst);
-	}
-
 	// compare to bytes
 	mTermMaxMemory *= (1024.0f * 1024.0f);
@@ -177,5 +166,4 @@
 	Debug << "consider memory: " << mConsiderMemory << endl;
 	Debug << "consider memory2: " << mConsiderMemory << endl;
-	Debug << "mem const: " << mMemoryConst << endl;
 	Debug << "min steps of same kind: " << mMinStepsOfSameType << endl;
 	Debug << "max steps of same kind: " << mMaxStepsOfSameType << endl;
@@ -1933,6 +1921,6 @@
 			
 			isLeaf = newNode->IsLeaf();
-			subStats.mRenderCostDecrease = oldNode->mRenderCostDecr;
-			entriesIncr = oldNode->mPvsEntriesIncr;
+			//subStats.mRenderCostDecrease = oldNode->mRenderCostDecr;
+			//entriesIncr = oldNode->mPvsEntriesIncr;
 		}
 		else
@@ -1944,6 +1932,6 @@
 			
 			isLeaf = newNode->IsLeaf();
-			subStats.mRenderCostDecrease = oldNode->mRenderCostDecr;
-			entriesIncr = oldNode->mPvsEntriesIncr;
+			//subStats.mRenderCostDecrease = oldNode->mRenderCostDecr;
+			//entriesIncr = oldNode->mPvsEntriesIncr;
 		}		
 				
@@ -2078,14 +2066,15 @@
 		
 		const float objectSpaceHierarchyMem = float(
-											  subStats.mObjectSpaceSplits * sizeof(BvhLeaf *) + 
-											  (subStats.mObjectSpaceSplits - 1) * sizeof(BvhInterior *) + 
-											  sizeof(BvHierarchy)
+											  subStats.mObjectSpaceSplits * sizeof(ObjectContainer)
+											  //+ (subStats.mObjectSpaceSplits - 1) * sizeof(BvhInterior)
+											  //+sizeof(BvHierarchy)
 											  ) / float(1024 * 1024);
 
 			
 		const float viewSpaceHierarchyMem = float(
-											subStats.mViewSpaceSplits * sizeof(VspLeaf *) + 
-											(subStats.mViewSpaceSplits - 1) * sizeof(VspInterior *) + 
-											sizeof(VspTree)
+											subStats.mViewSpaceSplits * sizeof(ObjectPvs)
+											//+ (subStats.mViewSpaceSplits - 1) * sizeof(VspInterior)
+											+ sizeof(ObjectPvs)
+											//+ sizeof(VspTree)
 											)  / float(1024 * 1024);
 
@@ -2093,10 +2082,12 @@
 		
 		subStats.Print(splitsStats);
-
 		splits += splitsStepSize;
 
 		if (subStats.mNumSplits == mHierarchyStats.Leaves())
 			break;
-	}
+
+		cout << subStats.mNumSplits << " ";
+	}
+	cout << endl;
 }
 
