Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionQueriesQueryManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionQueriesQueryManager.h	(revision 2280)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionQueriesQueryManager.h	(revision 2505)
@@ -21,8 +21,6 @@
 	OcclusionQueriesQueryManager(PlatformHierarchyInterface *hierarchyInterface, 
 								 Viewport *vp,
-								 int queryModes, 
-								 int itemBufferMode):  
-	PlatformQueryManager(hierarchyInterface, vp, queryModes), 
-	mItemBufferMode(itemBufferMode)
+								 int queryModes):  
+	PlatformQueryManager(hierarchyInterface, vp, queryModes)
 	{}
 
@@ -59,11 +57,4 @@
 							   bool relativeVisibility);
 
-	void CollectRelativeGeometryVisibilityForItemBuffer(GtpVisibility::QueryList::iterator &projQueryIt,
-														GeometryVector *geometryList, 
-														MeshInfoContainer *visibleGeometry);
-
-	void CollectRelativePatchVisibilityForItemBuffer(GtpVisibility::QueryList::iterator &projQueryIt,
-													 PatchVector *patchList, 
-													 PatchInfoContainer *visiblePatches);
 
 	void CollectPatchVisibility(GtpVisibility::QueryList::iterator &visQueryIt, 
@@ -84,5 +75,4 @@
 					 			  PatchVector *patchList);
 
-	int mItemBufferMode;
 };
 
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformQueryManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformQueryManager.h	(revision 2280)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformQueryManager.h	(revision 2505)
@@ -52,12 +52,4 @@
 protected:
 
