Index: trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp	(revision 59)
+++ trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp	(revision 74)
@@ -1,17 +1,14 @@
 #include "FrustumCullingManager.h"
+
+#include <windows.h>
 
 namespace GtpVisibility {
 
 //-----------------------------------------------------------------------
-FrustumCullingManager::FrustumCullingManager(HierarchyInterface *hierarchyInterface):
-CullingManager(hierarchyInterface)
-{
-}
-//-----------------------------------------------------------------------
 void FrustumCullingManager::RenderScene()
 {
 	mNumFrustumCulledNodes = mNumQueryCulledNodes = 0;
-
-	while(!mHierarchyInterface->GetQueue()->empty())
+	
+	while (!mHierarchyInterface->GetQueue()->empty())
 	{
 		HierarchyNode *node = mHierarchyInterface->GetQueue()->top();
@@ -22,21 +19,13 @@
 		mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
 
-		bool intersects = false;
-
-		if(mHierarchyInterface->CheckFrustumVisible(node, intersects))
+		if (!mHierarchyInterface->CheckFrustumVisible(node))
 		{
 			mNumFrustumCulledNodes ++;
-			continue;
 		}
-		
-		//if intersects near plane => skip occlusion query because wrong results possible
-		if(intersects)
-		{
-            mHierarchyInterface->SetNodeVisible(node, true);
+		else
+		{		
+			mHierarchyInterface->SetNodeVisible(node, true);
 			mHierarchyInterface->TraverseNode(node);
-			continue;
 		}
-
-		mHierarchyInterface->TraverseNode(node);
 	}
 }
Index: trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 59)
+++ trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 74)
@@ -3,9 +3,4 @@
 namespace GtpVisibility {
 
-//-----------------------------------------------------------------------
-CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager(HierarchyInterface *hierarchyInterface):
-CullingManager(hierarchyInterface)
-{
-}
 //-----------------------------------------------------------------------
 void CoherentHierarchicalCullingManager::RenderScene()
@@ -46,45 +41,46 @@
 			bool intersects = false;
 
-			if(!mHierarchyInterface->CheckFrustumVisible(node, intersects))
+			if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
 			{
 				mNumFrustumCulledNodes ++;
-				continue;
 			}
+			else
+			{
+				// if intersects near plane => skip occlusion query because wrong results possible
+				if (intersects)
+				{
+					// update octant's visited flag
+					mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
 
-			// if intersects near plane => skip occlusion query because wrong results possible
-			if (intersects)
-			{
-				// update octant's visited flag
+					mHierarchyInterface->PullUpVisibility(node);			
+					mHierarchyInterface->TraverseNode(node);
+
+					continue;
+				}
+
+				// identify previously visible nodes
+				bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 
+					(mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1);
+				
+				// identify nodes that we cannot skip queries for
+				bool mustQuery = !wasVisible || mHierarchyInterface->HasGeometry(node) || mHierarchyInterface->IsLeaf(node);
+
+				// reset node's visibility classification 
+				mHierarchyInterface->SetNodeVisible(node, false);
+
+				// update node's visited flag
 				mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
-
-				mHierarchyInterface->PullUpVisibility(node);			
-				mHierarchyInterface->TraverseNode(node);
-
-				continue;
-			}
-
-			// identify previously visible nodes
-			bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 
-				(mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1);
-				
-			// identify nodes that we cannot skip queries for
-			bool mustQuery = !wasVisible || mHierarchyInterface->HasGeometry(node) || mHierarchyInterface->IsLeaf(node);
-
-			// reset node's visibility classification 
-			mHierarchyInterface->SetNodeVisible(node, false);
-
-			// update node's visited flag
-			mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
 			
-			// skip testing previously visible interior nodes
-			if (mustQuery)
-			{
-				queryQueue.push(QueryPair(node, mHierarchyInterface->IssueOcclusionQuery(node)));
-			}
+				// skip testing previously visible interior nodes
+				if (mustQuery)
+				{
+					queryQueue.push(QueryPair(node, mHierarchyInterface->IssueOcclusionQuery(node)));
+				}
 					
-			// always traverse a node if it was visible
-			if (wasVisible)
-			{
-				mHierarchyInterface->TraverseNode(node);
+				// always traverse a node if it was visible
+				if (wasVisible)
+				{
+					mHierarchyInterface->TraverseNode(node);
+				}
 			}
 		}
Index: trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp	(revision 59)
+++ trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp	(revision 74)
@@ -1,5 +1,5 @@
 #include "HierarchyInterface.h"
 
-//#include <windows.h>
+#include <windows.h>
 
 namespace GtpVisibility {
@@ -7,6 +7,6 @@
 //-----------------------------------------------------------------------
 HierarchyInterface::HierarchyInterface(): 
-mFrameId(1), mNumSceneNodes(0), mNumTraversedNodes(0), 
-mNumRenderedNodes(0), mSceneRoot(0), mCurrentTestIdx(0)
+mFrameId(0), mNumTraversedNodes(0), mNumRenderedNodes(0), 
+mSceneRoot(0), mCurrentTestIdx(0)
 {	
 	mDistanceQueue = new DistanceQueue(GreaterDistance<HierarchyNode *>(this));
@@ -25,5 +25,5 @@
 void HierarchyInterface::InitFrame(HierarchyNode *root)
 {
-	mFrameId = 0;
+	mFrameId ++;
 	mNumTraversedNodes = 0;
 	mNumRenderedNodes = 0;
@@ -33,5 +33,5 @@
 }
 //-----------------------------------------------------------------------
-int HierarchyInterface::GetFrameId()
+unsigned int HierarchyInterface::GetFrameId() const
 {
 	return mFrameId;
@@ -42,3 +42,24 @@
 	return mDistanceQueue;
 }
+//-----------------------------------------------------------------------
+bool HierarchyInterface::CheckFrustumVisible(HierarchyNode *node)
+{
+	bool intersects = false;
+	return CheckFrustumVisible(node, intersects);
+}
+//-----------------------------------------------------------------------
+HierarchyNode *HierarchyInterface::GetSceneRoot() const 
+{
+	return mSceneRoot;
+}
+//-----------------------------------------------------------------------
+unsigned int HierarchyInterface::GetNumTraversedNodes()
+{
+	return mNumTraversedNodes;
+}
+//-----------------------------------------------------------------------
+unsigned int HierarchyInterface::GetNumRenderedNodes()
+{
+	return mNumRenderedNodes;
+}
 } // namespace GtpVisibility
Index: trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/VisibilityManager.cpp	(revision 65)
+++ trunk/VUT/GtpVisibility/src/VisibilityManager.cpp	(revision 74)
@@ -7,24 +7,24 @@
 
 namespace GtpVisibility {
-
-VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment)
+//-----------------------------------------------------------------------
+VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment):
+mVisibilityThreshold(0)
 {
 	mVisibilityEnvironment = visEnvironment;
-	//mVisibilityManagerType = VisibilityEnvironment::STOP_AND_WAIT;
-	//mVisibilityManager = new StopAndWaitCullingManager(NULL);
-	mCullingManagerType = VisibilityEnvironment::FRUSTUM_CULLING;
-	mCullingManager = new FrustumCullingManager(0);
+	
+	mCullingManagerType = VisibilityEnvironment::STOP_AND_WAIT_CULLING;
+	mCullingManager = new StopAndWaitCullingManager();
 
 	mQueryManager = new DummyQueryManager(0);
 	mPreprocessingManager = new DummyPreprocessingManager(0);
-
 }
-
+//-----------------------------------------------------------------------
 VisibilityManager::~VisibilityManager()
 {
 	delete mCullingManager;
 }
-
-void VisibilityManager::SetCullingManager(VisibilityEnvironment::CullingManagerType ocmType)
+//-----------------------------------------------------------------------
+void VisibilityManager::SetCullingManager(
+	VisibilityEnvironment::CullingManagerType ocmType)
 {
 	if (mCullingManagerType != ocmType)
@@ -35,31 +35,37 @@
 		switch (ocmType)
 		{
-		case VisibilityEnvironment::STOP_AND_WAIT:
-			mCullingManager = new StopAndWaitCullingManager(NULL);
+		case VisibilityEnvironment::STOP_AND_WAIT_CULLING:
+			mCullingManager = new StopAndWaitCullingManager();
 			break;
 
 		case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING:
-			mCullingManager = new CoherentHierarchicalCullingManager(NULL);
+			mCullingManager = new CoherentHierarchicalCullingManager();
 			break;
 
 		case VisibilityEnvironment::FRUSTUM_CULLING:
-			mCullingManager = new FrustumCullingManager(NULL);
+			mCullingManager = new FrustumCullingManager();
 			break;
 		default:
-			mCullingManager = new StopAndWaitCullingManager(NULL);
+			mCullingManager = new StopAndWaitCullingManager();
 			break;
 		}
 	}
 }
