Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp	(revision 259)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp	(revision 720)
@@ -7,5 +7,5 @@
 void FrustumCullingManager::RenderScene()
 {
-	//Ogre::LogManager::getSingleton().logMessage("Frustum Culling");
+	if (0) Ogre::LogManager::getSingleton().logMessage("Frustum Culling");
 	while (!mHierarchyInterface->GetQueue()->empty())
 	{
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp	(revision 371)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp	(revision 720)
@@ -17,7 +17,14 @@
 mAssumedVisibilityForChc(0)
 {
+
+#if 1
 	SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING);
-	//SetCullingManager(VisibilityEnvironment::STOP_AND_WAIT_CULLING);
-	//SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING);
+#endif
+#if 0	
+	SetCullingManager(VisibilityEnvironment::STOP_AND_WAIT_CULLING);
+#endif
+#if 0
+	SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING);
+#endif
 }
 //-----------------------------------------------------------------------
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp	(revision 675)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp	(revision 720)
@@ -1,3 +1,3 @@
-#include "OgreOcclusionCullingSceneManager.h"
+#include "OgreVisibilityTerrainSceneManager.h"
 #include "OgreVisibilityOptionsManager.h"
 #include <OgreMath.h>
@@ -10,9 +10,11 @@
 #include <OgreSubEntity.h>
 
+// HACK
+const static DEBUG_CHC = false;
 
 namespace Ogre {
 
 //-----------------------------------------------------------------------
-OcclusionCullingSceneManager::OcclusionCullingSceneManager(
+VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(
 							GtpVisibility::VisibilityManager *visManager): 
 mVisibilityManager(visManager), 
@@ -32,12 +34,15 @@
 mSkipTransparents(false),
 mRenderTransparentsForItemBuffer(true),
-mExecuteVertexProgramForAllPasses(true),
+mExecuteVertexProgramForAllPasses(false),
 mIsHierarchicalCulling(false)
 {
 	mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem);
 	
-	//mDisplayNodes = true;
-	//mShowBoundingBoxes = true;
-	//mShowBoxes = true;
+	if (0)
+	{
+		mDisplayNodes = true;
+		mShowBoundingBoxes = true;
+		mShowBoxes = true;
+	}
 
 	// TODO: set maxdepth to reasonable value
@@ -45,5 +50,5 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::InitDepthPass()
+void VisibilityTerrainSceneManager::InitDepthPass()
 {
 	MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass");
@@ -56,7 +61,9 @@
 
         mDepthPass = depthMat->getTechnique(0)->getPass(0);
+
 		mDepthPass->setColourWriteEnabled(false);
 		mDepthPass->setDepthWriteEnabled(true);
 		mDepthPass->setLightingEnabled(false);
+		//mDepthPass->setDepthCheckEnabled(true);
 	}
 	else
@@ -66,10 +73,10 @@
 }
 //-----------------------------------------------------------------------
-OcclusionCullingSceneManager::~OcclusionCullingSceneManager()
+VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager()
 {
 	OGRE_DELETE(mHierarchyInterface);
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::InitItemBufferPass()
+void VisibilityTerrainSceneManager::InitItemBufferPass()
 {
 	MaterialPtr itemBufferMat = MaterialManager::getSingleton().
@@ -95,5 +102,5 @@
 }
 //-------------------------------------------------------------------------
-void OcclusionCullingSceneManager::setWorldGeometry( const String& filename )
+void VisibilityTerrainSceneManager::setWorldGeometry( const String& filename )
 {
     // Clear out any existing world resources (if not default)
@@ -104,6 +111,8 @@
             ResourceGroupManager::getSingleton().getWorldResourceGroupName());
     }
+
     mTerrainPages.clear();
-    // Load the configuration
+	
+	// Load the configuration
     loadConfig(filename);
 
@@ -115,14 +124,12 @@
 	float maxAxis = std::max(max_x, max_y);
 	maxAxis = std::max(maxAxis, max_z);
-	resize( AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis ) );
+	resize(AxisAlignedBox(0, 0, 0, maxAxis, maxAxis, maxAxis));
     
     setupTerrainMaterial();
-
     setupTerrainPages();
