Index: trunk/VUT/GtpVisibility/include/VisibilityInfo.h
===================================================================
--- trunk/VUT/GtpVisibility/include/VisibilityInfo.h	(revision 144)
+++ trunk/VUT/GtpVisibility/include/VisibilityInfo.h	(revision 145)
@@ -9,54 +9,60 @@
 namespace GtpVisibility {
   
-/** Class storing the visibility information of a scene node. 
+/** Class storing visibility information.
 */
-class NodeInfo 
+class VisibilityInfo
 {
 public:
-    NodeInfo(HierarchyNode *node, const int projectedPixels, const int visiblePixels): 
-	mNode(node)//, mProjectedPixels(projectedPixels), mVisiblePixels(visiblePixels) 
-	{}
+	VisibilityInfo(const int visiblePixels, const int projectedPixels);
 
-	int GetVisiblePixels() const {return mVisiblePixels;}
-	int GetProjectedPixels() const {return mProjectedPixels;}
+	int GetVisiblePixels() const;
+	int GetProjectedPixels() const;
 
-	void SetVisiblePixels(int vis) {mVisiblePixels = vis;}
-	void SetProjectedPixels(int vis) {mProjectedPixels = vis;}
+	void SetVisiblePixels(int vis);
+	void SetProjectedPixels(int vis);
+	
+	/** Computes ratio of visible to projected pixels. */
+	float ComputeRelativeVisibility();
 
-	void SetNode(HierarchyNode *node) {mNode = node;}
-	HierarchyNode *GetNode() const {return mNode;}
+	/** Adds visibility to current visibility information.
+	*/
+	void AddVisibility(const VisibilityInfo &info);
 
-	float ComputeRelativeVisibility() { float result = mVisiblePixels; if (mProjectedPixels) result /= (float)mProjectedPixels; return result;}
+
+protected:
+	/** number of visible pixels. */
+    int mVisiblePixels;
+	/** number of projected pixels */
+	int mProjectedPixels;
+};
+/** Class storing the visibility information of a hierarchy node. 
+*/
+class NodeInfo: public VisibilityInfo
+{
+public:
+    NodeInfo(HierarchyNode *node, const int visiblePixels, const int projectedPixels);
+
+	void SetNode(HierarchyNode *node);
+	HierarchyNode *GetNode() const;
 	//bool operator<(const NodeInfo& rhs) const {return mNode < rhs.mNode;}
 
 protected:
 
-    /** pointer to the scene node */
+    /** Pointer to the hierarchy nnode.
+	*/
     HierarchyNode *mNode;
-    
-    int mVisiblePixels;
-	int mProjectedPixels;
 };
   
 /** Class storing the visibility information of a mesh.
 */
-class MeshInfo 
+class MeshInfo: public VisibilityInfo
 {
 public:
-	MeshInfo(Mesh *mesh,  const int projectedPixels, const int visiblePixels): 
-	mMesh(mesh), mProjectedPixels(projectedPixels), mVisiblePixels(visiblePixels) 
-	{}
+	MeshInfo(Mesh *mesh, const int visiblePixels, const int projectedPixels);
 
-	int GetVisiblePixels() const {return mVisiblePixels;}
-	int GetProjectedPixels() const {return mProjectedPixels;}
+	Mesh *GetMesh() const;
+	void SetMesh(Mesh *mesh);
 
-	void SetVisiblePixels(float vis) { mVisiblePixels = vis;}
-	void SetProjectedPixels(float vis) { mProjectedPixels = vis;}
-
-	Mesh *GetMesh() const {return mMesh;}
-	void SetMesh(Mesh *mesh) {mMesh = mesh;}
-
-	bool operator<(const MeshInfo& rhs) const {return mMesh < rhs.mMesh;}
-	//bool operator>(const MeshInfo& rhs) const {return mMesh > rhs.mMesh;}
+	//bool operator<(const MeshInfo& rhs) const {return mMesh < rhs.mMesh;}
 	//bool operator==(const MeshInfo& rhs) const {return mMesh == rhs.mMesh;}
 	
@@ -66,7 +72,4 @@
 	*/
     Mesh *mMesh;
-  
-    int mVisiblePixels;
-	int mProjectedPixels;
 };
   
Index: trunk/VUT/GtpVisibility/src/VisibilityInfo.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/VisibilityInfo.cpp	(revision 145)
+++ trunk/VUT/GtpVisibility/src/VisibilityInfo.cpp	(revision 145)
@@ -0,0 +1,81 @@
+#include "VisibilityInfo.h"
+#include <OgreLogManager.h>
+
+namespace GtpVisibility {
+/****************************************************/
+/*           VisibilityInfo implementation          */
+/****************************************************/
+VisibilityInfo::VisibilityInfo(const int visiblePixels, const int projectedPixels): 
+mProjectedPixels(projectedPixels), mVisiblePixels(visiblePixels) 
+{
+}
+
+//-----------------------------------------------------------------------
+int VisibilityInfo::GetVisiblePixels() const 
+{
+	return mVisiblePixels;
+}
+//-----------------------------------------------------------------------
+int VisibilityInfo::GetProjectedPixels() const 
+{
+	return mProjectedPixels;
+}
+//-----------------------------------------------------------------------
+void VisibilityInfo::SetVisiblePixels(int vis) 
+{
+	mVisiblePixels = vis;
+}
+//-----------------------------------------------------------------------
+void VisibilityInfo::SetProjectedPixels(int vis) 
+{
+	mProjectedPixels = vis;
+}
+//-----------------------------------------------------------------------
+float VisibilityInfo::ComputeRelativeVisibility() 
+{ 
+	if (!mProjectedPixels) 
+		return 0;
+
+	return (float)mVisiblePixels / (float)mProjectedPixels; 
+}
+//-----------------------------------------------------------------------
+void VisibilityInfo::AddVisibility(const VisibilityInfo &info)
+{
+	mVisiblePixels += info.GetVisiblePixels();
+	mProjectedPixels += info.GetProjectedPixels();
+}
+/****************************************************/
+/*              NodeInfo implementation             */
+/****************************************************/
+//-----------------------------------------------------------------------
+NodeInfo::NodeInfo(HierarchyNode *node, const int visiblePixels, const int projectedPixels): 
+VisibilityInfo(visiblePixels, projectedPixels), mNode(node) 
+{}
+//-----------------------------------------------------------------------
+void NodeInfo::SetNode(HierarchyNode *node) 
+{
+	mNode = node;
+}
+//-----------------------------------------------------------------------	
+HierarchyNode *NodeInfo::GetNode() const 
+{
+	return mNode;
+}
+/****************************************************/
+/*              MeshInfo implementation             */
+/****************************************************/
+//-----------------------------------------------------------------------
+MeshInfo::MeshInfo(Mesh *mesh, const int visiblePixels, const int projectedPixels): 
+VisibilityInfo(visiblePixels, projectedPixels), mMesh(mesh) 
+{}
+//-----------------------------------------------------------------------
+void MeshInfo::SetMesh(Mesh *mesh) 
+{
+	mMesh = mesh;
+}
+//-----------------------------------------------------------------------	
+Mesh *MeshInfo::GetMesh() const 
+{
+	return mMesh;
+}
+}// namespace GtpVisibility
Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 144)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 145)
@@ -377,7 +377,10 @@
 	for (geomIt = visibleGeometry.begin(); geomIt != geomIt_end; ++geomIt)
 	{
-		averageGeometryVis += (*geomIt).GetVisiblePixels();
-
-		std::stringstream d; d << "Geometry visibility: " << (*geomIt).GetVisiblePixels();
+		float vis = relativeVisibility ? 
+			(*geomIt).ComputeRelativeVisibility() : (float)(*geomIt).GetVisiblePixels();
+		
+		averageGeometryVis += vis;
+
+		std::stringstream d; d << "Geometry visibility: " << vis;
 		LogManager::getSingleton().logMessage(d.str());
 	}
