Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/README.txt
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/README.txt	(revision 1246)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/README.txt	(revision 1610)
@@ -51,3 +51,8 @@
 
 
-8) start TerrainExampleApplication for testing
+8) TestCullingTerrain is the test application
+
+take the path to the Ogre Release as working directory, e.g.,
+D:\svn\gametools\OGRE\trunk\ogrenew\Samples\Common\bin\Release
+
+start TestCullingTerrain
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 1606)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 1610)
@@ -72,5 +72,6 @@
 void OcclusionCullingSceneManager::InitDepthPass()
 {
-	MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass");
+	MaterialPtr depthMat = 
+		MaterialManager::getSingleton().getByName("Visibility/DepthPass");
 
 	if (depthMat.isNull())
@@ -106,5 +107,6 @@
     {
 		// Init
-		itemBufferMat = MaterialManager::getSingleton().create("Visibility/ItemBufferPass",
+		itemBufferMat = 
+			MaterialManager::getSingleton().create("Visibility/ItemBufferPass",
                 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
 
@@ -132,6 +134,8 @@
             ResourceGroupManager::getSingleton().getWorldResourceGroupName());
     }
+	
 	destroyLevelIndexes();
     mTerrainPages.clear();
+
     // Load the configuration
     loadConfig(stream);
@@ -361,9 +365,9 @@
 void OcclusionCullingSceneManager::_renderVisibleObjects()
 {
-	
 	if (mNormalExecution)
 	{
 		// the standard octree rendering mode
 		TerrainSceneManager::_renderVisibleObjects();
+		getRenderQueue()->clear(mDeleteQueueAfterRendering);
 		return;
 	}
@@ -1123,4 +1127,5 @@
 		// if no there is no view cell, set everything visible
 		SetObjectsVisible(true);
+
 		return;
 	}
@@ -1134,4 +1139,5 @@
 	for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)
 	{
+		// no associated geometry found
 		if (!(*oit).first) continue;
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1580)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1610)
@@ -544,13 +544,16 @@
 inline bool BvHierarchy::GlobalTerminationCriteriaMet(const BvhTraversalData &data) const
 {
+	// note: tracking for global cost termination 
+	// does not make much sense for interleaved vsp / osp partition
+	// as it is the responsibility of the hierarchy manager
+
 	const bool terminationCriteriaMet =
 		(0
 		|| (mBvhStats.Leaves() >= mTermMaxLeaves)
-		// does not make much sense for interleaved vsp / osp partition
 		//|| (mBvhStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance)
 		//|| mOutOfMemory 
 		);
 
-	if (0 && terminationCriteriaMet)
+	if (1 && terminationCriteriaMet)
 	{
 		Debug << "bvh global termination criteria met:" << endl;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1588)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1610)
@@ -582,5 +582,6 @@
 		);
 
-	if (0 && localTerminationCriteriaMet)
+#if _DEBUG
+	if (localTerminationCriteriaMet)
 	{
 		Debug << "local termination criteria met:" << endl;
@@ -591,5 +592,5 @@
 		Debug << "depth " << data.mDepth << " " << mTermMaxDepth << endl;
 	}
-
+#endif
 	return localTerminationCriteriaMet;		
 }
@@ -598,12 +599,15 @@
 inline bool VspTree::GlobalTerminationCriteriaMet(const VspTraversalData &data) const
 {
+	// note: to track for global cost misses does not really 
+	// make sense because cost termination  happens in the hierarchy mananger
+
 	const bool terminationCriteriaMet = (0
 		// || mOutOfMemory
 		|| (mVspStats.Leaves() >= mMaxViewCells)
-		// does not really make sense because cost termination already in hierarchy
 		// || (mVspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
 		);
 
-	if (0 && terminationCriteriaMet)
+#if _DEBUG
+	if (terminationCriteriaMet)
 	{
 		Debug << "vsp global termination criteria met:" << endl;
@@ -611,4 +615,5 @@
 		Debug << "leaves: " << mVspStats.Leaves() << " " <<  mMaxViewCells << endl;
 	}
+#endif
 
 	return terminationCriteriaMet;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1580)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1610)
@@ -231,5 +231,6 @@
 		);
 
-	if (0 && terminationCriteriaMet)
+#if _DEBUG
+	if (terminationCriteriaMet)
 	{
 		Debug << "hierarchy global termination criteria met:" << endl;
@@ -237,4 +238,6 @@
 		Debug << "cost misses: " << mHierarchyStats.mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl;
 	}
+#endif
+
 	return terminationCriteriaMet;
 }
@@ -327,5 +330,5 @@
 
 	mTotalCost = mVspTree->mTotalCost;
-	Debug << "\nreseting cost, new total cost: " << mTotalCost << endl;
+	cout << "\nreseting cost for vsp, new total cost: " << mTotalCost << endl;
 
 	mTQueue.Push(vsc);
@@ -392,22 +395,10 @@
 bool HierarchyManager::ApplySubdivisionCandidate(SubdivisionCandidate *sc, const bool repairQueue)
 {
+	// test if global termination criteria were met before this split
 	const bool globalTerminationCriteriaMet = GlobalTerminationCriteriaMet(sc);
 	const bool vspSplit = (sc->Type() == SubdivisionCandidate::VIEW_SPACE);
 
-	if (!globalTerminationCriteriaMet)
-	{
-		// cost ratio of cost decrease / totalCost
-		const float costRatio = mCurrentCandidate->GetRenderCostDecrease() / mTotalCost;
-		//Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl;
-	
-		if (costRatio < mTermMinGlobalCostRatio)
-		{
-			++ mHierarchyStats.mGlobalCostMisses;
-		}
-
-		mTotalCost -= mCurrentCandidate->GetRenderCostDecrease();
-	}
-
-	bool success;
+	bool success = false;
+
 	switch (sc->Type())
 	{
@@ -438,4 +429,24 @@
 	}
 
+	if (!success) // split was not taken
+	{
+		return false;
+	}
+
+	///////////////
+	//-- split was successful => 
+	//-- update stats and render queue
+
+    // cost ratio of cost decrease / totalCost
+	const float costRatio = mCurrentCandidate->GetRenderCostDecrease() / mTotalCost;
+	//Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl;
+	
+	if (costRatio < mTermMinGlobalCostRatio)
+	{
+		++ mHierarchyStats.mGlobalCostMisses;
+	}
+	
+	mTotalCost -= mCurrentCandidate->GetRenderCostDecrease();
+	
 	cout << sc->Type() << " ";
 		