-#ifdef ITEM_BUFFER
-	void CollectItemBufferResults(MeshInfoContainer *visibleGeometry,
-								  PatchInfoContainer *visiblePatches);
-
-	void InitItemBuffer(MeshInfoContainer *visibleGeometry,
-						PatchInfoContainer *visiblePatches);
-#endif // ITEM_BUFFER
-
 	Viewport *mViewport;
 	bool mWasInitialised;
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp	(revision 2455)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp	(revision 2505)
@@ -12,5 +12,9 @@
 namespace Ogre {
 
-
+//-----------------------------------------------------------------------
+void PlatformQueryManager::SetViewport(Viewport *vp)
+{
+	mViewport = vp;
+}
 //-----------------------------------------------------------------------
 void PlatformQueryManager::ComputeFromPointVisibility(
@@ -65,7 +69,5 @@
 		// prevent from initialising geometry / node array again
 		if (dir > 0)
-		{
 			mWasInitialised = true;
-		}
 
 		ComputeCameraVisibility(*cam, 
@@ -114,130 +116,11 @@
 	//pfHierarchyInterface->GetRenderSystem()->clearFrameBuffer(FBT_COLOUR | FBT_DEPTH);
 
-#ifdef ITEM_BUFFER
-	// initialise item buffer (if not already initialised)
-	InitItemBuffer(visibleGeometry, visiblePatches);
-
-	//////////
-	//-- render scene with item buffer (i.e., objects with their id as color codes)
-
-	// enable item buffer (must be provided by scene manager)
-	bool useItemBuffer = true;
-	sm->setOption("UseItemBuffer", &useItemBuffer);
-#endif // ITEM_BUFFER
-
-	sm->_renderScene(pCam, mViewport, false); // render item buffer
+	// render scene once to fill depth buffer
+	sm->_renderScene(pCam, mViewport, false); 
    
-#ifdef ITEM_BUFFER
-	/////////
-	//-- collect results
-	CollectItemBufferResults(visibleGeometry, visiblePatches);
-
-	/////////
-	//-- reset state
-	useItemBuffer = false; // don't need item buffer anymore
-	sm->setOption("UseItemBuffer", &useItemBuffer);
-#endif // ITEM_BUFFER
-
-	mWasInitialised = false; // reset initialised - flag
+	mWasInitialised = false; // reset flag
 	mViewport->setOverlaysEnabled(overlayEnabled); // reset old overlay status
 	mViewport->setBackgroundColour(bg); // reset background color
 }
-#ifdef ITEM_BUFFER
-//-----------------------------------------------------------------------
-void PlatformQueryManager::CollectItemBufferResults(
-				MeshInfoContainer *visibleGeometry,
-				PatchInfoContainer *visiblePatches)
-{
-	int dimx = 0;
-	int dimy = 0;
 
-	// copy frame buffer 
-	uchar *buf = mViewport->getTarget()->getBufferContents(dimx, dimy);
-
-	// loop through frame buffer and 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 (id values start at 1)
-		if (mQueryModes == PATCH_VISIBILITY)
-		{	
-			if ((id > 0) && (id < (int)visiblePatches->size()))
-			{
-				((*visiblePatches)[id]).AddVisibility(1, 0);
-			}
-		}
-		else if (mQueryModes == GEOMETRY_VISIBILITY)
-		{
-			if ((id > 0) && (id < (int)visibleGeometry->size()))
-			{
-				((*visibleGeometry)[id]).AddVisibility(1, 0);
-			}
-		}
-	}
-
-	delete [] buf;
-}
-
-//-----------------------------------------------------------------------
-void PlatformQueryManager::InitItemBuffer(
-				MeshInfoContainer *visibleGeometry,
-				PatchInfoContainer *visiblePatches)
-{
-	if (mWasInitialised)
-		return;
-
-	mWasInitialised = true;
-
-	SceneManager *sm = 
-		//static_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager();
-		static_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager();
-
-	SceneManager::EntityIterator it = sm->getEntityIterator();
-
-	// TODO: make the function more efficient
-
-	visibleGeometry->clear();
-	visiblePatches->clear();
-
-	int id = 0;
-
-	/* We can either use patches or meshes. If patches are used, an unique id must
-	   be given each patch. Otherwise the same id must be given to all patches belonging
-	   to the same mesh.
-    */
-	while (it.hasMoreElements())
-	{
-		Entity *ent = it.getNext();
-
-		for (int i = 0; i < (int)ent->getNumSubEntities(); ++i)
-		{
-			SubEntity *subEnt = ent->getSubEntity(i);
-
-			if (mQueryModes == PATCH_VISIBILITY)
-			{
-				++ id;
-				visiblePatches->push_back(GtpVisibility::PatchInfo(subEnt, 0, 0));
-			}
-				
-			subEnt->setId(id);
-			//subEnt->setId((41 << 16) + (4 << 8) + 60);
-		}
-			
-		if (mQueryModes == GEOMETRY_VISIBILITY)
-		{
-			visibleGeometry->push_back(GtpVisibility::MeshInfo(ent, 0, 0));
-			++ id;
-		}
-	}
-}
-#endif // ITEM_BUFFER
-//-----------------------------------------------------------------------
-void PlatformQueryManager::SetViewport(Viewport *vp)
-{
-	mViewport = vp;
-}
 } // namespace Ogre
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2353)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2505)
@@ -114,5 +114,5 @@
 				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;..\..\..\..\..\..\..\NonGTP\Zlib\lib;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\lib\$(ConfigurationName)&quot;"
 				ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def"
-				GenerateDebugInformation="FALSE"
+				GenerateDebugInformation="TRUE"
 				SubSystem="2"
 				OptimizeReferences="2"
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2502)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2505)
@@ -2206,5 +2206,4 @@
 														   const bool nodeVisibility)
 {
-	const int itemBufferMode = 0;
 	const bool relativeVisibility = false;
 	const bool approximateVisibility = false;
@@ -2220,6 +2219,5 @@
 		new OcclusionQueriesQueryManager(mHierarchyInterface,
 										 vp,
-										 queryModes, 
-										 itemBufferMode);
+										 queryModes);
 
 	mVisibilityManager->SetQueryManager(queryManager);
@@ -2397,5 +2395,4 @@
 	// don't have to fill queue, just render depth
 	const bool fillQueue = false;
-
 	RenderHierarchicalCulling(fillQueue);
    
@@ -2495,5 +2492,4 @@
 	mBoxes.clear();
 
-	const int itemBufferMode = 0;
 	const bool relativeVisibility = false;
 	bool approximateVisibility = false;
@@ -2518,6 +2514,5 @@
 		new OcclusionQueriesQueryManager(mHierarchyInterface,
 										 cam->getViewport(),
-										 queryModes, 
-										 itemBufferMode);
+										 queryModes);
 
 	mVisibilityManager->SetQueryManager(queryManager);