@@ -387,13 +390,16 @@
 	for (nodesIt = visibleNodes.begin(); nodesIt != nodesIt_end; ++nodesIt)
 	{
-		averageNodeVis += (*nodesIt).GetVisiblePixels();
-
-		std::stringstream d; d << "Node visibility: " << (*nodesIt).GetVisiblePixels();
+		float vis = relativeVisibility ? 
+			(*nodesIt).ComputeRelativeVisibility() : (float)(*nodesIt).GetVisiblePixels();
+		
+		averageNodeVis += vis;
+		
+		std::stringstream d; d << "Node visibility: " << vis;
 		LogManager::getSingleton().logMessage(d.str());
 	}
 
-	if ((int)visibleNodes.size())
+	if (visibleNodes.size())
 		averageNodeVis /= (float)visibleNodes.size();
-	if ((int)visibleGeometry.size())
+	if (visibleGeometry.size())
 		averageGeometryVis /= (float)visibleGeometry.size();
 
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 144)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 145)
@@ -18,5 +18,8 @@
 /*     TestCullingTerrainApplication implementation    */
 /*******************************************************/
-
+TestCullingTerrainApplication::TestCullingTerrainApplication():
+mTerrainContentGenerator(NULL)
+{
+}
 //-----------------------------------------------------------------------
 TestCullingTerrainApplication::~TestCullingTerrainApplication()