-
+//-----------------------------------------------------------------------
+void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
+{
+	mVisibilityThreshold = visibilityThreshold;
+	mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
+}
+//-----------------------------------------------------------------------
 CullingManager *VisibilityManager::GetCullingManager()
 {
 	return mCullingManager;
 }
-
+//-----------------------------------------------------------------------
 void VisibilityManager::ApplyVisibilityCulling()
 {
 	mCullingManager->RenderScene();
 }
-
+//-----------------------------------------------------------------------
 } // namespace GtpVisibility
Index: trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 59)
+++ trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 74)
@@ -3,9 +3,4 @@
 namespace GtpVisibility {
 
-//-----------------------------------------------------------------------
-StopAndWaitCullingManager::StopAndWaitCullingManager(HierarchyInterface *HierarchyInterface):
-CullingManager(HierarchyInterface)
-{
-}
 //-----------------------------------------------------------------------
 void StopAndWaitCullingManager::RenderScene()
@@ -24,27 +19,28 @@
 		bool intersects = false;
 
-		if (mHierarchyInterface->CheckFrustumVisible(node, intersects))
+		if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
 		{
 			mNumFrustumCulledNodes ++;
-			continue;
-		}
-		
-		//if intersects near plane => skip occlusion query because wrong results possible
-		if (intersects)
-		{
-            mHierarchyInterface->SetNodeVisible(node, true);
-			mHierarchyInterface->TraverseNode(node);
-			continue;
-		}
-
-		// node visible
-		if (mHierarchyInterface->IssueOcclusionQuery(node)->GetQueryResult() > 
-			mVisibilityThreshold)
-		{
-			mHierarchyInterface->TraverseNode(node);
 		}
 		else
 		{
-			mNumQueryCulledNodes ++;
+			//if intersects near plane => skip occlusion query because wrong results possible
+			if (intersects)
+			{
+	            mHierarchyInterface->SetNodeVisible(node, true);
+				mHierarchyInterface->TraverseNode(node);
+				continue;
+			}
+
+			// node visible
+			if (mHierarchyInterface->IssueOcclusionQuery(node)->GetQueryResult() > 
+				mVisibilityThreshold)
+			{
+				mHierarchyInterface->TraverseNode(node);
+			}
+			else
+			{
+				mNumQueryCulledNodes ++;
+			}
 		}
 	}
