Index: trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp	(revision 153)
+++ trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp	(revision 154)
@@ -8,5 +8,5 @@
 //----------------------------------------------------------------------- 
 ItemBufferQueryManager::ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp):
-PlatformQueryManager(hierarchyInterface, vp), mWasInitialised(false)
+PlatformQueryManager(hierarchyInterface, vp)
 {
 }
@@ -23,5 +23,5 @@
 			    bool relativeVisibility)
 {
-	// initialise item buffer if necessary
+	// initialise item buffer (if not already initialised)
 	InitItemBuffer(visibleNodes, visibleGeometry);
 
@@ -45,5 +45,5 @@
 	sm->setOption("UseItemBuffer", &useItemBuffer);
 	
-	// clear background with black
+	// clear background with black (i.e., not a valid item id)
 	ColourValue bg = mViewport->getBackgroundColour();
 	mViewport->setBackgroundColour(ColourValue(0, 0, 0, 0));
@@ -70,22 +70,21 @@
 	uchar *buf = mViewport->getTarget()->getBufferContents(dimx, dimy);
 
+	
 	// loop through frame buffer & collect visible pixels
 	for (int idx = 0; idx < dimy * dimx * 3; idx += 3)
 	{
+		// -- decode color code to receive id
 		int id = buf[idx] << 16;
 		id += buf[idx + 1] << 8;
 		id += buf[idx + 2];
 
-		// if valid id <= add visibility
-		if ((id >= 0) && (id < (int)visibleGeometry->size()))
+		// if valid id <= add visibility (id values start at 1
+		if ((id > 0) && (id < (int)visibleGeometry->size()))
 		{
 			((*visibleGeometry)[id]).AddVisibility(1, 1);
 		}
-	/*	else
-		{ 
-			std::stringstream d; 
-			d << "id: " << id << ", buf 1: " << (int)buf[idx] << ", buf 2: " << (int)buf[idx + 1] << ", buf 3: " << (int)buf[idx + 2];
-			LogManager::getSingleton().logMessage(d.str());
-		}*/
+		/*else {	std::stringstream d; 
+			d << "adding pixel to geometry with id: " << id << ", buf 1: " << (int)buf[idx] << ", buf 2: " << (int)buf[idx + 1] << ", buf 3: " << (int)buf[idx + 2];
+			LogManager::getSingleton().logMessage(d.str());	}*/
 	}
 
@@ -104,9 +103,11 @@
 	mWasInitialised = true;
 
-	SceneManager::EntityIterator it = dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->
+	SceneManager::EntityIterator it = 
+		dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->
 		GetSceneManager()->getEntityIterator();
 
 	// TODO: make this more efficient
 	visibleGeometry->clear();
+	visibleNodes->clear();
 
 	while (it.hasMoreElements())
@@ -115,61 +116,3 @@
 	}
 }
-//-----------------------------------------------------------------------
-void ItemBufferQueryManager::ComputeFromPointVisibility(const Vector3 &point,
-			       InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,
-			       InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,
-			       bool relativeVisibility)
-{
-	SceneManager *sm = dynamic_cast<PlatformHierarchyInterface *>
-		(mHierarchyInterface)->GetSceneManager();
-
-	Camera *cam = sm->createCamera("PointQueryCam");	
-
-	//save old camera
-	Camera *savedCam = mViewport->getCamera();
-	
-	// --- initialise new camera
-	mViewport->setCamera(cam);
-	cam->setPosition(point);
-
-	cam->setNearClipDistance(savedCam->getNearClipDistance());
-	cam->setFarClipDistance(savedCam->getFarClipDistance());
-
-	// set frustum to 45 degrees so all the scene can be captured with 6 shots
-	cam->setAspectRatio(1.0);
-	cam->setFOVy(Radian(Math::HALF_PI));
-
-	int sign = -1;
-	
-	// ---- capture visibility from all 6 directions
-	for (int i=0; i < 6; i++)	
-	{
-		sign *= -1;
-		
-		// Print camera details
-      	std::stringstream d;
-		d << "Point query camera: " + StringConverter::toString(cam->getDerivedPosition()) + 
-			" " + "O: " + StringConverter::toString(cam->getDerivedOrientation());
-		LogManager::getSingleton().logMessage(d.str());
-
-		// prevent from initialising array again
-		if (i > 0)
-			mWasInitialised = true;
-		
-		// compute camera visibility for this direction
-		ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, relativeVisibility);
-
-		//mViewport->getTarget()->update(); for(int j=0; j<10000000; j++)	printf("wait"); // HACK: DISPLAY CAMERA VIEW
-
-		// --- permute directions
-		Vector3 dir(0,0,0);
-		dir[i/2] = sign;
-
-		cam->setDirection(dir);
-	}
-	
-	// reset camera
-	mViewport->setCamera(savedCam);
-}
-
 } // namespace Ogre
