Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/RandomUpdateCullingManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/RandomUpdateCullingManager.h	(revision 2258)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/RandomUpdateCullingManager.h	(revision 2258)
@@ -0,0 +1,55 @@
+#ifndef _RandomUpdateCullingManager_H__
+#define _RandomUpdateCullingManager_H__
+
+#include "CullingManager.h"
+#include "HierarchyInterface.h"
+
+
+namespace GtpVisibility
+{
+
+/** Renders the scene with the coherent hierarchical culling algorithm. 
+*/
+class RandomUpdateCullingManager : public CullingManager
+{
+public:
+	RandomUpdateCullingManager();
+	/** Constructor taking the assumed visibility into account, i.e., the estimation
+		for how many frames the current visibility is considered to be valid
+	*/
+	RandomUpdateCullingManager(const unsigned int assumedVisibility);
+
+	void RenderScene();
+	/** Sets assumed visibility (i.e., an estimation for 
+		how many frames the visibility is considered to be valid).
+		@param assumedVisibility indicates for how many frames the 
+		same visibility is be assumed.
+		if 0, the visibility is tested deterministically for each frame.
+	*/
+	void SetAssumedVisibility(const unsigned int assumedVisibility);
+
+protected:
+	/** Decides if node is considered to be visible depeding on the 
+		assumed visibility factor.
+		@returns if node is considered to be visible
+	*/
+	bool DecideVisible(HierarchyNode *node) const;
+
+
+	/** Skip query for this node.
+	*/
+	void SkipQuery(HierarchyNode *node) const;
+
+	/** number of steps the visibility is assumed to be valid.
+	*/
+	unsigned int mAssumedVisibility;
+
+	/** Threshold for rand function to return positive result with respect to
+		mAssumedVisibility.
+	*/
+	int mThreshold;
+};
+
+} // namespace GtpVisibility
+
+#endif // RandomUpdateCullingManager_H
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h	(revision 925)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h	(revision 2258)
@@ -84,5 +84,6 @@
 		@param intersects returns true if the current node intersects the near plane
 	*/
-	virtual bool CheckFrustumVisible(HierarchyNode *node, bool &intersects) = 0;
+	virtual bool CheckFrustumVisible(HierarchyNode *node, 
+									 bool &intersects) = 0;
 	/** Checks if the node is visible from the current view frustum.
 		@param node the current node
@@ -102,5 +103,6 @@
 		@param visible the visible flag
 	*/
-	virtual void SetNodeVisible(HierarchyNode *node, const bool visible) const = 0;
+	virtual void SetNodeVisible(HierarchyNode *node, 
+								const bool visible) const = 0;
 	/** Returns true if node has the visible flag set. See set
 	*/
@@ -143,6 +145,6 @@
 	*/
 	virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node,	
-					 		 GeometryVector *geometryList, 
-							 bool includeChildren) = 0;
+					 				 GeometryVector *geometryList, 
+									 bool includeChildren) = 0;
 
 	
@@ -156,4 +158,11 @@
 	void TestGeometryForVisibleLeaves(bool testGeometry);
 
+
+	virtual void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const = 0;
+
+	virtual void TraverseNode2(GtpVisibility::HierarchyNode *node) = 0;
+
+	virtual HierarchyNode *GetRandomLeaf() = 0;
+	virtual bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const;
 
 protected:
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp	(revision 2184)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp	(revision 2258)
@@ -12,6 +12,6 @@
 }
 //-----------------------------------------------------------------------
-CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager(const unsigned int 
-																	   assumedVisibility)
+CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager(
+														const unsigned int assumedVisibility)
 {
 	SetAssumedVisibility(assumedVisibility);
@@ -67,5 +67,4 @@
 		if (!mHierarchyInterface->GetQueue()->empty())
 		{
-			//Ogre::LogManager::getSingleton().logMessage("traversal");
 			HierarchyNode *node = mHierarchyInterface->GetQueue()->top();
 			mHierarchyInterface->GetQueue()->pop();
@@ -96,7 +95,4 @@
 					DecideVisible(node) && mHierarchyInterface->HasGeometry(node);
 
-				//if (mHierarchyInterface->LastVisited(node) >= mHierarchyInterface->GetFrameId())
-				//	Ogre::LogManager::getSingleton().logMessage("error");
-				
 				if (skipQuery)
 				{
@@ -115,5 +111,5 @@
 				// update node's visited flag
 				mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
-				//Ogre::LogManager::getSingleton().logMessage("here999");
+				
 				// skip testing previously visible nodes without geometry
 				if (issueQuery)
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 2183)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 2258)
@@ -315,4 +315,7 @@
 			</File>
 			<File
+				RelativePath=".\RandomUpdateCullingManager.cpp">
+			</File>
+			<File
 				RelativePath="..\src\StopAndWaitCullingManager.cpp">
 			</File>
@@ -360,4 +363,7 @@
 			<File
 				RelativePath="..\include\QueryManager.h">
+			</File>
+			<File
+				RelativePath="..\include\RandomUpdateCullingManager.h">
 			</File>
 			<File
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp	(revision 2258)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp	(revision 2258)
@@ -0,0 +1,187 @@
+#include "RandomUpdateCullingManager.h"
+#include <OgreLogManager.h>
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+RandomUpdateCullingManager::RandomUpdateCullingManager()
+{
+	SetAssumedVisibility(0);
+	// initialise random generator in case we use assumed visibility
+	srand(time(NULL));
+}
+//-----------------------------------------------------------------------
+RandomUpdateCullingManager::RandomUpdateCullingManager(
+			const unsigned int assumedVisibility)
+{
+	SetAssumedVisibility(assumedVisibility);
+	// initialise random generator in case we use assumed visibility
+	srand(time(NULL));
+}
+//-----------------------------------------------------------------------
+void RandomUpdateCullingManager::RenderScene()
+{
+	QueryQueue queryQueue;
+	unsigned int visiblePixels = 0;
+	
+	/////////////
+	//-- PART 1: process finished occlusion queries
+
+	while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty())
+	{
+		bool resultAvailable = false;
+
+		//-- only wait for result if there are no nodes to process
+		while (!queryQueue.empty() && 
+				queryQueue.front().second->GetQueryResult(visiblePixels, 
+				mHierarchyInterface->GetQueue()->empty()))
+		{
+        	HierarchyNode *node = queryQueue.front().first;
+			
+			queryQueue.pop();
+			
+			if (visiblePixels > mVisibilityThreshold)
+			{
+				// in case geometry is in interior node: 
+				// ensure that we only traverse once
+				if (!mHierarchyInterface->IsNodeVisible(node))
+				{
+					mHierarchyInterface->TraverseNode(node);
+				}
+
+				mHierarchyInterface->PullUpVisibility(node);
+			}
+			else
+			{	
+				mHierarchyInterface->SetNodeVisible(node, false);
+
+				++ mNumQueryCulledNodes;
+				
+				if (mVisualizeCulledNodes)
+				{
+					mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED);
+				}
+			}
+		}
+		
+		//-- PART 2: hierarchical traversal
+		if (!mHierarchyInterface->GetQueue()->empty())
+		{
+			HierarchyNode *node = mHierarchyInterface->GetQueue()->top();
+			mHierarchyInterface->GetQueue()->pop();
+				
+			bool intersects = false;
+
+			if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
+			{
+				++ mNumFrustumCulledNodes;	
+				if (mVisualizeCulledNodes)
+				{
+					mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
+				}
+			}
+			//-- if node intersects near plane, skip query because wrong results possible
+			else if (intersects)
+			{
+				SkipQuery(node);
+			}
+			else
+			{
+				// identify previously visible nodes
+				const bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 
+					(mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1);
+				
+				// if we assume node to be visible in this frame => skip query 
+				const bool skipQuery = wasVisible && (mAssumedVisibility > 0) && 
+					DecideVisible(node) && mHierarchyInterface->HasGeometry(node);
+
+				if (skipQuery)
+				{
+					SkipQuery(node);
+					continue;
+				}
+				
+				if (mHierarchyInterface->IsNodeFullyVisible(node))
+				{
+					// node fully visible => test only random leaves
+					/*for (int i = 0; i < mRandomCandidates; ++ i)
+					{
+						HierarchyNode *randomLeaf = mHierarchyInterface->GetRandomLeaf(node);
+
+						mHierarchyInterface->SetNodeVisible(randomLeaf, false);
+
+						// update node's visited flag
+						mHierarchyInterface->SetLastVisited(randomLeaf, 
+															mHierarchyInterface->GetFrameId());
+
+						queryQueue.push(QueryPair(node, 
+							mHierarchyInterface->IssueNodeOcclusionQuery(node, wasVisible)));
+					}*/
+
+					continue;
+				}
+
+                // identify nodes that we cannot skip queries for
+				// geometry not only in leaves => test for renderable geometry
+				const bool issueQuery = !wasVisible || mHierarchyInterface->HasGeometry(node);
+							
+				// reset node's visibility classification
+				// set visibe if geometry in node => we only traverse the node once
+				mHierarchyInterface->SetNodeVisible(node, wasVisible && issueQuery);
+
+				// update node's visited flag
+				mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
+				
+
+				// skip testing previously visible nodes without geometry
+				if (issueQuery)
+				{
+					++ mNumQueriesIssued;
+					
+					queryQueue.push(QueryPair(node, mHierarchyInterface->
+						IssueNodeOcclusionQuery(node, wasVisible)));
+				}
+				
+				// always traverse a node if it was visible
+				if (wasVisible)
+				{
+					mHierarchyInterface->TraverseNode(node);
+				}
+			}
+		}
+	}
+}
+//-----------------------------------------------------------------------
+void RandomUpdateCullingManager::SetAssumedVisibility(const unsigned int assumedVisibility)
+{
+	mAssumedVisibility = assumedVisibility;
+	
+	mThreshold = 0;
+
+	if (mAssumedVisibility > 0)
+	{
+		mThreshold = RAND_MAX - RAND_MAX / mAssumedVisibility;
+		if (mAssumedVisibility > 100) // fix visibility
+			mThreshold = RAND_MAX;
+	}
+	//std::stringstream d; d << "*** setting assumed vis: " << mAssumedVisibility; Ogre::LogManager::getSingleton().logMessage(d.str());
+}
+//-----------------------------------------------------------------------
+inline bool RandomUpdateCullingManager::DecideVisible(HierarchyNode *node) const
+{
+	//bool result = rand() < mThreshold; std::stringstream d; d << "Assumed vis: " << mAssumedVisibility << ", result: " << result;
+	//Ogre::LogManager::getSingleton().logMessage(d.str()); return result;
+	
+	return rand() < mThreshold;
+}
+//-----------------------------------------------------------------------
+inline void RandomUpdateCullingManager::SkipQuery(HierarchyNode *node) const
+{
+	// -- set node to be visible in this frame, then traverse it
+	mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
+	
+	mHierarchyInterface->PullUpVisibility(node);			
+	mHierarchyInterface->TraverseNode(node);
+}
+
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOctreeHierarchyInterface.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOctreeHierarchyInterface.h	(revision 370)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOctreeHierarchyInterface.h	(revision 2258)
@@ -51,4 +51,12 @@
 							 bool includeChildren);
 	