-
- }
-
-//-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam)
+}
+
+//-----------------------------------------------------------------------
+void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam)
 {
 	// add player camera for visualization purpose
@@ -173,5 +180,5 @@
 }
 //-----------------------------------------------------------------------
-Pass *OcclusionCullingSceneManager::setPass(Pass* pass)
+Pass *VisibilityTerrainSceneManager::setPass(Pass* pass)
 {
 	// TODO: setting vertex program is not efficient
@@ -179,12 +186,16 @@
 	
 	// set depth fill pass if we currently do not make an aabb occlusion query
-	Pass *usedPass = (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery() ? 
-					  mDepthPass : pass);
-		
-	IlluminationRenderStage savedStage = mIlluminationStage; 
+	const bool useDepthPass = 1 &&
+		(mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery());
+
+	Pass *usedPass = useDepthPass ? mDepthPass : pass;
+	
+
+	const IlluminationRenderStage savedStage = mIlluminationStage; 
 	
 	// set illumination stage to NONE so no shadow material is used 
 	// for depth pass or for occlusion query
-	if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery())
+	if (1 && 
+		(mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery()))
 	{
 		mIlluminationStage = IRS_NONE;
@@ -192,5 +203,7 @@
 	
 	// --- set vertex program of current pass in order to set correct depth
-	if (mExecuteVertexProgramForAllPasses && mIsDepthPassPhase && pass->hasVertexProgram())
+	if (mExecuteVertexProgramForAllPasses 
+		&& mIsDepthPassPhase 
+		&& pass->hasVertexProgram())
 	{
 		// add vertex program of current pass to depth pass
@@ -207,11 +220,11 @@
 		}
 	}
-	else if (mDepthPass->hasVertexProgram())
+	else if (mDepthPass->hasVertexProgram()) // reset vertex program
 	{
 		mDepthPass->setVertexProgram("");
 	}
 	
-
-	bool IsDepthWrite = usedPass->getDepthWriteEnabled();
+	// save old depth write: needed for item buffer
+	const bool IsDepthWrite = usedPass->getDepthWriteEnabled();
 
 	// global option which enables / disables depth writes
@@ -220,7 +233,9 @@
 		usedPass->setDepthWriteEnabled(false);
 	}
-	//else if (mIsItemBufferPass) {usedPass = mItemBufferPass;}
-	
+	
+
+	//-- set actual pass here
 	Pass *result = SceneManager::setPass(usedPass);
+
 
 	// reset depth write
@@ -236,5 +251,5 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam,
+void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam,
 														bool onlyShadowCasters)
 {
@@ -256,6 +271,8 @@
 			TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
 		}
+
 		// only shadow casters will be rendered in shadow texture pass
-		// mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
+		if (0)
+			mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
 	}
 	
@@ -266,7 +283,6 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::_renderVisibleObjects()
-{
-
+void VisibilityTerrainSceneManager::_renderVisibleObjects()
+{
 	InitDepthPass(); 	  // create material for depth pass
 	InitItemBufferPass(); // create material for item buffer pass
@@ -312,4 +328,5 @@
 
 		TerrainSceneManager::_renderVisibleObjects();
+		/////////////////////////////////////////////////
 
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
@@ -331,8 +348,8 @@
 
 		/** 
-		* the hierarchical culling algorithm
-		* for depth pass: we just find objects and update depth buffer
-		* for "delayed" rendering: we render some passes afterwards
-		* e.g., transparents, because they need front-to-back sorting
+		 * the hierarchical culling algorithm
+		 * for depth pass: we just find objects and update depth buffer
+		 * for "delayed" rendering: we render some passes afterwards
+		 * e.g., transparents, because they need front-to-back sorting
 		**/
 		
@@ -352,4 +369,5 @@
 
 		// add visible nodes found by the visibility culling algorithm
+#if 1
 		if (mUseDepthPass)
 		{
@@ -359,10 +377,11 @@
 			}
 		}
-		
+#endif	
 		//-- now we can render all remaining queue objects
-		// used for depth pass, transparents, overlay 
+		//-- used for depth pass, transparents, overlay
 		clearSpecialCaseRenderQueues();
-
-		TerrainSceneManager::_renderVisibleObjects();
+	
+		if (!DEBUG_CHC)
+			TerrainSceneManager::_renderVisibleObjects();
 	}
 		
