Index: trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingOctreeSceneManager.h
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingOctreeSceneManager.h	(revision 44)
+++ trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingOctreeSceneManager.h	(revision 45)
@@ -10,5 +10,5 @@
 
 #include "OgrePrerequisites.h"
-#include "OgreOcclusionCullingTerrainSceneTraverser.h"
+#include "OgreOcclusionCullingOctreeSceneTraverser.h"
 //#include "OgreSolidHalfBoundingBox.h"
 
Index: trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingOctreeSceneTraverser.h
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingOctreeSceneTraverser.h	(revision 45)
+++ trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingOctreeSceneTraverser.h	(revision 45)
@@ -0,0 +1,90 @@
+#ifndef _OcclusionCullingOctreeSceneTraverser_H__
+#define _OcclusionCullingOctreeSceneTraverser_H__
+
+#include "OgreOctree.h"
+#include "OgreOcclusionCullingSceneTraverser.h"
+
+using namespace std;
+
+namespace Ogre {
+	/**
+		This class implements the compare operator for the priority queue
+		especially for octree hierarchies using getCullBounds for bounding
+		box computation. A lower distance has a higher value in the queue.
+	*/
+	template <typename T> class octreeless 
+	{
+	public:
+		octreeless(Camera *cam) { mCamera = cam; }
+		
+		bool operator() (T v1, T v2) const
+		{
+			AxisAlignedBox box1, box2;
+			v1->_getCullBounds(&box1);
+			v2->_getCullBounds(&box2);
+
+			return getSquaredViewDepth(mCamera, &box1) > getSquaredViewDepth(mCamera, &box2);
+		}
+
+	private:
+		Real getSquaredViewDepth(const Ogre::Camera* cam, const Ogre::AxisAlignedBox* box) const
+		{
+			Vector3 mid  = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum();
+			return (cam->getDerivedPosition() - mid).squaredLength();                                                                   
+		}
+
+		Camera *mCamera;
+		//AxisAlignedBox mBox1, mBox2;
+		//Ogre::Vector3 min, max, mid, dist;
+	};
+
+	typedef pair<Octree *, HardwareOcclusionQuery *> OctreeQueryPair;
+	typedef priority_queue<Octree *, vector<Octree *>, octreeless<vector<Octree *>::value_type> > OctreePriorityQueue;
+	typedef queue<OctreeQueryPair> OctreeQueryQueue;
+
+	class OcclusionCullingOctreeSceneTraverser: public OcclusionCullingSceneTraverser
+	{
+	public:
+		OcclusionCullingOctreeSceneTraverser(SceneManager *sm, RenderSystem *rsys);
+		~OcclusionCullingOctreeSceneTraverser();
+		//void renderScene( Camera *cam );
+		void setSceneRoot(Octree *root);
+		/** Sets the number of nodes in this octree 
+		@remark do not confuse this with the OctreeNode class 
+		which is derived from SceneNode
+		@param num number of nodes in the octree
+		*/
+		void setNumOctreeNodes( unsigned int num );
+	
+		/** Gets the given option for the scene traverser.
+	        @remarks
+		    See setOption
+		*/
+		bool getOption( const String &, void * );
+		bool getOptionKeys( StringVector &refKeys );
+		
+	protected:
+		/** Renders the scene with view frustum culling only. */
+		void renderCullFrustum( Camera *cam );
+		/** Renders the scene with the hierarchical stop and wait algorithm. */
+		void renderStopAndWait( Camera *cam );
+		/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
+		void renderCoherentWithQueue( Camera *cam );
+		/** Issue a occlusion query for this node. */
+		
+		void initDistanceQueue(Camera *cam);
+		void pullUpVisibility( Camera *cam, Octree *octree );
+		void traverseOctant(Camera *cam, Octree *octant );
+		void renderOctant( Camera *cam, Octree *octant );
+		bool isLeaf(Octree *octant);
+
+	private:
+		OctreePriorityQueue *mOctreeDistanceQueue;
+		// the octree root
+		Octree *mOctreeSceneRoot;
+
+		unsigned int mNumOctreeNodes;
+	};
+
+}
+#endif // OcclusionCullingOctreeSceneTraverser_H
Index: trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h	(revision 42)
+++ trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h	(revision 45)
@@ -10,5 +10,5 @@
 
 #include "OgrePrerequisites.h"
-#include "OgreOcclusionCullingTerrainSceneTraverser.h"
+#include "OgreOcclusionCullinOctreeSceneTraverser.h"
 //#include "OgreSolidHalfBoundingBox.h"
 
@@ -55,10 +55,6 @@
 
 	protected:
-		/** Recursively counts octree size (i.e., number of octree instances)
-		@param root current octree
-		*/
-		//unsigned int countOctreeSize(Octree *root);
 
-		OcclusionCullingTerrainSceneTraverser *mOcclusionCullingTerrainSceneTraverser;
+		OcclusionCullingOctreeSceneTraverser *mOcclusionCullingOctreeSceneTraverser;
 	};
 