Index: trunk/VUT/GtpVisibility/src/CullingManager.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/CullingManager.cpp	(revision 59)
+++ trunk/VUT/GtpVisibility/src/CullingManager.cpp	(revision 74)
@@ -4,6 +4,6 @@
 
 //-----------------------------------------------------------------------
-CullingManager::CullingManager(HierarchyInterface *hierarchyInterface):
-mHierarchyInterface(hierarchyInterface), mVisibilityThreshold(0), mNumQueryCulledNodes(0), 
+CullingManager::CullingManager():
+mHierarchyInterface(NULL), mVisibilityThreshold(0), mNumQueryCulledNodes(0), 
 mNumFrustumCulledNodes(0)
 {
@@ -14,3 +14,18 @@
 	mHierarchyInterface = hierarchyInterface;
 }
+//-----------------------------------------------------------------------
+void CullingManager::SetVisibilityThreshold(unsigned int visibilityThreshold)
+{
+	mVisibilityThreshold = visibilityThreshold;
+}
+//-----------------------------------------------------------------------
+unsigned int CullingManager::GetNumFrustumCulledNodes()
+{
+	return mNumFrustumCulledNodes;
+}
+//-----------------------------------------------------------------------
+unsigned int CullingManager::GetNumQueryCulledNodes()
+{
+	return mNumQueryCulledNodes;
+}
 } // namespace GtpVisibility
Index: trunk/VUT/GtpVisibility/src/DummyPreprocessingManager.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/DummyPreprocessingManager.cpp	(revision 65)
+++ trunk/VUT/GtpVisibility/src/DummyPreprocessingManager.cpp	(revision 74)
@@ -3,5 +3,5 @@
 namespace GtpVisibility {
 
-DummyPreprocessingManager::DummyPreprocessingManager( HierarchyInterface *hierarchyInterface )
+DummyPreprocessingManager::DummyPreprocessingManager(HierarchyInterface *hierarchyInterface)
   :PreprocessingManager(hierarchyInterface)
 {
@@ -9,6 +9,5 @@
   
 
-bool
-DummyPreprocessingManager::ExportScene(const string filename)
+bool DummyPreprocessingManager::ExportScene(const string filename)
 {
   ofstream s(filename.c_str());
@@ -19,6 +18,5 @@
   
 
-bool
-DummyPreprocessingManager::LoadPreprocessedData(const string filename)
+bool DummyPreprocessingManager::LoadPreprocessedData(const string filename)
 {
   // do nothing
@@ -31,9 +29,7 @@
       Returns false if no viewcell was found.
     */
-bool
-DummyPreprocessingManager::LocateViewCellIds(const Vector3 &center,
-					     const float radius,
-					     vector<int> *viewCellIds
-					     )
+bool DummyPreprocessingManager::LocateViewCellIds(const Vector3 &center,
+												  const float radius,
+												  vector<int> *viewCellIds)
 {
   return false;
@@ -43,6 +39,5 @@
     Uses the specified viewcell to find its PVS
 */
-int
-DummyPreprocessingManager::AddViewCellPVS(const int cellID,
+int DummyPreprocessingManager::AddViewCellPVS(const int cellID,
 					  InfoContainer<NodeInfo> *visibleNodes,
 					  InfoContainer<MeshInfo> *visibleMeshes )
Index: trunk/VUT/GtpVisibility/src/VisibilityEnvironment.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/VisibilityEnvironment.cpp	(revision 59)
+++ trunk/VUT/GtpVisibility/src/VisibilityEnvironment.cpp	(revision 74)
@@ -2,9 +2,9 @@
 
 namespace GtpVisibility {
-
+//-----------------------------------------------------------------------
 VisibilityEnvironment::VisibilityEnvironment()
 {
 }
-	
+//-----------------------------------------------------------------------
 void VisibilityEnvironment::LoadEnvironment()
 {