+	void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const;
+
+	void TraverseNode2(GtpVisibility::HierarchyNode *node);
+
+	HierarchyNode *GetRandomLeaf();
+
+	bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const;
+
 protected:
 	/** Returns pointer to the bounding box of the node.
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreSceneNodeHierarchyInterface.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreSceneNodeHierarchyInterface.h	(revision 370)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreSceneNodeHierarchyInterface.h	(revision 2258)
@@ -46,4 +46,9 @@
 					 bool includeChildren);
 
+	void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {}
+	void TraverseNode2(GtpVisibility::HierarchyNode *node) {}
+	HierarchyNode *GetRandomLeaf() { return NULL;}
+	bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;}
+
 };
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyInterface.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyInterface.h	(revision 1320)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyInterface.h	(revision 2258)
@@ -61,5 +61,6 @@
 	@param visible the visible flag
 	*/
-	virtual void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const;
+	virtual void SetNodeVisible(GtpVisibility::HierarchyNode *node, 
+								const bool visible) const;
 	/** Returns true if node has the visible flag set. See set
 	*/
@@ -69,5 +70,6 @@
 	@param frameId the current frame id
 	*/
-	virtual void SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) const;
+	virtual void SetLastVisited(GtpVisibility::HierarchyNode *node, 
+								const unsigned int frameId) const;
 	/** Returns frame id when this node was last visited by the traverser. See set
 	*/