Index: trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneTraverser.h
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneTraverser.h	(revision 42)
+++ 	(revision )
@@ -1,90 +1,0 @@
-#ifndef _OcclusionCullingTerrainSceneTraverser_H__
-#define _OcclusionCullingTerrainSceneTraverser_H__
-
-#include "OgreOctree.h"
-#include "OgreOcclusionCullingSceneTraverser.h"
-
-using namespace std;
-
-namespace Ogre {
-	/**
-		This class implements the compare operator for the priority queue
-		especially for octree hierarchies using getCullBounds for bounding
-		box computation. A lower distance has a higher value in the queue.
-	*/
-	template <typename T> class octreeless 
-	{
-	public:
-		octreeless(Camera *cam) { mCamera = cam; }
-		
-		bool operator() (T v1, T v2) const
-		{
-			AxisAlignedBox box1, box2;
-			v1->_getCullBounds(&box1);
-			v2->_getCullBounds(&box2);
-
-			return getSquaredViewDepth(mCamera, &box1) > getSquaredViewDepth(mCamera, &box2);
-		}
-
-	private:
-		Real getSquaredViewDepth(const Ogre::Camera* cam, const Ogre::AxisAlignedBox* box) const
-		{
-			Vector3 mid  = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum();
-			return (cam->getDerivedPosition() - mid).squaredLength();                                                                   
-		}
-
-		Camera *mCamera;
-		//AxisAlignedBox mBox1, mBox2;
-		//Ogre::Vector3 min, max, mid, dist;
-	};
-
-	typedef pair<Octree *, HardwareOcclusionQuery *> OctreeQueryPair;
-	typedef priority_queue<Octree *, vector<Octree *>, octreeless<vector<Octree *>::value_type> > OctreePriorityQueue;
-	typedef queue<OctreeQueryPair> OctreeQueryQueue;
-
-	class OcclusionCullingTerrainSceneTraverser: public OcclusionCullingSceneTraverser
-	{
-	public:
-		OcclusionCullingTerrainSceneTraverser(SceneManager *sm, RenderSystem *rsys);
-		~OcclusionCullingTerrainSceneTraverser();
-		//void renderScene( Camera *cam );
-		void setSceneRoot(Octree *root);
-		/** Sets the number of nodes in this octree 
-		@remark do not confuse this with the OctreeNode class 
-		which is derived from SceneNode
-		@param num number of nodes in the octree
-		*/
-		void setNumOctreeNodes( unsigned int num );
-	
-		/** Gets the given option for the scene traverser.
-	        @remarks
-		    See setOption
-		*/
-		bool getOption( const String &, void * );
-		bool getOptionKeys( StringVector &refKeys );
-		
-	protected:
-		/** Renders the scene with view frustum culling only. */
-		void renderCullFrustum( Camera *cam );
-		/** Renders the scene with the hierarchical stop and wait algorithm. */
-		void renderStopAndWait( Camera *cam );
-		/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
-		void renderCoherentWithQueue( Camera *cam );
-		/** Issue a occlusion query for this node. */
-		
-		void initDistanceQueue(Camera *cam);
-		void pullUpVisibility( Camera *cam, Octree *octree );
-		void traverseOctant(Camera *cam, Octree *octant );
-		void renderOctant( Camera *cam, Octree *octant );
-		bool isLeaf(Octree *octant);
-
-	private:
-		OctreePriorityQueue *mOctreeDistanceQueue;
-		// the octree root
-		Octree *mOctreeSceneRoot;
-
-		unsigned int mNumOctreeNodes;
-	};
-
-}
-#endif // OcclusionCullingTerrainSceneTraverser_H
Index: trunk/VUT/OcclusionCullingSceneManager/scripts/Plugin_OcclusionCullingSceneManager.vcproj
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/scripts/Plugin_OcclusionCullingSceneManager.vcproj	(revision 40)
+++ trunk/VUT/OcclusionCullingSceneManager/scripts/Plugin_OcclusionCullingSceneManager.vcproj	(revision 45)
@@ -181,5 +181,5 @@
 		</Filter>
 		<Filter
-			Name="TerrainSceneManager"
+			Name="OctreeOcclusionCullingSceneManager"
 			Filter="">
 			<Filter
@@ -187,9 +187,12 @@
 				Filter="">
 				<File
+					RelativePath="..\src\OgreOcclusionCullingOctreeSceneManager.cpp">
+				</File>
+				<File
+					RelativePath="..\src\OgreOcclusionCullingOctreeSceneTraverser.cpp">
+				</File>
+				<File
 					RelativePath="..\src\OgreOcclusionCullingTerrainSceneManager.cpp">
 				</File>
-				<File
-					RelativePath="..\src\OgreOcclusionCullingTerrainSceneTraverser.cpp">
-				</File>
 			</Filter>
 			<Filter
@@ -197,13 +200,16 @@
 				Filter="">
 				<File
