Index: /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 345)
+++ /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 346)
@@ -25,5 +25,5 @@
 	unsigned int visiblePixels = 0;
 	bool isAvailable = false;
-	Ogre::LogManager::getSingleton().logMessage("Coherent Hierarchical Culling\n");
+	//Ogre::LogManager::getSingleton().logMessage("Coherent Hierarchical Culling");
 
 	//-- PART 1: process finished occlusion queries
@@ -37,7 +37,4 @@
 			
 			queryQueue.pop();
-
-			std::stringstream d2; d2 << "fetch node from query queue " << node;
-			Ogre::LogManager::getSingleton().logMessage(d2.str());
 
 			if (visiblePixels > mVisibilityThreshold)
@@ -63,7 +60,4 @@
 			mHierarchyInterface->GetQueue()->pop();
 				
-			std::stringstream d2; d2 << "fetch node from hierarchy queue " << node;
-			Ogre::LogManager::getSingleton().logMessage(d2.str());
-
 			bool intersects = false;
 
@@ -87,11 +81,5 @@
 				bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 
 					(mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1);
-				if (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId())
-				{
-				std::stringstream d2; d2 << "!!!!lastVisited: " << mHierarchyInterface->LastVisited(node) << " " << node;
-				Ogre::LogManager::getSingleton().logMessage(d2.str());
-				std::stringstream d; d << "!!!!!frameid: " << mHierarchyInterface->GetFrameId() << " " << node << "\n";
-				Ogre::LogManager::getSingleton().logMessage(d.str());
-				}
+				
 				// if we assume node to be visible in this frame => skip query 
 				// TODO: check this (not the expected speed up)
@@ -105,4 +93,6 @@
                 // identify nodes that we cannot skip queries for
 				// geometry not only in leaves => test for renderable geometry
+				// we also need to test if node was processed in current frame, otherwise
+				// node is tested several times because of priority queue
 				bool issueQuery = (mHierarchyInterface->LastVisited(node) != mHierarchyInterface->GetFrameId())
 						&& (!wasVisible || mHierarchyInterface->HasGeometry(node));
@@ -113,7 +103,4 @@
 				// update node's visited flag
 				mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
-
-				std::stringstream d2; d2 << "lastVisited: " << mHierarchyInterface->LastVisited(node) << " " << node;
-				Ogre::LogManager::getSingleton().logMessage(d2.str());
 
 				// skip testing previously visible nodes without geometry
@@ -129,6 +116,4 @@
 				if (wasVisible)
 				{
-						std::stringstream d2; d2 << "traversing node " << node;
-					Ogre::LogManager::getSingleton().logMessage(d2.str());
 					mHierarchyInterface->TraverseNode(node);
 				}
@@ -162,9 +147,6 @@
 {
 	// -- set node to be visible in this frame, then traverse it
-	std::stringstream d2; d2 << "skipping node " << node;
-					Ogre::LogManager::getSingleton().logMessage(d2.str());
 	mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
 	
-	mHierarchyInterface->SetNodeVisible(node, true);
 	mHierarchyInterface->PullUpVisibility(node);			
 	mHierarchyInterface->TraverseNode(node);
Index: /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 345)
+++ /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 346)
@@ -19,10 +19,4 @@
 		bool intersects = false;
 	
-		//if (mHierarchyInterface->HasGeometry(node) && (!mHierarchyInterface->IsLeaf(node))) ++ mNumFrustumCulledNodes;
-				//	Ogre::LogManager::getSingleton().logMessage("no geometry");
-			//else if (!mHierarchyInterface->IsLeaf(node)) ++ mNumQueriesIssued;//	Ogre::LogManager::getSingleton().logMessage("has geometry");
-/*if (!mHierarchyInterface->HasGeometry(node))
-					Ogre::LogManager::getSingleton().logMessage("no geometry");
-				else 	Ogre::LogManager::getSingleton().logMessage("has geometry");*/
 		if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
 		{
Index: /trunk/VUT/chcdemo/RenderTraverser.cpp
===================================================================
--- /trunk/VUT/chcdemo/RenderTraverser.cpp	(revision 345)
+++ /trunk/VUT/chcdemo/RenderTraverser.cpp	(revision 346)
@@ -182,5 +182,5 @@
 					// update node's visited flag
 					node->SetLastVisited(mFrameID);
-
+					node->SetVisible(true);
 					PullUpVisibility(node);
 					TraverseNode(node);
@@ -192,5 +192,5 @@
 					
 					// identify nodes that we cannot skip queries for
-					bool leafOrWasInvisible = !wasVisible || node->IsLeaf();
+					bool leafOrWasInvisible = (node->LastVisited() != mFrameID) && (!wasVisible || node->IsLeaf());
 
 					// reset node's visibility classification 
@@ -199,5 +199,5 @@
 					// update node's visited flag
 					node->SetLastVisited(mFrameID);
-					//if (mFrameID == node->LastVisited()) mNumFrustumCulledNodes ++;
+					
 					// skip testing previously visible interior nodes
 					if(leafOrWasInvisible)
@@ -215,5 +215,5 @@
 			{
 				// for stats
-				//mNumFrustumCulledNodes ++;
+				mNumFrustumCulledNodes ++;
 			}
 		}