@@ -80,5 +82,5 @@
 	*/
 	virtual void VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 
-		GtpVisibility::CullingType type) const;
+									 GtpVisibility::CullingType type) const;
 
 
@@ -89,8 +91,10 @@
 	*/
 	virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node,	
-		GtpVisibility::GeometryVector *geometryList, 
-		bool includeChildren);
+									 GtpVisibility::GeometryVector *geometryList, 
+									 bool includeChildren);
 
-
+	void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {}
+	void TraverseNode2(GtpVisibility::HierarchyNode *node) {}
+	bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;}
 };
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeHierarchyInterface.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeHierarchyInterface.h	(revision 1170)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeHierarchyInterface.h	(revision 2258)
@@ -61,5 +61,6 @@
 	@param visible the visible flag
 	*/
-	virtual void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const;
+	virtual void SetNodeVisible(GtpVisibility::HierarchyNode *node, 
+								const bool visible) const;
 	/** Returns true if node has the visible flag set. See set
 	*/
@@ -69,5 +70,6 @@
 	@param frameId the current frame id
 	*/
-	virtual void SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) const;
+	virtual void SetLastVisited(GtpVisibility::HierarchyNode *node, 
+								const unsigned int frameId) const;
 	/** Returns frame id when this node was last visited by the traverser. See set
 	*/
@@ -80,5 +82,5 @@
 	*/
 	virtual void VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 
-		GtpVisibility::CullingType type) const;
+									 GtpVisibility::CullingType type) const;
 
 
@@ -89,8 +91,14 @@
 	*/
 	virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node,	
-		GtpVisibility::GeometryVector *geometryList, 
-		bool includeChildren);
+									 GtpVisibility::GeometryVector *geometryList, 
+									 bool includeChildren);
 
+	void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {}
 
+	void TraverseNode2(GtpVisibility::HierarchyNode *node);
+
+	HierarchyNode *GetRandomLeaf() { return NULL;}
+
+	bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;}
 };
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchyInterface.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchyInterface.cpp	(revision 2066)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchyInterface.cpp	(revision 2258)
@@ -49,4 +49,5 @@
 }
 
+
 void BvHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node)
 {
@@ -62,4 +63,5 @@
 	}
 }
+
 
 void BvHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2255)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2258)
@@ -12,11 +12,10 @@
 #include <OgreIteratorWrappers.h>
 #include <OgreHeightmapTerrainPageSource.h>
-#include "VspBspTree.h"
-#include "Containers.h"
+//#include "Containers.h"
 #include "ViewCellsManager.h"
 #include <OgreConfigFile.h>
 #include "OgreTypeConverter.h"
 #include "OgreMeshInstance.h"
-#include "common.h"
+//#include "common.h"
 #include "OgreBoundingBoxConverter.h"
 #include <OgreManualObject.h>