@@ -2546,5 +2541,5 @@
 	}
 		
-	if (1)
+	if (0)
 	{
 		std::stringstream d; 
@@ -2563,5 +2558,4 @@
 		////////////
 		//-- apply queries on geometry level
-
 		AddVisibleNodeGeometryToQueue(visibleNodes, cam);
 	}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 2280)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 2505)
@@ -19,6 +19,5 @@
 							int queryModes,
 							int itemBufferMode)
-:PlatformQueryManager(hierarchyInterface, vp, queryModes), 
-mItemBufferMode(itemBufferMode)
+:PlatformQueryManager(hierarchyInterface, vp, queryModes)
 {
 }*/
@@ -39,59 +38,36 @@
 	bool overlayEnabled = mViewport->getOverlaysEnabled();
 
-	//mItemBufferMode = 0;
-	if (0 && (mItemBufferMode && mQueryModes) != 0)
-	{
-		///////////
-		//-- render scene with item buffer (ids are used as color codes)
-
-		int savedQueryModes = mQueryModes;
-		mQueryModes = mItemBufferMode;
-		
-		PlatformQueryManager::ComputeCameraVisibility(camera, 
-													  visibleNodes,
-													  visibleGeometry, 
-													  visiblePatches, 
-													  relativeVisibility,
-													  approximateVisibility);
-		
-		// overlays cause false visibility
-		mViewport->setOverlaysEnabled(false);
-		mQueryModes = savedQueryModes;
-	}
-	else
-	{
-   		// const_cast allowed because camera is not changed in renderScene
-		Camera *pCam = const_cast<Camera *>(&camera); 
-		mViewport->setOverlaysEnabled(false);
-
-		////////////////////////
-		//-- Render scene to get conservative visibility and fill depth buffer
-
-		OcclusionCullingSceneManager *occlusionSceneMgr = 
-			static_cast<OcclusionCullingSceneManager *>(pfHierarchyInterface->GetSceneManager());
-
-		// no visibility manager available => no visibility scene manager, return
-		GtpVisibility::VisibilityManager *visManager = NULL;	
-		
-		if (!occlusionSceneMgr->getOption("VisibilityManager", &visManager))
-		{
-			Ogre::LogManager::getSingleton().logMessage("no vismanager found");
-			return;
-		}
-
-		// use stop and wait culling for from view point queries because probably
-		// no temporal coherence
-		GtpVisibility::VisibilityEnvironment::CullingManagerType occlusionType = 
-			visManager->GetCullingManagerType();
-
-		visManager->SetCullingManager(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING);
-
-		if (1)
-			occlusionSceneMgr->RenderDepthForQuery(pCam, mViewport);
-		else
-			pfHierarchyInterface->GetSceneManager()->_renderScene(pCam, mViewport, false);
-
-		visManager->SetCullingManager(occlusionType);
-	}
+	// const_cast allowed because camera is not changed in renderScene
+	Camera *pCam = const_cast<Camera *>(&camera); 
+	mViewport->setOverlaysEnabled(false);
+
+	////////////////////////
+	//-- Render scene to get conservative visibility and fill depth buffer
+
+	OcclusionCullingSceneManager *occlusionSceneMgr = 
+		static_cast<OcclusionCullingSceneManager *>(pfHierarchyInterface->GetSceneManager());
+
+	// no visibility manager available => no visibility scene manager, return
+	GtpVisibility::VisibilityManager *visManager = NULL;	
+
+	if (!occlusionSceneMgr->getOption("VisibilityManager", &visManager))
+	{
+		Ogre::LogManager::getSingleton().logMessage("no vismanager found");
+		return;
+	}
+
+	// use stop and wait culling for from view point queries because
+	// of issues with temporal coherence
+	GtpVisibility::VisibilityEnvironment::CullingManagerType occlusionType = 
+		visManager->GetCullingManagerType();
+
+	visManager->SetCullingManager(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING);
+
+	// rendert the scene once to fill depth buffer and to get a first approximation
+	// of visible objects
+	occlusionSceneMgr->RenderDepthForQuery(pCam, mViewport);
+
+	// reset occlusion culling manager
+	visManager->SetCullingManager(occlusionType);
 
 	
@@ -164,18 +140,16 @@
 	// for relative visibility we need 2 rendering passes
 	int n = relativeVisibility ? 2 : 1;