@@ -375,11 +394,11 @@
 
 	getRenderQueue()->clear(); // finally clear render queue
-	OGRE_DELETE(mRenderQueue); // HACK: should be cleared before...
+	OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared...
+
 	//WriteLog(); // write out stats
-
-}
-
-//-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::_updateSceneGraph(Camera* cam)
+}
+
+//-----------------------------------------------------------------------
+void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam)
 {
 	mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
@@ -389,5 +408,5 @@
 }
 //-----------------------------------------------------------------------
-bool OcclusionCullingSceneManager::setOption(const String & key, const void * val)
+bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val)
 {
 	if (key == "UseDepthPass")
@@ -482,5 +501,5 @@
 }
 //-----------------------------------------------------------------------
-bool OcclusionCullingSceneManager::getOption(const String & key, void *val)
+bool VisibilityTerrainSceneManager::getOption(const String & key, void *val)
 {
 	if (key == "NumHierarchyNodes")
@@ -494,5 +513,5 @@
 }
 //-----------------------------------------------------------------------
-bool OcclusionCullingSceneManager::getOptionValues(const String & key, 
+bool VisibilityTerrainSceneManager::getOptionValues(const String & key, 
 													StringVector &refValueList)
 {
@@ -500,5 +519,5 @@
 }
 //-----------------------------------------------------------------------
-bool OcclusionCullingSceneManager::getOptionKeys(StringVector & refKeys)
+bool VisibilityTerrainSceneManager::getOptionKeys(StringVector & refKeys)
 {
 	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
@@ -506,5 +525,5 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::setVisibilityManager(GtpVisibility::
+void VisibilityTerrainSceneManager::setVisibilityManager(GtpVisibility::
 														 VisibilityManager *visManager)
 {
@@ -512,10 +531,10 @@
 }
 //-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::getVisibilityManager( void )
+GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager( void )
 {
 	return mVisibilityManager;
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::WriteLog()
+void VisibilityTerrainSceneManager::WriteLog()
 {
 	std::stringstream d;
@@ -535,10 +554,11 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::renderObjects(
-	const RenderPriorityGroup::TransparentRenderablePassList& objs, 
-    bool doLightIteration, const LightList* manualLightList)
+void VisibilityTerrainSceneManager::renderObjects(
+						const RenderPriorityGroup::TransparentRenderablePassList& objs, 
+                        bool doLightIteration, 
+						const LightList* manualLightList)
 {
 	// for correct rendering, transparents must be rendered after hierarchical culling
-	if (!mSkipTransparents)
+	if (1 && !mSkipTransparents)
 	{
 		OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList);
@@ -546,16 +566,21 @@
 }
 //-----------------------------------------------------------------------
-bool OcclusionCullingSceneManager::validatePassForRendering(Pass* pass)
+bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass)
 {
 	// skip all but first pass if we are doing the depth pass
-	if ((mIsDepthPassPhase || mIsItemBufferPhase) && pass->getIndex() > 0)
+	if ((mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() > 0))
 	{
 		return false;
 	}
+	// all but first pass
+	/*else if ((!mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() != 0))
+	{
+		return false;
+	}*/
 
 	return SceneManager::validatePassForRendering(pass);
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup)
+void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup)
 {
 	if (!mIsItemBufferPhase)
@@ -565,5 +590,5 @@
 	}
 
-	//-- item buffer
+	//-- item buffer: render objects using false colors
 
     // Iterate through priorities
@@ -576,5 +601,5 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup)
+void VisibilityTerrainSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup)
 {
 	// Do solids
@@ -605,5 +630,5 @@
 				ipass->first->getParent()->getParent()->getName();
 				
-			LogManager::getSingleton().logMessage(d.str());
+			//LogManager::getSingleton().logMessage(d.str());
 			
 			RenderSingleObjectForItemBuffer(*irend, ipass->first);
@@ -633,5 +658,5 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass)
+void VisibilityTerrainSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass)
 {
 	static LightList nullLightList;
@@ -674,14 +699,14 @@
 
 
-	// Render a single object, this will set up auto params if required
+	// render a single object, this will set up auto params if required
 	renderSingleObject(rend, usedPass, false, &nullLightList);
 }
 //-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::GetVisibilityManager()
+GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::GetVisibilityManager()
 {
 	return mVisibilityManager;
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::InitVisibilityCulling(Camera *cam)
+void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam)
 {
 	// reset culling manager stats
@@ -704,5 +729,5 @@
 	mLeavePassesInQueue = 0;
 
-	if (!mUseDepthPass && !mUseItemBuffer)
+	if (!DEBUG_CHC && !mUseDepthPass && !mUseItemBuffer)
 	{
 		if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE)
@@ -733,8 +758,8 @@
 	}
 
-	// skip rendering transparents in the hierarchical culling
+	// skip rendering transparents during the hierarchical culling
 	// (because they will be rendered afterwards)
-	mSkipTransparents = mUseDepthPass || 
-		(mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES);
+	mSkipTransparents = !DEBUG_CHC && 
+		(mIsDepthPassPhase || (mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES));
 
 	// -- initialise interface for rendering traversal of the hierarchy
@@ -749,15 +774,15 @@
 }
 //-----------------------------------------------------------------------
-OctreeHierarchyInterface *OcclusionCullingSceneManager::GetHierarchyInterface()
+OctreeHierarchyInterface *VisibilityTerrainSceneManager::GetHierarchyInterface()
 {
 	return mHierarchyInterface;
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::endFrame()
+void VisibilityTerrainSceneManager::endFrame()
 {
 	TerrainRenderable::ResetRenderLevelIndex();
 }
 //-----------------------------------------------------------------------
-Entity* OcclusionCullingSceneManager::createEntity(const String& entityName, 
+Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, 
 													const String& meshName)
 {
@@ -775,5 +800,5 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)
+void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)
 {
 	// only render solid passes during hierarchical culling
@@ -807,5 +832,5 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionCullingSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)
+void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)
 {
    if (mIsHierarchicalCulling)
@@ -830,3 +855,4 @@
    }
 }
+
 } // namespace Ogre
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 675)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 720)
@@ -1,3 +1,3 @@
-#include "OgreVisibilityTerrainSceneManager.h"
+#include "OgreOcclusionCullingSceneManager.h"
 #include "OgreVisibilityOptionsManager.h"
 #include <OgreMath.h>
@@ -14,5 +14,5 @@
 
 //-----------------------------------------------------------------------
-VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(
+OcclusionCullingSceneManager::OcclusionCullingSceneManager(
 							GtpVisibility::VisibilityManager *visManager): 
 mVisibilityManager(visManager), 
@@ -40,4 +40,6 @@
 	//mShowBoundingBoxes = true;
 	//mShowBoxes = true;
+//std::stringstream d; d << "here555";
+//mDummyLog.open("");
 
 	// TODO: set maxdepth to reasonable value
@@ -45,5 +47,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::InitDepthPass()
+void OcclusionCullingSceneManager::InitDepthPass()
 {
 	MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass");
@@ -66,10 +68,10 @@
 }
 //-----------------------------------------------------------------------
-VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager()
+OcclusionCullingSceneManager::~OcclusionCullingSceneManager()
 {
 	OGRE_DELETE(mHierarchyInterface);
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::InitItemBufferPass()
+void OcclusionCullingSceneManager::InitItemBufferPass()
 {
 	MaterialPtr itemBufferMat = MaterialManager::getSingleton().
@@ -95,5 +97,5 @@
 }
 //-------------------------------------------------------------------------
-void VisibilityTerrainSceneManager::setWorldGeometry( const String& filename )
+void OcclusionCullingSceneManager::setWorldGeometry( const String& filename )
 {
     // Clear out any existing world resources (if not default)
@@ -124,5 +126,5 @@
 
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam)
+void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam)
 {
 	// add player camera for visualization purpose
@@ -173,5 +175,5 @@
 }
 //-----------------------------------------------------------------------
-Pass *VisibilityTerrainSceneManager::setPass(Pass* pass)
+Pass *OcclusionCullingSceneManager::setPass(Pass* pass)
 {
 	// TODO: setting vertex program is not efficient
@@ -236,5 +238,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam,
+void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam,
 														bool onlyShadowCasters)
 {
@@ -266,5 +268,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::_renderVisibleObjects()
+void OcclusionCullingSceneManager::_renderVisibleObjects()
 {
 
@@ -329,4 +331,7 @@
 		// hierarchical visibility culling and rendering
 		InitVisibilityCulling(mCameraInProgress);
+
+		std::stringstream d; d << "here34\n";
+		LogManager::getSingleton().logMessage(d.str());
 
 		/** 
@@ -376,10 +381,10 @@
 	getRenderQueue()->clear(); // finally clear render queue
 	OGRE_DELETE(mRenderQueue); // HACK: should be cleared before...
-	//WriteLog(); // write out stats
-
-}
-
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam)
+	WriteLog(); // write out stats
+
+}
+
+//-----------------------------------------------------------------------
+void OcclusionCullingSceneManager::_updateSceneGraph(Camera* cam)
 {
 	mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
@@ -389,5 +394,5 @@
 }
 //-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val)
+bool OcclusionCullingSceneManager::setOption(const String & key, const void * val)
 {
 	if (key == "UseDepthPass")
@@ -482,5 +487,5 @@
 }
 //-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::getOption(const String & key, void *val)
+bool OcclusionCullingSceneManager::getOption(const String & key, void *val)
 {
 	if (key == "NumHierarchyNodes")
@@ -494,5 +499,5 @@
 }
 //-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::getOptionValues(const String & key, 
+bool OcclusionCullingSceneManager::getOptionValues(const String & key, 
 													StringVector &refValueList)
 {
@@ -500,5 +505,5 @@
 }
 //-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::getOptionKeys(StringVector & refKeys)
+bool OcclusionCullingSceneManager::getOptionKeys(StringVector & refKeys)
 {
 	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
@@ -506,5 +511,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::setVisibilityManager(GtpVisibility::
+void OcclusionCullingSceneManager::setVisibilityManager(GtpVisibility::
 														 VisibilityManager *visManager)
 {
@@ -512,10 +517,10 @@
 }
 //-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager( void )
+GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::getVisibilityManager( void )
 {
 	return mVisibilityManager;
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::WriteLog()
+void OcclusionCullingSceneManager::WriteLog()
 {
 	std::stringstream d;
@@ -535,5 +540,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::renderObjects(
+void OcclusionCullingSceneManager::renderObjects(
 	const RenderPriorityGroup::TransparentRenderablePassList& objs, 
     bool doLightIteration, const LightList* manualLightList)
@@ -546,5 +551,5 @@
 }
 //-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass)
+bool OcclusionCullingSceneManager::validatePassForRendering(Pass* pass)
 {
 	// skip all but first pass if we are doing the depth pass
@@ -557,5 +562,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup)
+void OcclusionCullingSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup)
 {
 	if (!mIsItemBufferPhase)
@@ -576,5 +581,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup)
+void OcclusionCullingSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup)
 {
 	// Do solids
@@ -602,8 +607,7 @@
 		for (irend = rendList->begin(); irend != irendend; ++irend)
 		{
-			std::stringstream d; d << "itembuffer, pass name: " << 
-				ipass->first->getParent()->getParent()->getName();
-				
-			LogManager::getSingleton().logMessage(d.str());
+			//std::stringstream d; d << "itembuffer, pass name: " << 
+			//	ipass->first->getParent()->getParent()->getName();
+			//	LogManager::getSingleton().logMessage(d.str());
 			
 			RenderSingleObjectForItemBuffer(*irend, ipass->first);
@@ -633,5 +637,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass)
+void OcclusionCullingSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass)
 {
 	static LightList nullLightList;
@@ -678,10 +682,10 @@
 }
 //-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::GetVisibilityManager()
+GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::GetVisibilityManager()
 {
 	return mVisibilityManager;
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam)
+void OcclusionCullingSceneManager::InitVisibilityCulling(Camera *cam)
 {
 	// reset culling manager stats
@@ -704,5 +708,6 @@
 	mLeavePassesInQueue = 0;
 
-	if (!mUseDepthPass && !mUseItemBuffer)
+	// if we have the depth pass or use an item buffer, no passes are left in the queue
+	if (0 && !mUseDepthPass && !mUseItemBuffer)
 	{
 		if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE)
@@ -746,18 +751,19 @@
 									   mLeavePassesInQueue);
 		
-	//std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;LogManager::getSingleton().logMessage(d.str());
-}
-//-----------------------------------------------------------------------
-OctreeHierarchyInterface *VisibilityTerrainSceneManager::GetHierarchyInterface()
+	std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;
+	LogManager::getSingleton().logMessage(d.str());
+}
+//-----------------------------------------------------------------------
+OctreeHierarchyInterface *OcclusionCullingSceneManager::GetHierarchyInterface()
 {
 	return mHierarchyInterface;
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::endFrame()
+void OcclusionCullingSceneManager::endFrame()
 {
 	TerrainRenderable::ResetRenderLevelIndex();
 }
 //-----------------------------------------------------------------------
-Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, 
+Entity* OcclusionCullingSceneManager::createEntity(const String& entityName, 
 													const String& meshName)
 {
@@ -775,5 +781,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)
+void OcclusionCullingSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)
 {
 	// only render solid passes during hierarchical culling
@@ -807,5 +813,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)
+void OcclusionCullingSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)
 {
    if (mIsHierarchicalCulling)
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp	(revision 343)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp	(revision 720)
@@ -681,5 +681,5 @@
 	mLeavePassesInQueue = 0;
 
-	if (!mUseDepthPass && !mUseItemBuffer)
+	if (0 && !mUseDepthPass && !mUseItemBuffer)
 	{
 		if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE)
@@ -724,5 +724,6 @@
 							mLeavePassesInQueue);
 		
-	//std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;LogManager::getSingleton().logMessage(d.str());
+	std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;
+	LogManager::getSingleton().logMessage(d.str());
 }
 //-----------------------------------------------------------------------
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h	(revision 710)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h	(revision 720)
@@ -57,5 +57,5 @@
 		/// the probability that this node contains view point
 		float mProbability;
-		/// geometry of node as induced by planes
+		/// geometry of node induced by half planes
 		BspNodeGeometry *mGeometry;
 		/// pvs size
@@ -63,8 +63,9 @@
 		/// how often this branch has missed the max-cost ratio
 		int mMaxCostMisses;
-		/// if this node is a kd-node (i.e., boundaries are axis aligned
+		/// if this node is a kd-node (i.e., boundaries are axis aligned)
 		bool mIsKdNode;
-		// hack for octree
+		/// current split axis: used for octree
 		int mAxis;
+		/// for priority traversal: priority of this traversal data
 		float mPriority;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 719)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 720)
@@ -468,10 +468,12 @@
 	
 	// the current view cells are kept in this container
-	// we start with the current view cells from the
-	// view cell manager. They will change with
-	// subsequent merges
-	ViewCellContainer &activeViewCells = mViewCellsManager->GetViewCells();
-
-
+	// we start with the current view cells from the view cell manager. 
+	// The active view cells will change with subsequent merges
+	Debug << "here2" << endl; Debug.flush();
+	// todo: should rather take initial view cells
+    ViewCellContainer &activeViewCells = mViewCellsManager->GetViewCells();
+	//ViewCellContainer activeViewCells;
+	
+	Debug << "here2.6" << endl; Debug.flush();
 	ViewCell::NewMail();
 
@@ -487,5 +489,5 @@
 	// frequency stats are updated
 	const int statsOut = 500;
-
+	Debug << "here3" << endl; Debug.flush();
 	// passes are needed for statistics, because we don't want to record
 	// every merge
@@ -501,5 +503,5 @@
 	int maxMergesPerPass;
 	int numMergedViewCells = 0;
-
+	Debug << "here5" << endl; Debug.flush();
 	environment->GetIntValue("ViewCells.PostProcess.maxMergesPerPass", maxMergesPerPass);
 	environment->GetFloatValue("ViewCells.PostProcess.avgCostMaxDeviation", avgCostMaxDeviation);
@@ -537,7 +539,8 @@
 			const int numMergedViewCells = UpdateActiveViewCells(activeViewCells);
 		
-			// refines the view cells
-			// then priorities are recomputed
-			// and the candidates are put back into merge queue
+			
+			//-- resets / refines the view cells
+			//-- priorities are recomputed
+			//-- the candidates are put back into merge queue
 			if (mRefineViewCells)
 				RefineViewCells(rays, objects);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 719)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 720)
@@ -279,5 +279,5 @@
 	float GetRendercost(ViewCell *viewCell, float objRendercost) const;
 
-	/** Returns container of loaded / generated view cells.
+	/** Returns reference to container of loaded / generated view cells.
 	*/
 	ViewCellContainer &GetViewCells();
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 719)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 720)
@@ -309,9 +309,6 @@
 	disposeRays(initialSamples, outRays);
 	
-	cout << "testing filter ... ";
-
-	TestFilter(preprocessor->mObjects);
-
-	cout << "finished" << endl;
+	// testing the view cell filter functionality	
+	if (0) TestFilter(preprocessor->mObjects);
 
 	// -- stats after contruction
@@ -359,6 +356,5 @@
 				 		Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION;*/
 
-		if (0)
-			dirSamples = !dirSamples; // toggle sampling method
+		if (0) dirSamples = !dirSamples; // toggle sampling method
 
 		numSamples += CastPassSamples(mSamplesPerPass, 
@@ -414,8 +410,8 @@
 		ComputeSampleContributions(postProcessSamples, true, storeViewCells);
 
-	// merge the view cells
+	//-- post processing (e.g.,merging) of the view cells
 	PostProcess(preprocessor->mObjects, postProcessSamples);
 
-	// only for testing
+	// only for debugging purpose
 	if (TEST_EMPTY_VIEW_CELLS)
 		CollectEmptyViewCells();
@@ -444,4 +440,6 @@
     //SetValidity(0, 99999999999);
 
+
+	// evaluation of the paritition, i.e., a number of new samples are cast
 	if (mEvaluateViewCells)
 	{
@@ -1136,5 +1134,5 @@
 void ViewCellsManager::UpdatePvs()
 {
-	if (mViewCellPvsIsUpdated)
+	if (mViewCellPvsIsUpdated || !ViewCellsTreeConstructed())
 		return;
 
@@ -1245,8 +1243,10 @@
 void ViewCellsManager::ResetViewCells()
 {
+	// recollect view cells
 	mViewCells.clear();
-	
 	CollectViewCells();
 	
+	
+	// stats are computed once more
 	mCurrentViewCellsStats.Reset();
 	EvaluateViewCellsStats();
@@ -3325,4 +3325,5 @@
 		maxPvs = mMaxPvsSize;
 	}
+
 	Debug << "setting validity, min: " << minPvs << " max: " << maxPvs << endl;
 	cout << "setting validity, min: " << minPvs << " max: " << maxPvs << endl;
@@ -3331,8 +3332,7 @@
 
 	// update valid view space according to valid view cells
-	if (0)
-		mVspBspTree->ValidateTree();
-
-	// has to be recomputed
+	if (0) mVspBspTree->ValidateTree();
+
+	// area has to be recomputed
 	mTotalAreaValid = false;
 	VssRayContainer postProcessRays;
@@ -3345,19 +3345,17 @@
 	// and to correct the rendering statistics
 	if (0) FinalizeViewCells(false);
-	
-	
+		
 	//-- merge the individual view cells
 	MergeViewCells(postProcessRays, objects);
 	
-	// only for testing
+
+	// only for debugging purpose: test if the subdivision is valid
 	TestSubdivision();
 
 	//-- refines the merged view cells
-	if (0)
-		RefineViewCells(postProcessRays, objects);
+	if (0) RefineViewCells(postProcessRays, objects);
 
 	
 	//-- render simulation after merge + refine
-	
 	cout << "\nevaluating bsp view cells render time before compress ... ";
 	dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene();
@@ -3372,5 +3370,4 @@
 
 	//-- compression
-
 	if (ViewCellsTreeConstructed() && mCompressViewCells)
 	{
Index: GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp
===================================================================
--- GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp	(revision 675)
+++ GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp	(revision 720)
@@ -110,5 +110,5 @@
 }
 
-
+// Computes number of view cells to reach the same render cost
 int ComputeNoViewCells(const StatsContainer &firstStats, 
 					   const StatsContainer &currentStats)
@@ -116,5 +116,5 @@
 	const int n = min((int)firstStats.size(), (int)currentStats.size());
 
-	const float renderCost = (int)currentStats[n - 1].mRenderCost;
+	const float renderCost = (float)currentStats[n - 1].mRenderCost;
 
 	int i = 0;