@@ -69,10 +72,10 @@
 bool TestCullingTerrainApplication::setup()
 {
-	bool result = ExampleApplication::setup();
-
-	if (mWindow)
+	bool carryOn = ExampleApplication::setup();
+
+	if (carryOn)
 		createRenderTargetListener();
 
-	return result;
+	return carryOn;
 }
 //-----------------------------------------------------------------------
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 139)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 145)
@@ -28,4 +28,5 @@
 {
 public:
+	TestCullingTerrainApplication();
 	~TestCullingTerrainApplication();
 
Index: trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp	(revision 144)
+++ trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp	(revision 145)
@@ -130,6 +130,5 @@
 		++visQueryIt;
 		
-		// nodes with visibilty 0 in queue: 
-		// happens if node is intersected by near plane
+		// node with visibilty 0 in queue (e.g., if node is intersected by near plane)
 		if (visiblePixels > 0)
 		{
@@ -161,6 +160,6 @@
 		if (visiblePixels > 0)
 		{			 
-			visibleGeometry->push_back(GtpVisibility::MeshInfo(*geometryIt, 
-				visiblePixels, projectedPixels));
+			visibleGeometry->push_back(GtpVisibility::MeshInfo(*geometryIt, visiblePixels, 
+				projectedPixels));
 		}
 	}
@@ -209,9 +208,4 @@
 	cam->setAspectRatio(1.0);
 	cam->setFOVy(Radian(Math::HALF_PI));
-
-	std::stringstream d;
-	d << "old camera: " + StringConverter::toString(savedCam->getDerivedPosition()) + 
-		" " + "O: " + StringConverter::toString(savedCam->getDerivedOrientation());
-	LogManager::getSingleton().logMessage(d.str());
 
 	int sign = -1;
@@ -230,5 +224,5 @@
 		ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, relativeVisibility);
 		
-		//mViewport->getTarget()->update(); for(int j=0; j<10000000; j++)	printf("HAAHHAHAHAHAH");
+		//mViewport->getTarget()->update(); for(int j=0; j<10000000; j++)	printf("wait");
 
 		// permute directions
@@ -254,5 +248,5 @@
 
 	for (visibleNodesIt = visibleNodes->begin(); visibleNodesIt != visibleNodesIt_end; 
-		++visibleNodesIt);
+		++visibleNodesIt)
 	{
 		if (!nodeInfo || (nodeInfo->GetNode() != (*visibleNodesIt).GetNode()))
@@ -260,12 +254,7 @@
 			nodeInfo = &(*visibleNodesIt);
 		}
-		else
-		{
-			// add visibility
-			nodeInfo->SetVisiblePixels(nodeInfo->GetVisiblePixels() + 
-				(*visibleNodesIt).GetVisiblePixels());
-		
-			nodeInfo->SetProjectedPixels(nodeInfo->GetProjectedPixels() + 
-				(*visibleNodesIt).GetProjectedPixels());
+		else // add visibility
+		{			
+			nodeInfo->AddVisibility(*visibleNodesIt);
 		}
 
@@ -283,6 +272,7 @@
 	GtpVisibility::MeshInfo *geomInfo = NULL;
 
+	int i=0;
 	for (visibleGeomIt = visibleGeometry->begin(); visibleGeomIt != visibleGeomIt_end; 
-		++visibleGeomIt);
+		++visibleGeomIt)
 	{
 		if (!geomInfo || (geomInfo->GetMesh() != (*visibleGeomIt).GetMesh()))
@@ -290,12 +280,7 @@
 			geomInfo = &(*visibleGeomIt);
 		}
-		else // info points to equal mesh
-		{
-			// add visibility
-			geomInfo->SetVisiblePixels(geomInfo->GetVisiblePixels() + 
-				(*visibleGeomIt).GetVisiblePixels());
-
-			geomInfo->SetProjectedPixels(nodeInfo->GetProjectedPixels() + 
-				(*visibleNodesIt).GetProjectedPixels());
+		else // info points to same mesh, just add visibility
+		{
+			geomInfo->AddVisibility(*visibleGeomIt);
 		}
 	}