-	if (mItemBufferMode > 0)
-		LogManager::getSingleton().logMessage("using item buffer");
+	
 
 	for (int i = 0; i < n; ++ i)
 	{
-		//-- queries for hierarchy nodes
+		//-- query the hierarchy nodes
 		for (nodeIt = nodeList.begin(); nodeIt != nodeIt_end; ++ nodeIt)		
 		{
 			// TODO: DELETE QUERIES FROM PREVIOUS RENDER
 			bool intersects = false;
-
 			pfHierarchyInterface->CheckFrustumVisible(*nodeIt, intersects);
 
-			// always push back if only checking approximate visibility or intersects
+			// always add node if only checking for approximate visibility or intersects
 			if (approximateVisibility || intersects)
 			{
@@ -195,50 +169,45 @@
 		///////////////
 		//-- queries for geometry
-		
-		// note: for item buffer we can capture only projected visibility
-
-		if ((mItemBufferMode != GEOMETRY_VISIBILITY) || (i == 1))
-		{			
-			for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++ geometryIt)
-			{
-				if (approximateVisibility)
-				{
-					// no more information available
-					const int visPixels = 1;
-					const int projPixels = 1;
-
-					visibleGeometry->push_back(MeshInfo(*geometryIt, visPixels, projPixels));
-				}
-				else
-				{
-					queryList[i].push_back(pfHierarchyInterface->IssueMeshOcclusionQuery(*geometryIt));
-				}
-			}
-		}
-		
+
+		for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++ geometryIt)
+		{
+			if (approximateVisibility)
+			{
+				// no more information available
+				const int visPixels = 1;
+				const int projPixels = 1;
+
+				visibleGeometry->push_back(MeshInfo(*geometryIt, visPixels, projPixels));
+			}
+			else
+			{
+				queryList[i].push_back(pfHierarchyInterface->IssueMeshOcclusionQuery(*geometryIt));
+			}
+		}
+
 		///////////////
 		//-- queries for patches
 
-		if ((mItemBufferMode != PATCH_VISIBILITY) || (i == 1))
-		{
-			for (patchIt = patchList.begin(); patchIt != patchIt_end; ++patchIt)
-			{
-				if (approximateVisibility)
-				{
-					// no more information available
-					const int visPixels = 1;
-					const int projPixels = 1;
-
-					visiblePatches->push_back(PatchInfo(*patchIt, visPixels, projPixels));
-				}
-				else
-				{
-					queryList[i].push_back(pfHierarchyInterface->IssuePatchOcclusionQuery(*patchIt));
-				}
-			}
-		}
-
+		for (patchIt = patchList.begin(); patchIt != patchIt_end; ++patchIt)
+		{
+			if (approximateVisibility)
+			{
+				// there is not more information available
+				const int visPixels = 1;
+				const int projPixels = 1;
+
+				visiblePatches->push_back(PatchInfo(*patchIt, visPixels, projPixels));
+			}
+			else
+			{
+				queryList[i].push_back(pfHierarchyInterface->IssuePatchOcclusionQuery(*patchIt));
+			}
+		}
+
+		// the second time we have to render against the cleared depth buffer to obtain
+		// projected pixels
 		pfHierarchyInterface->GetRenderSystem()->clearFrameBuffer(FBT_DEPTH);
 	}
+
 
 	///////////////	
@@ -248,46 +217,33 @@
 	GtpVisibility::QueryList::iterator projQueryIt = queryList[1].begin();
 	