+					RelativePath="..\include\OgreOcclusionCullingOctreeSceneManager.h">
+				</File>
+				<File
+					RelativePath="..\include\OgreOcclusionCullingOctreeSceneTraverser.h">
+				</File>
+				<File
 					RelativePath="..\include\OgreOcclusionCullingTerrainSceneManager.h">
 				</File>
-				<File
-					RelativePath="..\include\OgreOcclusionCullingTerrainSceneTraverser.h">
-				</File>
-			</Filter>
-		</Filter>
-		<Filter
-			Name="DotSceneManager"
+			</Filter>
+		</Filter>
+		<Filter
+			Name="DotSceneOcclusionCullingSceneManager"
 			Filter="">
 			<Filter
Index: trunk/VUT/OcclusionCullingSceneManager/scripts/Plugin_OcclusionCullingSceneManager.sln
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/scripts/Plugin_OcclusionCullingSceneManager.sln	(revision 37)
+++ trunk/VUT/OcclusionCullingSceneManager/scripts/Plugin_OcclusionCullingSceneManager.sln	(revision 45)
@@ -11,4 +11,8 @@
 	ProjectSection(ProjectDependencies) = postProject
 		{80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCullingTerrain", "..\TestCullingTerrain\TestCullingTerrain.vcproj", "{248F19A6-2FE0-4F5D-8928-E0EA10609887}"
+	ProjectSection(ProjectDependencies) = postProject
 	EndProjectSection
 EndProject
@@ -31,4 +35,8 @@
 		{BE13944C-D05E-467F-B0AC-8A65A3B5FE60}.Release.ActiveCfg = Release|Win32
 		{BE13944C-D05E-467F-B0AC-8A65A3B5FE60}.Release.Build.0 = Release|Win32
+		{248F19A6-2FE0-4F5D-8928-E0EA10609887}.Debug.ActiveCfg = Debug|Win32
+		{248F19A6-2FE0-4F5D-8928-E0EA10609887}.Debug.Build.0 = Debug|Win32
+		{248F19A6-2FE0-4F5D-8928-E0EA10609887}.Release.ActiveCfg = Release|Win32
+		{248F19A6-2FE0-4F5D-8928-E0EA10609887}.Release.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
Index: trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManagerDll.cpp
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManagerDll.cpp	(revision 37)
+++ trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManagerDll.cpp	(revision 45)
@@ -34,5 +34,6 @@
 namespace Ogre {
 
-    OcclusionCullingDotSceneManager *occlusionPlugin;
+   // OcclusionCullingDotSceneManager *occlusionDotPlugin;
+	OcclusionCullingOctreeSceneManager *occlusionOctreePlugin;
 	OcclusionCullingTerrainSceneManager *occlusionTerrainPlugin;
 	HeightmapTerrainPageSource* heightmapTerrainPageSource;
@@ -42,5 +43,6 @@
     {
 		// Create new scene manager
-		occlusionPlugin = new OcclusionCullingDotSceneManager();
+		//occlusionDotPlugin = new OcclusionCullingDotSceneManager();
+		occlusionOctreePlugin = new OcclusionCullingOctreeSceneManager();
 		occlusionTerrainPlugin = new OcclusionCullingTerrainSceneManager();
 		heightmapTerrainPageSource = new HeightmapTerrainPageSource();
@@ -49,5 +51,6 @@
 
 	    // Register
-		Root::getSingleton().setSceneManager( ST_GENERIC, occlusionPlugin );
+		//Root::getSingleton().setSceneManager( ST_GENERIC, occlusionDotPlugin );
+		Root::getSingleton().setSceneManager( ST_GENERIC, occlusionOctreePlugin );
 		Root::getSingleton().setSceneManager( ST_EXTERIOR_CLOSE, occlusionTerrainPlugin );
 		
@@ -57,5 +60,6 @@
     {
 		delete heightmapTerrainPageSource;
-        delete occlusionPlugin;
+        //delete occlusionDotPlugin;
+		delete occlusionOctreePlugin;
 		delete occlusionTerrainPlugin;
     }
Index: trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneManager.cpp
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneManager.cpp	(revision 44)
+++ trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneManager.cpp	(revision 45)
@@ -1,9 +1,7 @@
-#include "OgreOcclusionCullingTerrainSceneManager.h"
+#include "OgreOcclusionCullingOctreeSceneManager.h"
 #include "OgreMath.h"
 #include "OgreIteratorWrappers.h"
 #include "OgreRenderSystem.h"
 #include "OgreCamera.h"
-#include "OgreHardwareOcclusionQuery.h"
-#include "OgreSolidHalfBoundingBox.h"
 
 #include <windows.h>
@@ -11,8 +9,8 @@
 namespace Ogre {
 	//-----------------------------------------------------------------------
-	OcclusionCullingTerrainSceneManager::OcclusionCullingTerrainSceneManager()
+	OcclusionCullingOctreeSceneManager::OcclusionCullingOctreeSceneManager()
 	{
-		mOcclusionCullingTerrainSceneTraverser = 
-			new OcclusionCullingTerrainSceneTraverser(this, mDestRenderSystem);
+		mOcclusionCullingOctreeSceneTraverser = 
+			new OcclusionCullingOctreeSceneTraverser(this, mDestRenderSystem);
 
 		//mDisplayNodes = true;
@@ -22,10 +20,10 @@
 	}
 	//-----------------------------------------------------------------------
-	OcclusionCullingTerrainSceneManager::~OcclusionCullingTerrainSceneManager()
+	OcclusionCullingOctreeSceneManager::~OcclusionCullingOctreeSceneManager()
 	{
-		delete mOcclusionCullingTerrainSceneTraverser;
+		delete mOcclusionCullingOctreeSceneTraverser;
 	}
 	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneManager::_renderVisibleObjects(void)
+	void OcclusionCullingOctreeSceneManager::_renderVisibleObjects(void)
 	{
 		//-- render background
@@ -43,6 +41,6 @@
 		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
 
-		mOcclusionCullingTerrainSceneTraverser->setSceneRoot(mOctree);
-		mOcclusionCullingTerrainSceneTraverser->renderScene(mCameraInProgress);
+		mOcclusionCullingOctreeSceneTraverser->setSceneRoot(mOctree);
+		mOcclusionCullingOctreeSceneTraverser->renderScene(mCameraInProgress);
 		
 		_deleteRenderedQueueGroups();
@@ -55,5 +53,5 @@
 	}
 	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
+	void OcclusionCullingOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
 	{
 		// must be empty because objects are found and rendered in an interleaved fashion
@@ -62,38 +60,38 @@
 	}
 	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneManager::_updateSceneGraph(Camera* cam)
+	void OcclusionCullingOctreeSceneManager::_updateSceneGraph(Camera* cam)
 	{
 		//char *msg = "now updating scenegraph\n"; OutputDebugString(msg);
-		//mOcclusionCullingTerrainSceneTraverser->preprocess();
+		//mOcclusionCullingOctreeSceneTraverser->preprocess();
 
-     	mOcclusionCullingTerrainSceneTraverser->setNumSceneNodes((int)mSceneNodes.size());
-		mOcclusionCullingTerrainSceneTraverser->setRenderSystem(mDestRenderSystem);
+     	mOcclusionCullingOctreeSceneTraverser->setNumSceneNodes((int)mSceneNodes.size());
+		mOcclusionCullingOctreeSceneTraverser->setRenderSystem(mDestRenderSystem);
         
-		mOcclusionCullingTerrainSceneTraverser->setNumOctreeNodes(mNumOctreeNodes);
+		mOcclusionCullingOctreeSceneTraverser->setNumOctreeNodes(mNumOctreeNodes);
 
-		TerrainSceneManager::_updateSceneGraph(cam);
+		OctreeSceneManager::_updateSceneGraph(cam);
 	}
 	//-----------------------------------------------------------------------
-	bool OcclusionCullingTerrainSceneManager::setOption( const String & key, const void * val )
+	bool OcclusionCullingOctreeSceneManager::setOption( const String & key, const void * val )
 	{
-		return mOcclusionCullingTerrainSceneTraverser->setOption( key, val) || TerrainSceneManager::setOption( key, val );
+		return mOcclusionCullingOctreeSceneTraverser->setOption( key, val) || OctreeSceneManager::setOption( key, val );
 	}
 	//-----------------------------------------------------------------------
-	bool OcclusionCullingTerrainSceneManager::getOption( const String & key, void *val )
+	bool OcclusionCullingOctreeSceneManager::getOption( const String & key, void *val )
 	{
-		return mOcclusionCullingTerrainSceneTraverser->getOption( key, val) || TerrainSceneManager::getOption( key, val ) ;
+		return mOcclusionCullingOctreeSceneTraverser->getOption( key, val) || OctreeSceneManager::getOption( key, val ) ;
 	}
 	//-----------------------------------------------------------------------
-	bool OcclusionCullingTerrainSceneManager::getOptionValues( const String & key, StringVector  &refValueList )
+	bool OcclusionCullingOctreeSceneManager::getOptionValues( const String & key, StringVector  &refValueList )
 	{
-		return TerrainSceneManager::getOptionValues( key, refValueList );
+		return OctreeSceneManager::getOptionValues( key, refValueList );
 	}
 	//-----------------------------------------------------------------------
-	bool OcclusionCullingTerrainSceneManager::getOptionKeys( StringVector & refKeys )
+	bool OcclusionCullingOctreeSceneManager::getOptionKeys( StringVector & refKeys )
 	{
-		return mOcclusionCullingTerrainSceneTraverser->getOptionKeys ( refKeys ) || TerrainSceneManager::getOptionKeys( refKeys );
+		return mOcclusionCullingOctreeSceneTraverser->getOptionKeys ( refKeys ) || OctreeSceneManager::getOptionKeys( refKeys );
 	}
 	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneManager::_renderOctant(Camera *cam, Octree *octant)
+	void OcclusionCullingOctreeSceneManager::_renderOctant(Camera *cam, Octree *octant)
 	{
 		//Add stuff to be rendered;
@@ -131,18 +129,3 @@
 		_deleteRenderedQueueGroups();
 	}
-	//-----------------------------------------------------------------------
-	/*unsigned int OcclusionCullingTerrainSceneManager::countNumOctrees(Octree *root)
-	{
-		unsigned int result = 1;
-				
-		for(int i=0; i<8; ++i)
-		{
-			Octree *nextChild = root->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1];
-		
-			if(nextChild != 0)
-				result += countNumOctrees(nextChild);
-		}
-		
-		return result;
-	}*/
 }	
Index: trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneTraverser.cpp
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneTraverser.cpp	(revision 45)
+++ trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneTraverser.cpp	(revision 45)
@@ -0,0 +1,278 @@
+#include "OgreOcclusionCullingOctreeSceneTraverser.h"
+#include "OgreOcclusionCullingTerrainSceneManager.h"
+#include "OgreHardwareOcclusionQuery.h"
+
+#include <windows.h>
+
+namespace Ogre {
+	//-----------------------------------------------------------------------
+	OcclusionCullingTerrainSceneTraverser::OcclusionCullingTerrainSceneTraverser(SceneManager *sm, RenderSystem *rsys): 
+	OcclusionCullingSceneTraverser(sm, rsys), mOctreeSceneRoot(0), mOctreeDistanceQueue(0)
+	{
+	}
+	//-----------------------------------------------------------------------
+	OcclusionCullingTerrainSceneTraverser::~OcclusionCullingTerrainSceneTraverser()
+	{		
+		if(mOctreeDistanceQueue)
+			delete mOctreeDistanceQueue;
+	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::traverseOctant(Camera *cam, Octree *octant )
+	{
+		mNumTraversedNodes ++;
+	
+		// if we come across some renderable geometry => render it
+		renderOctant(cam, octant);
+		
+		for(int i=0; i<8; i++)
+		{
+			Octree *nextChild = octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1];
+		
+			if(nextChild)
+				mOctreeDistanceQueue->push(nextChild);
+		}
+	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::renderCullFrustum(Camera *cam)
+	{
+		AxisAlignedBox box;
+
+		while(!mOctreeDistanceQueue->empty())
+		{
+			Octree *octant = mOctreeDistanceQueue->top();
+			mOctreeDistanceQueue->pop();
+	
+			// interesting for visualization purpose
+			//TODO: octree->setNodeVisible(false);
+			octant->_getCullBounds(&box);
+			
+			//if(static_cast<OctreeCamera *>(cam)->getVisibility(box) == OctreeCamera::NONE)
+			if(!cam->isVisible(box))
+			{
+				mNumFrustumCulledNodes ++;
+				continue;
+			}
+
+			// update node's visited flag 
+			octant->setLastVisited(mFrameId);
+			octant->setOctreeVisible(true);
+		
+			traverseOctant(cam, octant);
+		}
+	}	
+	//-----------------------------------------------------------------------
+	/** Renders the scene with the hierarchical stop and wait algorithm. */
+	void OcclusionCullingTerrainSceneTraverser::renderStopAndWait( Camera *cam )
+	{
+		AxisAlignedBox box;
+
+		while(!mOctreeDistanceQueue->empty())
+		{
+			Octree *octant = mOctreeDistanceQueue->top();
+			mOctreeDistanceQueue->pop();
+		
+			// interesting for visualization purpose
+			octant->setOctreeVisible(false);
+			octant->setLastVisited(mFrameId);
+
+			//TODO: Isvisible also checked inside scenenode::findvisibleobjects
+			octant->_getCullBounds(&box);
+
+			bool intersects = false;
+
+			//if(vis == OctreeCamera::NONE)
+			if(!cam->isVisible(box, intersects))
+			{
+				mNumFrustumCulledNodes ++;
+				continue;
+			}
+			//if intersects near plane => skip occlusion query because wrong results possible
+			if(intersects)
+			{
+				octant->setOctreeVisible(true);
+				traverseOctant(cam, octant);
+				continue;
+			}
+
+			HardwareOcclusionQuery *query = issueOcclusionQuery(&box, false);
+				
+			unsigned int visiblePixels;
+			// wait if result not available
+			query->pullOcclusionQuery(&visiblePixels);
+			
+			// node visible
+			if(visiblePixels > mVisibilityThreshold)
+			{
+				traverseOctant(cam, octant);
+			}
+			else
+			{
+				mNumQueryCulledNodes ++;
+			}
+		}
+	}
+	//-----------------------------------------------------------------------
+	/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
+	void OcclusionCullingTerrainSceneTraverser::renderCoherentWithQueue( Camera *cam )
+	{
+		OctreeQueryQueue queryQueue;
+		AxisAlignedBox box;
+
+		//-- PART 1: process finished occlusion queries
+		while(!mOctreeDistanceQueue->empty() || !queryQueue.empty())
+		{
+			while(!queryQueue.empty() && 
+				  ((queryQueue.front().second)->resultAvailable() || mOctreeDistanceQueue->empty()))
+			{
+				Octree *octant = queryQueue.front().first;
+				HardwareOcclusionQuery *query = queryQueue.front().second;
+
+				queryQueue.pop();
+			
+				// wait until result available
+				unsigned int visiblePixels;
+				query->pullOcclusionQuery(&visiblePixels);
+
+				if(visiblePixels > mVisibilityThreshold)
+				{
+					pullUpVisibility(cam, octant);
+					traverseOctant(cam, octant);
+				}
+				else
+				{
+					mNumQueryCulledNodes ++;
+				}
+			}	
+
+			//-- PART 2: hierarchical traversal
+			if(!mOctreeDistanceQueue->empty())
+			{
+				Octree *octant = mOctreeDistanceQueue->top();
+				mOctreeDistanceQueue->pop();
+					
+				octant->_getCullBounds(&box);
+
+				bool intersects = false;
+				//TODO: Isvisible also checked inside scenenode::findvisibleobjects
+				if(!cam->isVisible(box, intersects))
+				{
+                    mNumFrustumCulledNodes ++;
+					continue;
+				}
+
+				// if intersects near plane => skip occlusion query because wrong results possible
+				if(intersects)
+				{
+					// update node's visited flag
+					octant->setLastVisited(mFrameId);
+					pullUpVisibility(cam, octant);			
+					traverseOctant(cam, octant);
+
+					continue;
+				}
+
+				// identify previously visible nodes
+				bool wasVisible = octant->isOctreeVisible() && (octant->lastVisited() == mFrameId - 1);
+					
+				// identify nodes that we cannot skip queries for
+				bool leafOrWasInvisible = !wasVisible || isLeaf(octant);
+
+				// reset node's visibility classification 
+				octant->setOctreeVisible(false);
+
+				// update node's visited flag
+				octant->setLastVisited(mFrameId);
+			
+				// skip testing previously visible interior nodes
+				if(leafOrWasInvisible)
+				{
+					HardwareOcclusionQuery *query = issueOcclusionQuery(&box, wasVisible);
+					queryQueue.push(OctreeQueryPair(octant, query));
+				}
+					
+				// always traverse a node if it was visible
+				if(wasVisible)
+				{
+					traverseOctant(cam, octant);
+				}
+				else
+				{
+					mNumFrustumCulledNodes ++;
+				}
+			}
+		}
+	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::pullUpVisibility( Camera *cam, Octree *octant )
+	{
+		while(octant && !octant->isOctreeVisible())
+		{
+			// if we come across some renderable geometry => render it
+			renderOctant(cam, octant);
+			
+			octant->setOctreeVisible(true);
+			octant = octant->getParent();
+		}
+	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::renderOctant( Camera *cam, Octree *octant )
+	{
+		//if(octant->numNodes() > 0)
+		if(octant->lastVisited() != octant->lastRendered())
+		{
+			//setRenderingMode(MODE_RENDER);
+
+			octant->setLastRendered(octant->lastVisited());
+			((OcclusionCullingTerrainSceneManager *)mSceneManager)->_renderOctant(cam, octant);
+		}
+		else OutputDebugString("already rendered");
+	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::setSceneRoot(Octree *root)
+	{
+		mOctreeSceneRoot = root;
+	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::initDistanceQueue(Camera *cam)
+	{
+		if(mOctreeDistanceQueue)
+			delete mOctreeDistanceQueue;
+
+		mOctreeDistanceQueue = new OctreePriorityQueue(octreeless<Octree *>(cam));
+		mOctreeDistanceQueue->push(mOctreeSceneRoot);
+	}
+	//-----------------------------------------------------------------------
+	bool OcclusionCullingTerrainSceneTraverser::isLeaf(Octree *octant)
+	{
+		for(int i=0; i<8; i++)
+		{
+			if(octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1])
+				return false;
+		}
+
+		return true;
+	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingTerrainSceneTraverser::setNumOctreeNodes(unsigned int num)
+	{
+		mNumOctreeNodes = num;
+	}
+	//-----------------------------------------------------------------------
+	bool OcclusionCullingTerrainSceneTraverser::getOption( const String & key, void *val )
+	{
+		if ( key == "NumOctreeNodes" )
+		{
+			* static_cast < unsigned int * > ( val ) = mNumOctreeNodes;
+			return true;
+		}
+
+		return OcclusionCullingSceneTraverser::getOption(key, val);
+	}
+	//-----------------------------------------------------------------------
+	bool OcclusionCullingTerrainSceneTraverser::getOptionKeys( StringVector & refKeys )
+	{
+		refKeys.push_back( "NumOctreeNodes" );
+		
+		return OcclusionCullingSceneTraverser::getOptionKeys(refKeys);		
+	}
+}	
Index: trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp	(revision 44)
+++ 	(revision )
@@ -1,278 +1,0 @@
-#include "OgreOcclusionCullingTerrainSceneTraverser.h"
-#include "OgreOcclusionCullingTerrainSceneManager.h"
-#include "OgreHardwareOcclusionQuery.h"
-
-#include <windows.h>
-
-namespace Ogre {
-	//-----------------------------------------------------------------------
-	OcclusionCullingTerrainSceneTraverser::OcclusionCullingTerrainSceneTraverser(SceneManager *sm, RenderSystem *rsys): 
-	OcclusionCullingSceneTraverser(sm, rsys), mOctreeSceneRoot(0), mOctreeDistanceQueue(0)
-	{
-	}
-	//-----------------------------------------------------------------------
-	OcclusionCullingTerrainSceneTraverser::~OcclusionCullingTerrainSceneTraverser()
-	{		
-		if(mOctreeDistanceQueue)
-			delete mOctreeDistanceQueue;
-	}
-	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::traverseOctant(Camera *cam, Octree *octant )
-	{
-		mNumTraversedNodes ++;
-	
-		// if we come across some renderable geometry => render it
-		renderOctant(cam, octant);
-		
-		for(int i=0; i<8; i++)
-		{
-			Octree *nextChild = octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1];
-		
-			if(nextChild)
-				mOctreeDistanceQueue->push(nextChild);
-		}
-	}
-	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::renderCullFrustum(Camera *cam)
-	{
-		AxisAlignedBox box;
-
-		while(!mOctreeDistanceQueue->empty())
-		{
-			Octree *octant = mOctreeDistanceQueue->top();
-			mOctreeDistanceQueue->pop();
-	
-			// interesting for visualization purpose
-			//TODO: octree->setNodeVisible(false);
-			octant->_getCullBounds(&box);
-			
-			//if(static_cast<OctreeCamera *>(cam)->getVisibility(box) == OctreeCamera::NONE)
-			if(!cam->isVisible(box))
-			{
-				mNumFrustumCulledNodes ++;
-				continue;
-			}
-
-			// update node's visited flag 
-			octant->setLastVisited(mFrameId);
-			octant->setOctreeVisible(true);
-		
-			traverseOctant(cam, octant);
-		}
-	}	
-	//-----------------------------------------------------------------------
-	/** Renders the scene with the hierarchical stop and wait algorithm. */
-	void OcclusionCullingTerrainSceneTraverser::renderStopAndWait( Camera *cam )
-	{
-		AxisAlignedBox box;
-
-		while(!mOctreeDistanceQueue->empty())
-		{
-			Octree *octant = mOctreeDistanceQueue->top();
-			mOctreeDistanceQueue->pop();
-		
-			// interesting for visualization purpose
-			octant->setOctreeVisible(false);
-			octant->setLastVisited(mFrameId);
-
-			//TODO: Isvisible also checked inside scenenode::findvisibleobjects
-			octant->_getCullBounds(&box);
-
-			bool intersects = false;
-
-			//if(vis == OctreeCamera::NONE)
-			if(!cam->isVisible(box, intersects))
-			{
-				mNumFrustumCulledNodes ++;
-				continue;
-			}
-			//if intersects near plane => skip occlusion query because wrong results possible
-			if(intersects)
-			{
-				octant->setOctreeVisible(true);
-				traverseOctant(cam, octant);
-				continue;
-			}
-
-			HardwareOcclusionQuery *query = issueOcclusionQuery(&box, false);
-				
-			unsigned int visiblePixels;
-			// wait if result not available
-			query->pullOcclusionQuery(&visiblePixels);
-			
-			// node visible
-			if(visiblePixels > mVisibilityThreshold)
-			{
-				traverseOctant(cam, octant);
-			}
-			else
-			{
-				mNumQueryCulledNodes ++;
-			}
-		}
-	}
-	//-----------------------------------------------------------------------
-	/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
-	void OcclusionCullingTerrainSceneTraverser::renderCoherentWithQueue( Camera *cam )
-	{
-		OctreeQueryQueue queryQueue;
-		AxisAlignedBox box;
-
-		//-- PART 1: process finished occlusion queries
-		while(!mOctreeDistanceQueue->empty() || !queryQueue.empty())
-		{
-			while(!queryQueue.empty() && 
-				  ((queryQueue.front().second)->resultAvailable() || mOctreeDistanceQueue->empty()))
-			{
-				Octree *octant = queryQueue.front().first;
-				HardwareOcclusionQuery *query = queryQueue.front().second;
-
-				queryQueue.pop();
-			
-				// wait until result available
-				unsigned int visiblePixels;
-				query->pullOcclusionQuery(&visiblePixels);
-
-				if(visiblePixels > mVisibilityThreshold)
-				{
-					pullUpVisibility(cam, octant);
-					traverseOctant(cam, octant);
-				}
-				else
-				{
-					mNumQueryCulledNodes ++;
-				}
-			}	
-
-			//-- PART 2: hierarchical traversal
-			if(!mOctreeDistanceQueue->empty())
-			{
-				Octree *octant = mOctreeDistanceQueue->top();
-				mOctreeDistanceQueue->pop();
-					
-				octant->_getCullBounds(&box);
-
-				bool intersects = false;
-				//TODO: Isvisible also checked inside scenenode::findvisibleobjects
-				if(!cam->isVisible(box, intersects))
-				{
-                    mNumFrustumCulledNodes ++;
-					continue;
-				}
-
-				// if intersects near plane => skip occlusion query because wrong results possible
-				if(intersects)
-				{
-					// update node's visited flag
-					octant->setLastVisited(mFrameId);
-					pullUpVisibility(cam, octant);			
-					traverseOctant(cam, octant);
-
-					continue;
-				}
-
-				// identify previously visible nodes
-				bool wasVisible = octant->isOctreeVisible() && (octant->lastVisited() == mFrameId - 1);
-					
-				// identify nodes that we cannot skip queries for
-				bool leafOrWasInvisible = !wasVisible || isLeaf(octant);
-
-				// reset node's visibility classification 
-				octant->setOctreeVisible(false);
-
-				// update node's visited flag
-				octant->setLastVisited(mFrameId);
-			
-				// skip testing previously visible interior nodes
-				if(leafOrWasInvisible)
-				{
-					HardwareOcclusionQuery *query = issueOcclusionQuery(&box, wasVisible);
-					queryQueue.push(OctreeQueryPair(octant, query));
-				}
-					
-				// always traverse a node if it was visible
-				if(wasVisible)
-				{
-					traverseOctant(cam, octant);
-				}
-				else
-				{
-					mNumFrustumCulledNodes ++;
-				}
-			}
-		}
-	}
-	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::pullUpVisibility( Camera *cam, Octree *octant )
-	{
-		while(octant && !octant->isOctreeVisible())
-		{
-			// if we come across some renderable geometry => render it
-			renderOctant(cam, octant);
-			
-			octant->setOctreeVisible(true);
-			octant = octant->getParent();
-		}
-	}
-	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::renderOctant( Camera *cam, Octree *octant )
-	{
-		//if(octant->numNodes() > 0)
-		if(octant->lastVisited() != octant->lastRendered())
-		{
-			//setRenderingMode(MODE_RENDER);
-
-			octant->setLastRendered(octant->lastVisited());
-			((OcclusionCullingTerrainSceneManager *)mSceneManager)->_renderOctant(cam, octant);
-		}
-		else OutputDebugString("already rendered");
-	}
-	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::setSceneRoot(Octree *root)
-	{
-		mOctreeSceneRoot = root;
-	}
-	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::initDistanceQueue(Camera *cam)
-	{
-		if(mOctreeDistanceQueue)
-			delete mOctreeDistanceQueue;
-
-		mOctreeDistanceQueue = new OctreePriorityQueue(octreeless<Octree *>(cam));
-		mOctreeDistanceQueue->push(mOctreeSceneRoot);
-	}
-	//-----------------------------------------------------------------------
-	bool OcclusionCullingTerrainSceneTraverser::isLeaf(Octree *octant)
-	{
-		for(int i=0; i<8; i++)
-		{
-			if(octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1])
-				return false;
-		}
-
-		return true;
-	}
-	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::setNumOctreeNodes(unsigned int num)
-	{
-		mNumOctreeNodes = num;
-	}
-	//-----------------------------------------------------------------------
-	bool OcclusionCullingTerrainSceneTraverser::getOption( const String & key, void *val )
-	{
-		if ( key == "NumOctreeNodes" )
-		{
-			* static_cast < unsigned int * > ( val ) = mNumOctreeNodes;
-			return true;
-		}
-
-		return OcclusionCullingSceneTraverser::getOption(key, val);
-	}
-	//-----------------------------------------------------------------------
-	bool OcclusionCullingTerrainSceneTraverser::getOptionKeys( StringVector & refKeys )
-	{
-		refKeys.push_back( "NumOctreeNodes" );
-		
-		return OcclusionCullingSceneTraverser::getOptionKeys(refKeys);		
-	}
-}	
Index: trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCulling.vcproj
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCulling.vcproj	(revision 44)
+++ trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCulling.vcproj	(revision 45)
@@ -122,7 +122,4 @@
 			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
 			<File
-				RelativePath=".\TerrainContentGenerator.cpp">
-			</File>
-			<File
 				RelativePath=".\TestCullingApplication.cpp">
 			</File>
@@ -132,7 +129,4 @@
 			Filter="h;hpp;hxx;hm;inl;inc;xsd"
 			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
-			<File
-				RelativePath=".\TerrainContentGenerator.h">
-			</File>
 			<File
 				RelativePath=".\TestCullingApplication.h">