@@ -775,12 +774,4 @@
 														bool onlyShadowCasters)
 {
-	// clear render queue
-	// fully reset it after some frames
-	const bool flushQueue = 
-		mDeleteQueueAfterRendering && ((mCurrentFrame % mFlushRate) == 0);
-	getRenderQueue()->clear(flushQueue);
-
-	++ mCurrentFrame;
-
 	if (mShowVisualization)
     {
@@ -790,5 +781,5 @@
 		PrepareVisualization(cam);
 		
-			// lists only used for visualization
+		// lists only used for visualization
 		mVisible.clear();
 		mBoxes.clear();
@@ -797,8 +788,4 @@
 	}
 	
-
-	mVisible.clear();
-	mBoxes.clear();
-
 	///////////
 	//-- set visibility according to pvs of current view cell
@@ -820,10 +807,13 @@
 	else if (mUseDepthPass)
 	{
+		mVisible.clear();
+		mBoxes.clear();
+
+		// clear render queue before depth pass
+		getRenderQueue()->clear();
+
 		// render scene once in order to fill depth buffer
 		RenderHierarchicalCulling();
 	}
-	
-	// only shadow casters will be rendered in shadow texture pass
-	//if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
 }
 //-----------------------------------------------------------------------
@@ -838,6 +828,10 @@
 	}
 
-	//const bool flushQueue = mDeleteQueueAfterRendering && ((mCurrentFrame % mFlushRate) == 0);
-	//++ mCurrentFrame;
+	// clear render queue
+	// fully reset it after some frames
+	const bool flushQueue = 
+		mDeleteQueueAfterRendering && ((mCurrentFrame % mFlushRate) == 0);
+	
+	++ mCurrentFrame;
 
 	// create material for item buffer pass
@@ -956,7 +950,6 @@
 
 	// remove rest from queue
-#if 0
 	getRenderQueue()->clear(flushQueue);
-#endif
+
 	
 	if (0) WriteLog(); // write out stats
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp	(revision 2066)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp	(revision 2258)
@@ -9,8 +9,8 @@
 
 //-----------------------------------------------------------------------
-OctreeHierarchyInterface::OctreeHierarchyInterface(OctreeSceneManager *sm, RenderSystem *rsys): 
+OctreeHierarchyInterface::OctreeHierarchyInterface(OctreeSceneManager *sm, 
+												   RenderSystem *rsys): 
 SceneNodeHierarchyInterface(sm, rsys)
-{
-}
+{}
 //-----------------------------------------------------------------------
 void OctreeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node)
@@ -27,4 +27,57 @@
 	
 	
+	// if not all subtrees are empty
+	if (!IsLeaf(node))
+	{
+		Octree *nextChild;
+
+		if ((nextChild = octree->mChildren[0][0][0]) != NULL)
+			mDistanceQueue->push(nextChild);
+		if ((nextChild = octree->mChildren[0][0][1]) != NULL)
+			mDistanceQueue->push(nextChild);
+		if ((nextChild = octree->mChildren[0][1][0]) != NULL)
+			mDistanceQueue->push(nextChild);
+		if ((nextChild = octree->mChildren[0][1][1]) != NULL)
+           	mDistanceQueue->push(nextChild);
+		if ((nextChild = octree->mChildren[1][0][0]) != NULL)
+			mDistanceQueue->push(nextChild);
+		if ((nextChild = octree->mChildren[1][0][1]) != NULL)
+			mDistanceQueue->push(nextChild);
+		if ((nextChild = octree->mChildren[1][1][0]) != NULL)
+			mDistanceQueue->push(nextChild);
+		if ((nextChild = octree->mChildren[1][1][1]) != NULL)
+			mDistanceQueue->push(nextChild);
+	}
+}
+//-----------------------------------------------------------------------
+HierarchyNode *OctreeHierarchyInterface::GetRandomLeaf() 
+{ 
+	return NULL;
+}
+//-----------------------------------------------------------------------
+bool OctreeHierarchyInterface::GIsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const
+{
+	return static_cast<Octree *>(node)->isOctreeFullyVisible();
+}
+//-----------------------------------------------------------------------
+void OctreeHierarchyInterface::TraverseNode2(GtpVisibility::HierarchyNode *node)
+{
+	++ mNumTraversedNodes;
+
+	Octree *octree = static_cast<Octree *>(node);
+
+	// if we come across some renderable geometry => render it
+	if (!octree->mNodes.empty())
+	{
+		// render everything from here
+		if (octree->isOctreeFullyVisible())
+		{		
+			RenderNodeRecursive(node);
+			return;
+		}
+
+		RenderNode(node);
+	}
+		
 	// if not all subtrees are empty
 	if (!IsLeaf(node))
@@ -107,4 +160,37 @@
 }
 //-----------------------------------------------------------------------