-	// collect occlusion queries for hierarchy nodes
-	CollectNodeVisibility(visQueryIt, 
-						  projQueryIt, 
-						  &nodeList, 
-						  visibleNodes, 
-						  relativeVisibility);
-
-
-	// collect occlusion queries for geometry
-	if ((mItemBufferMode == GEOMETRY_VISIBILITY) && relativeVisibility)
-	{
-		// if visibility was established using the item buffer,
-		// the array is organized different (e.g., ordered by id, all possible objects)
-		CollectRelativeGeometryVisibilityForItemBuffer(projQueryIt, 
-													   &geometryList, 
-													   visibleGeometry);
-	}
-	else if (mItemBufferMode != GEOMETRY_VISIBILITY)
-	{
+	if (1)
+	{	
+		// collect occlusion queries for hierarchy nodes
+		CollectNodeVisibility(visQueryIt, 
+			projQueryIt, 
+			&nodeList, 
+			visibleNodes, 
+			relativeVisibility);
+	}
+
+	if (1)
+	{	
 		CollectGeometryVisibility(visQueryIt, 
-								  projQueryIt, 
-								  &geometryList, 
-								  visibleGeometry, 
-								  relativeVisibility);
-	}
-
-
-	// collect occlusion queries for patches
-	if ((mItemBufferMode == PATCH_VISIBILITY) && relativeVisibility)
-	{
-		CollectRelativePatchVisibilityForItemBuffer(projQueryIt, 
-													&patchList, 
-													visiblePatches);
-	}
-	else if (mItemBufferMode != PATCH_VISIBILITY)
-	{
+			projQueryIt, 
+			&geometryList, 
+			visibleGeometry, 
+			relativeVisibility);
+	}
+
+	if (1)
+	{
+		// collect occlusion queries for patches
 		CollectPatchVisibility(visQueryIt, 
-							   projQueryIt, 
-							   &patchList, 
-							   visiblePatches, 
-							   relativeVisibility);
-	}	
+			projQueryIt, 
+			&patchList, 
+			visiblePatches, 
+			relativeVisibility);
+	}
+
 
 	////////////
@@ -321,14 +277,6 @@
 	// (duplicates occur if an object is on the edge of the viewport)
 	RemoveDuplicateNodes(visibleNodes);
-
-	if (mItemBufferMode != GEOMETRY_VISIBILITY)
-	{
-		RemoveDuplicateGeometry(visibleGeometry);
-	}
-
-	if (mItemBufferMode != PATCH_VISIBILITY)
-	{
-		RemoveDuplicatePatches(visiblePatches);
-	}
+	RemoveDuplicateGeometry(visibleGeometry);
+	RemoveDuplicatePatches(visiblePatches);
 }
 //------------------------------------------------------------------------
@@ -374,52 +322,4 @@
 }
 //-----------------------------------------------------------------------
-void OcclusionQueriesQueryManager::CollectRelativeGeometryVisibilityForItemBuffer(
-									GtpVisibility::QueryList::iterator &projQueryIt,
-									GeometryVector *geometryList, 
-									MeshInfoContainer *visibleGeometry)
-{
-	GeometryVector::iterator geometryIt;
-
-	//-- queries for geometry
-	for (geometryIt = geometryList->begin(); geometryIt != geometryList->end(); ++ geometryIt)
-	{
-		unsigned int projectedPixels = 0;
-
-		(*projQueryIt)->GetQueryResult(projectedPixels, true);
-
-		++projQueryIt;
-		int id = (*geometryIt)->getSubEntity(0)->getId();
-
-		if ((id > 0) && (id < (int)visibleGeometry->size()))
-		{
-			(*visibleGeometry)[id].AddVisibility(0, projectedPixels);
-		}
-	}
-}
-//-----------------------------------------------------------------------
-void OcclusionQueriesQueryManager::CollectRelativePatchVisibilityForItemBuffer(
-									GtpVisibility::QueryList::iterator &projQueryIt,
-									PatchVector *patchList, 
-									PatchInfoContainer *visiblePatches)
-{
-	PatchVector::iterator patchIt;
-
-	//-- queries for geometry
-	for (patchIt = patchList->begin(); patchIt != patchList->end(); ++ patchIt)
-	{
-		unsigned int projectedPixels = 0;
-
-		(*projQueryIt)->GetQueryResult(projectedPixels, true);
-
-		++projQueryIt;
-		int id = (*patchIt)->getId();
-
-		if ((id > 0) && (id < (int)visiblePatches->size()))
-		{
-			(*visiblePatches)[id].AddVisibility(0, projectedPixels);
-		}
-	}
-}
-//-----------------------------------------------------------------------
 void  OcclusionQueriesQueryManager::CollectGeometryVisibility(
 							GtpVisibility::QueryList::iterator &visQueryIt, 