@@ -331,5 +331,5 @@
 	// get next available test id
 	unsigned int occlusionQuery = mOcclusionQueries[mCurrentTestIdx++];
-	mNumFrustumCulledNodes ++;
+	
 	node->SetOcclusionQuery(occlusionQuery);
 	// do the actual occlusion query for this node
Index: /trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
===================================================================
--- /trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 345)
+++ /trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 346)
@@ -52,5 +52,5 @@
 	0.03,
 	//0.1,
-	0.04
+	0.03
 };
 
@@ -423,5 +423,5 @@
 
 		// clamp camera so we always walk along the terrain
-		mApplication->Clamp2Terrain(mCamNode, 10);
+		mApplication->Clamp2Terrain(mCamNode, 5);
 		break;
 
Index: /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 345)
+++ /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 346)
@@ -297,16 +297,16 @@
 
 	mTerrainMinPos = EntityState::msMinPos = Vector3(0, 0, 0);
-	mTerrainMaxPos = EntityState::msMaxPos = Vector3(3000, 5000, 3000);
+	mTerrainMaxPos = EntityState::msMaxPos = Vector3(5000, 5000, 5000);
 
 	mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr);
 	
 	// if no objects in file, we generate new objects
-	//if (!mTerrainContentGenerator->LoadObjects("objects.out"))
-	//{
+	if (!mTerrainContentGenerator->LoadObjects("objects.out"))
+	{
 		// the objects are generated randomly distributed over the terrain
-		generateScene(900, 0); // create soldiers, trees, ninjas
-		generateScene(500, 1);
-		generateScene(100, 2);
-	//}
+		generateScene(1000, 0); // create soldiers, trees, ninjas
+		generateScene(1000, 1);
+		generateScene(200, 2);
+	}
 
 	// no limitations on height => it is possible for the user to put single 
@@ -319,9 +319,9 @@
 	float val = TerrainFrameListener::msObjectScales[objectType];
 	Vector3 scale(val, val, val); 
-
+	const float maxHeight = 100;
 	// to provide much occlusion,
 	// height is restricted to 50 => no objects are created on peaks
 	mTerrainContentGenerator->SetMinPos(Vector3(mTerrainMinPos));
-	mTerrainContentGenerator->SetMaxPos(Vector3(mTerrainMaxPos.x, 75.0f, mTerrainMaxPos.z));
+	mTerrainContentGenerator->SetMaxPos(Vector3(mTerrainMaxPos.x, maxHeight, mTerrainMaxPos.z));
 	std::stringstream d; d << "objscale: " << scale[0];
 	Ogre::LogManager::getSingleton().logMessage(d.str());
Index: /trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp	(revision 345)
+++ /trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp	(revision 346)
@@ -36,6 +36,4 @@
 			if (nextChild)
 			{
-					std::stringstream d2; d2 << "pushing node " << nextChild;
-					Ogre::LogManager::getSingleton().logMessage(d2.str());
 				mDistanceQueue->push(nextChild);
 			}
Index: /trunk/VUT/Ogre/resources/terrain.cfg
===================================================================
--- /trunk/VUT/Ogre/resources/terrain.cfg	(revision 192)
+++ /trunk/VUT/Ogre/resources/terrain.cfg	(revision 346)
@@ -26,5 +26,5 @@
 
 # How large is each tile? Must be (2^n)+1 and be smaller than PageSize
-TileSize=65
+TileSize=129
 
 # The maximum error allowed when determining which LOD to use
@@ -32,8 +32,8 @@
 
 # The size of a terrain page, in world units
-PageWorldX=3000
-PageWorldZ=3000
+PageWorldX=5000
+PageWorldZ=5000
 # Maximum height of the terrain 
-MaxHeight=300
+MaxHeight=500
 
 # Upper LOD limit
