Index: trunk/VUT/Ogre/include/OgrePlatformQueryManager.h
===================================================================
--- trunk/VUT/Ogre/include/OgrePlatformQueryManager.h	(revision 143)
+++ trunk/VUT/Ogre/include/OgrePlatformQueryManager.h	(revision 144)
@@ -41,5 +41,5 @@
 			    InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,
 			    InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,
-			    bool projectedPixels = false
+			    bool relativeVisibility = false
 			    );
     
@@ -52,5 +52,5 @@
 			       InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,
 			       InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,
-			       bool projectedPixels = false
+			       bool relativeVisibility = false
 			       );
     
@@ -73,5 +73,5 @@
 	     );  
 
-	/** Sets a viewport to render into.
+	/** Sets a viewport for rendering.
 	*/
 	void SetViewport(Viewport *vp);
Index: trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp	(revision 143)
+++ trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp	(revision 144)
@@ -23,5 +23,5 @@
 			    InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,
 			    InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,
-			    bool projectedPixels)
+			    bool relativeVisibility)
 {
 	// we need access to the scene manager and the rendersystem
@@ -68,5 +68,5 @@
 	*/
 	// for relative visibility we need 2 rendering passes
-	int n = projectedPixels ? 2 : 1;
+	int n = relativeVisibility ? 2 : 1;
 	
 	for (int i=0; i<n; ++i)
@@ -104,5 +104,5 @@
 
 	//---- collect results
-	unsigned int visiblePixels = 0;
+	
 	std::pair<InfoContainer<GtpVisibility::NodeInfo>::iterator, bool> insertNode;
 	std::pair<InfoContainer<GtpVisibility::MeshInfo>::iterator, bool> insertGeom;
@@ -116,14 +116,12 @@
 	for (nodeIt = nodeList->begin(); nodeIt != nodeIt_end; ++nodeIt)
 	{
+		unsigned int visiblePixels = 0;
 		(*visQueryIt)->GetQueryResult(visiblePixels, true);
 	
-		int visiblePixels = visiblePixels;
-		int projectedPixels = 0;
-
-		if (projectedPixels)
-		{
-			(*projQueryIt)->GetQueryResult(visiblePixels, true);
-	
-			mProjectedPixels = visiblePixels;
+		unsigned int projectedPixels = 0;
+
+		if (relativeVisibility)
+		{
+			(*projQueryIt)->GetQueryResult(projectedPixels, true);
 		
 			++projQueryIt;
@@ -145,14 +143,12 @@
 	for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++geometryIt)
 	{
+		unsigned int visiblePixels = 0;
 		(*visQueryIt)->GetQueryResult(visiblePixels, true);
 		
-		int visiblePixels = visiblePixels;
-		int projectedPixels = 0;
-
-		if (projectedPixels)
-		{
-			(*projQueryIt)->GetQueryResult(visiblePixels, true);
-
-			mProjectedPixels = visiblePixels;
+		unsigned int projectedPixels = 0;
+
+		if (relativeVisibility)
+		{
+			(*projQueryIt)->GetQueryResult(projectedPixels, true);
 
 			++projQueryIt;
@@ -163,7 +159,8 @@
 		// approximate depth ordering during rendering => 
 		// geometry maybe occluded
-		if (isVisible)
+		if (visiblePixels > 0)
 		{			 
-			visibleGeometry->push_back(GtpVisibility::MeshInfo(*geometryIt,visiblePixels, projectedPixels));
+			visibleGeometry->push_back(GtpVisibility::MeshInfo(*geometryIt, 
+				visiblePixels, projectedPixels));
 		}
 	}
@@ -181,8 +178,18 @@
 }
 //-----------------------------------------------------------------------
+inline bool nodeinfo_lower(const GtpVisibility::NodeInfo &info1, const GtpVisibility::NodeInfo &info2) 
+{ 
+	return info1.GetNode() < info2.GetNode(); 
+}
+//-----------------------------------------------------------------------
+inline bool meshinfo_lower(const GtpVisibility::MeshInfo &info1, const GtpVisibility::MeshInfo &info2) 
+{ 
+	return info1.GetMesh() < info2.GetMesh(); 
+}
+//-----------------------------------------------------------------------
 void PlatformQueryManager::ComputeFromPointVisibility(const Vector3 &point,
 			       InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,
 			       InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,
-			       bool projectedPixels)
+			       bool relativeVisibility)
 {
 	SceneManager *sm = dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager();
@@ -221,5 +228,5 @@
 		LogManager::getSingleton().logMessage(d.str());
 
-		ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, projectedPixels);
+		ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, relativeVisibility);
 		
 		//mViewport->getTarget()->update(); for(int j=0; j<10000000; j++)	printf("HAAHHAHAHAHAH");
@@ -240,5 +247,5 @@
 
 	// --- visible nodes
-	sort(visibleNodes->begin(), visibleNodes->end());
+	sort(visibleNodes->begin(), visibleNodes->end(), nodeinfo_lower);
 	InfoContainer<GtpVisibility::NodeInfo>::iterator visibleNodesIt,
 		visibleNodesIt_end = visibleNodes->end();
@@ -256,6 +263,9 @@
 		{
 			// add visibility
-			nodeInfo->SetVisibility(nodeInfo->GetVisiblePixels() + 
+			nodeInfo->SetVisiblePixels(nodeInfo->GetVisiblePixels() + 
 				(*visibleNodesIt).GetVisiblePixels());
+		
+			nodeInfo->SetProjectedPixels(nodeInfo->GetProjectedPixels() + 
+				(*visibleNodesIt).GetProjectedPixels());
 		}
 
@@ -267,5 +277,5 @@
 
 	// --- visible geometry
-	sort(visibleGeometry->begin(), visibleGeometry->end());
+	sort(visibleGeometry->begin(), visibleGeometry->end(), meshinfo_lower);
 	InfoContainer<GtpVisibility::MeshInfo>::iterator visibleGeomIt,
 		visibleGeomIt_end = visibleGeometry->end();
@@ -283,12 +293,15 @@
 		{
 			// add visibility
-			geomInfo->SetVisibility(geomInfo->GetVisiblePixels() + 
+			geomInfo->SetVisiblePixels(geomInfo->GetVisiblePixels() + 
 				(*visibleGeomIt).GetVisiblePixels());
+
+			geomInfo->SetProjectedPixels(nodeInfo->GetProjectedPixels() + 
+				(*visibleNodesIt).GetProjectedPixels());
 		}
 	}
 
 	// now delete duplicates
-	visibleGeometry->erase(std::unique(visibleGeometry->begin(), 
-		visibleGeometry->end(), meshinfo_eq), visibleGeometry->end());
+	visibleGeometry->erase(std::unique(visibleGeometry->begin(), visibleGeometry->end(), 
+		meshinfo_eq), visibleGeometry->end());
 	
 }