+void OctreeHierarchyInterface::DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const
+{		
+	Octree *octant = static_cast<Octree *>(node);
+
+	// leaf node: terminate recursion
+	if (IsLeaf(node))
+	{
+		octant->setOctreeFullyVisible(octant->isOctreeVisible());
+		return;
+	}
+
+	octant->setOctreeFullyVisible(false);
+
+	Octree *nextChild;
+
+	for (int i = 0; i < 8; ++ i)
+	{
+		int x = i & 4;
+		int y = i & 2;
+		int z = i & 1;
+
+		if ((nextChild = octant->mChildren[x][y][z]) != NULL)
+		{
+			DetermineFullVisibility(nextChild);
+			if (!nextChild->isOctreeFullyVisible())
+			return;
+		}
+	}
+
+	// all children fully visible => pull up
+	octant->setOctreeFullyVisible(true);
+}
+//-----------------------------------------------------------------------
 void OctreeHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node)
 {
@@ -118,10 +204,12 @@
 			static_cast<OctreeSceneManager *>(mSceneManager);
 
-		ocm->_renderOctant(mCamera, octant, mOnlyShadowCasters, mLeavePassesInQueue);
+		ocm->_renderOctant(mCamera, 
+						   octant, 
+						   mOnlyShadowCasters, 
+						   mLeavePassesInQueue);
 
 		mVisibleNodes.push_back(node);
 	}
-#endif
-	
+#endif	
 }
 //-----------------------------------------------------------------------
@@ -189,3 +277,4 @@
 }
 
+
 } // namespace Ogre
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2255)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2258)
@@ -3607,6 +3607,6 @@
 			if (mCurrentViewCellsStats.maxPvs)
 			{
-				importance = (float)mViewCellsTree->GetPvsCost(vc) / 
-							 (float)mCurrentViewCellsStats.maxPvs;
+				importance = (float)mViewCellsTree->GetPvsCost(vc) / 700;
+							 //(float)mCurrentViewCellsStats.maxPvs;
 			}
 		}
@@ -3618,13 +3618,4 @@
 		}
 		break;
-#if 0
-	case 3: // merge tree differene
-		{
-			importance = (float)GetMaxTreeDiff(vc) /
-				(float)(mVspBspTree->GetStatistics().maxDepth * 2);
-
-		}
-		break;
-#endif
 	default:
 		break;
@@ -6365,5 +6356,5 @@
 		const int savedColorCode = mColorCode;
 
-		const float maxRenderCost = -1;//UpdateObjectCosts();
+		const float maxRenderCost = UpdateObjectCosts();
 		cout << "maxRenderCost: " << maxRenderCost << endl;
 		mColorCode = 0; // 0 = random, 1 = export pvs
@@ -6412,6 +6403,9 @@
 
 		if (1)
-		mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, 
-													  CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false);
+		mHierarchyManager->ExportObjectSpaceHierarchy(exporter, 
+													  objects, 
+													  CLAMP_TO_BOX ? &bbox : NULL, 
+													  maxRenderCost, 
+													  false);
 		
 
Index: GTP/trunk/Lib/Vis/GtpVisibility.sln
===================================================================
--- GTP/trunk/Lib/Vis/GtpVisibility.sln	(revision 2255)
+++ GTP/trunk/Lib/Vis/GtpVisibility.sln	(revision 2258)
@@ -19,4 +19,12 @@
 		{101A7691-74F3-48B4-96A3-CF35578F5900} = {101A7691-74F3-48B4-96A3-CF35578F5900}
 		{EABCE292-D598-4600-A1C9-2591E7D62FDA} = {EABCE292-D598-4600-A1C9-2591E7D62FDA}
+		{7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D}
+		{7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D}
+		{7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D}
+		{7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D}
+		{7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D}
+		{7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D}
+		{7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D}
+		{7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D}
 	EndProjectSection
 EndProject
