Index: /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp	(revision 1304)
+++ /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp	(revision 1312)
@@ -623,8 +623,4 @@
 		mSceneMgr->setOption("RenderMethod", &mOptions.mRenderMethod);
 		mSceneMgr->setOption("EnhancedVisibility", &mOptions.mEnhancedVisibility);
-		mSceneMgr->setOption("DeleteRenderQueue", &mOptions.mDelRenderQueue);
-		// fix
-		bool depthpass = false;
-		mSceneMgr->setOption("UseDepthPass", &depthpass);
 	}
 	// set algorithm when scene manager is OCM - numbering is different though
@@ -633,6 +629,12 @@
 		int alg = CONV_KDT_TO_OCM_ALG(mOptions.mRenderMethod);
 		mSceneMgr->setOption("Algorithm", &alg);
-		mSceneMgr->setOption("DeleteRenderQueue", &mOptions.mDelRenderQueue);
-	}
+	}
+	bool vizcullnodes = true;
+	mSceneMgr->setOption("VisualizeCulledNodes", &vizcullnodes);
+	mSceneMgr->setOption("DeleteRenderQueue", &mOptions.mDelRenderQueue);
+
+	// fix
+	//bool depthpass = true;
+	//mSceneMgr->setOption("UseDepthPass", &depthpass);
 
 	// create ray query for ground intersection
Index: /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp	(revision 1304)
+++ /GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp	(revision 1312)
@@ -432,5 +432,6 @@
 {
 	// viewcells apply only for scenes loaded from geometry
-	if (mOptions.mSceneType != ST_GEOMETRY)
+	if (mOptions.mSceneType != ST_GEOMETRY || 
+		mOptions.myApp->getViewCellsFileName().empty())
 		return;
 
@@ -445,5 +446,6 @@
 		// call once to load view cell loading overlay
 		mWindow->update();
-		mViewCellsLoaded = mSceneMgr->setOption("LoadViewCells", mOptions.myApp->getViewCellsFileName().c_str());
+		mViewCellsLoaded = mSceneMgr->setOption("LoadViewCells", 
+			mOptions.myApp->getViewCellsFileName().c_str());
 
 		if (!mViewCellsLoaded)
@@ -746,4 +748,10 @@
 	{
 		toggleRenderMethod();
+		mTimeUntilNextToggle = 0.5;
+	}
+
+	if (mInputDevice->isKeyDown(KC_V) && mTimeUntilNextToggle <= 0)
+	{
+		toggleEnhancedVisibility();
 		mTimeUntilNextToggle = 0.5;
 	}
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h	(revision 1296)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h	(revision 1312)
@@ -483,5 +483,5 @@
 		typedef std::set<LeafPtr> LeafSet;
 
-		typedef struct Stats_
+		struct TreeStats
 		{
 			unsigned int mNumNodes;
@@ -494,6 +494,20 @@
 				mNumLeaves = 0;
 				mNumSceneNodes = 0;
-			};
-		} Stats;
+			}
+		};
+
+		struct FrameStats 
+		{
+			unsigned int mTraversedNodes;
+			unsigned int mRenderedNodes;
+			unsigned int mFrustumCulledNodes;
+
+			void clear(void)
+			{
+				mTraversedNodes = 0;
+				mRenderedNodes = 0;
+				mFrustumCulledNodes = 0;
+			}
+		};
 
 		enum RenderMethod
@@ -571,7 +585,8 @@
 
 		// self-explanatory ...
-		int getMaxDepth(void) { return mMaxDepth; };
-		const Stats& getStats(void) const { return mStats; };
-		AxisAlignedBox getBox(void) { if (mKdRoot) return mKdRoot->mAABB; else return AxisAlignedBox(); };
+		int getMaxDepth(void) { return mMaxDepth; }
+		const TreeStats& getTreeStats(void) const { return mTreeStats; }
+		const FrameStats& getFramesStats(void) const { return mFrameStats; }
+		AxisAlignedBox getBox(void) { if (mKdRoot) return mKdRoot->mAABB; else return AxisAlignedBox(); }
 		void setBuildMethod(BuildMethod bm) { mBuildMethod = bm; }
 	protected:
@@ -627,6 +642,9 @@
 		Log * mBuildLog;
 
-		// statistical information
-		Stats mStats;
+		// statistical information on the tree
+		TreeStats mTreeStats;
+
+		// statistical info on a single rendered frame
+		FrameStats mFrameStats;
 
 		/** Visualization flags **/
@@ -638,5 +656,7 @@
 		bool mShowNodes;
 
-		// pointer zur getVisibility function (simple oder enhanced)
+		// function pointer to the getVisibility function
+		// allows choosing between regular vis (NONE/PART, same es isVisible)
+		// and enhaced vis (NONE/PART/FULL) for early traversal abort
 		KdTreeCamera::NodeVisibility (KdTreeCamera::*getVisibility)(const AxisAlignedBox& box) const;
 
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeCamera.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeCamera.h	(revision 1250)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeCamera.h	(revision 1312)
@@ -28,22 +28,8 @@
 	};
 
-	//typedef NodeVisibility (KdTreeCamera::*VisFunction)(const AxisAlignedBox& box) const;
-
 	// default constructor
 	KdTreeCamera(const String& name, SceneManager *sm);
 	// default destructor
 	~KdTreeCamera();
-
-	// chage vis mode
-	void setEnhancedVisMode(bool enhanced);
-	// query vis mode
-	bool getEnhancedVisMode(void);
-
-	// function pointer to the actual getvis function
-	// allows choosing between regular vis (NONE/PART, same es isVisible)
-	// and enhaced vis (NONE/PART/FULL) for early traversal abort
-	//NodeVisibility (KdTreeCamera::*getVisibility)(const AxisAlignedBox& box) const;
-	//VisFunction getVisibility;
-	//NodeVisibility getVisibility(const AxisAlignedBox& box ) const;
 
 	// regular visibility, like isVisible
@@ -52,10 +38,6 @@
 	NodeVisibility getVisibilityEnhanced(const AxisAlignedBox& box) const;
 
-	// DEBUG
-	//mutable unsigned int mNumVisQueries;
-protected:
-
-	// flag indicating current vis mode, default is on (true)
-	bool mEnhancedVisMode;
+	// statistical info
+	mutable unsigned int mNumVisQueries;
 };
 
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeCamera.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeCamera.cpp	(revision 1250)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeCamera.cpp	(revision 1312)
@@ -14,8 +14,7 @@
 
 KdTreeCamera::KdTreeCamera(const String& name, SceneManager *sm):
-Camera(name, sm), 
-mEnhancedVisMode(true)
+Camera(name, sm)
 {
-	//getVisibility = getVisibilityEnhanced;
+
 }
 
@@ -25,19 +24,10 @@
 }
 
-void KdTreeCamera::setEnhancedVisMode(bool enhanced)
-{
-	mEnhancedVisMode = enhanced;
-}
-
-bool KdTreeCamera::getEnhancedVisMode()
-{
-	return mEnhancedVisMode;
-}
-
 //-----------------------------------------------------------------------
 // enhanced vis calculation - borrowed from OctreeCamera - indicate when entire box inside the frustum
 KdTreeCamera::NodeVisibility KdTreeCamera::getVisibilityEnhanced(const AxisAlignedBox& box) const
 {
-	//++ mNumVisQueries;
+	++ mNumVisQueries;
+	
 	// Null boxes always invisible
 	if ( box.isNull() )
@@ -98,5 +88,5 @@
 KdTreeCamera::NodeVisibility KdTreeCamera::getVisibilitySimple(const AxisAlignedBox& box) const
 {
-	//++ mNumVisQueries;
+	++ mNumVisQueries;
 
 	// dummy
@@ -112,16 +102,3 @@
 }
 
-//KdTreeCamera::NodeVisibility KdTreeCamera::getVisibility(const AxisAlignedBox& box) const
-//{
-//	// dummy
-//	FrustumPlane* culledBy = 0;
-//	if (mCullFrustum)
-//	{
-//		return mCullFrustum->isVisible(box, culledBy) ? KDNV_PART : KDNV_NONE;
-//	}
-//	else
-//	{
-//		return Frustum::isVisible(box, culledBy) ? KDNV_PART : KDNV_NONE;
-//	}
-//}
 } // namespace Ogre
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp	(revision 1304)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp	(revision 1312)
@@ -44,5 +44,5 @@
 mLeavePassesInQueue(0),
 mDelayRenderTransparents(true),
-mUseDepthPass(true),
+mUseDepthPass(false),
 mIsDepthPassPhase(false),
 mUseItemBuffer(false),
@@ -462,12 +462,69 @@
 	}
 	// vis options
+	else if (strKey == "NumFrustumCulledNodes")
+	{
+		if (mRenderMethod == KdTree::KDRM_INTERNAL)
+		{
+			unsigned int numnodes = 0;
+			if (mKdTree)
+				numnodes = mKdTree->getFramesStats().mFrustumCulledNodes;
+
+			* static_cast<unsigned int *>(pDestValue) = (unsigned int)numnodes;
+			return true;
+		}
+		// otherwise let fall through to VisibilityOptionsManager
+	}
+	else if (strKey == "NumQueryCulledNodes")
+	{
+		if (mRenderMethod == KdTree::KDRM_INTERNAL)
+		{
+			* static_cast<unsigned int *>(pDestValue) = 0;
+			return true;
+		}
+		// otherwise let fall through to VisibilityOptionsManager
+	}
 	else if (strKey == "NumHierarchyNodes")
 	{
 		unsigned int numnodes = 0;
 		if (mKdTree)
-			numnodes = mKdTree->getStats().mNumNodes;
+			numnodes = mKdTree->getTreeStats().mNumNodes;
 
 		* static_cast<unsigned int *>(pDestValue) = (unsigned int)numnodes;
 		return true;
+	}
+	else if (strKey == "NumRenderedNodes")
+	{
+		if (mRenderMethod == KdTree::KDRM_INTERNAL)
+		{
+			unsigned int numnodes = 0;
+			if (mKdTree)
+				numnodes = mKdTree->getFramesStats().mRenderedNodes;
+
+			* static_cast<unsigned int *>(pDestValue) = (unsigned int)numnodes;
+			return true;
+		}
+		// otherwise let fall through to VisibilityOptionsManager
+	}
+	else if (strKey == "NumQueriesIssued")
+	{
+		if (mRenderMethod == KdTree::KDRM_INTERNAL)
+		{
+			* static_cast<unsigned int *>(pDestValue) = 0;
+			return true;
+		}
+		// otherwise let fall through to VisibilityOptionsManager
+	}
+	else if (strKey == "NumTraversedNodes")
+	{
+		if (mRenderMethod == KdTree::KDRM_INTERNAL)
+		{
+			unsigned int numnodes = 0;
+			if (mKdTree)
+				numnodes = mKdTree->getFramesStats().mTraversedNodes;
+
+			* static_cast<unsigned int *>(pDestValue) = (unsigned int)numnodes;
+			return true;
+		}
+		// otherwise let fall through to VisibilityOptionsManager
 	}
 	else if (strKey == "VisibilityManager")
@@ -1357,5 +1414,5 @@
 		<< "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", "
 		<< "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", "
-		<< "Hierarchy nodes: " << (mKdTree ? mKdTree->getStats().mNumNodes : 0) << ", " 
+		<< "Hierarchy nodes: " << (mKdTree ? mKdTree->getTreeStats().mNumNodes : 0) << ", " 
 		<< "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", "
 		<< "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", "
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp	(revision 1296)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp	(revision 1312)
@@ -877,5 +877,5 @@
 	unsigned long t1, t2, t3, t4;
 
-	mStats.clear();
+	mTreeStats.clear();
 	
 	// data we want to collect
@@ -890,5 +890,5 @@
 	t3 = timer->getMicroseconds(); // DEBUG
 
-	mStats.mNumSceneNodes = nObjects;
+	mTreeStats.mNumSceneNodes = nObjects;
 
 	assert(! aabb.isNull() && "Teh stubid worldAABB iz NULL ... waht now?");
@@ -924,7 +924,7 @@
 	mBuildLog->logMessage("Total time: " + StringConverter::toString(t4 - t1) + "µs");
 	mBuildLog->logMessage("Tree Depth: " + StringConverter::toString(mMaxDepth));
-	mBuildLog->logMessage("Number of Objects: " + StringConverter::toString(mStats.mNumSceneNodes));
-	mBuildLog->logMessage("Number of Leaves: " + StringConverter::toString(mStats.mNumLeaves));
-	mBuildLog->logMessage("Number of Nodes: " + StringConverter::toString(mStats.mNumNodes));
+	mBuildLog->logMessage("Number of Objects: " + StringConverter::toString(mTreeStats.mNumSceneNodes));
+	mBuildLog->logMessage("Number of Leaves: " + StringConverter::toString(mTreeStats.mNumLeaves));
+	mBuildLog->logMessage("Number of Nodes: " + StringConverter::toString(mTreeStats.mNumNodes));
 	mBuildLog->logMessage("Total cost: " + StringConverter::toString(calcCost()));
 	mBuildLog->logMessage("################################");
@@ -1044,6 +1044,6 @@
 		}
 		// update stats
-		++ mStats.mNumNodes;
-		++ mStats.mNumLeaves;
+		++ mTreeStats.mNumNodes;
+		++ mTreeStats.mNumLeaves;
 		// update bounding box
 		leaf->_updateBounds(false);
@@ -1128,5 +1128,5 @@
 
 		// update stats
-		++ mStats.mNumNodes;
+		++ mTreeStats.mNumNodes;
 
 		// update bounding box
@@ -1196,6 +1196,6 @@
 				topNode = leaf;
 			// update stats
-			++ mStats.mNumNodes;
-			++ mStats.mNumLeaves;
+			++ mTreeStats.mNumNodes;
+			++ mTreeStats.mNumLeaves;
 		}
 
@@ -1310,5 +1310,5 @@
 
 			// update stats
-			++ mStats.mNumNodes;
+			++ mTreeStats.mNumNodes;
 		}
 
@@ -1399,6 +1399,6 @@
 	bool showBoxes, KdTree::NodeList& visibleNodes)
 {
-	// debug
-	//cam->mNumVisQueries = 0;
+	mFrameStats.clear();
+	cam->mNumVisQueries = 0;
 
 	if (mKdRoot)
@@ -1406,6 +1406,5 @@
 			cam, queue, onlyShadowCasters, showBoxes, visibleNodes);
 
-	//mBuildLog->logMessage("Frame # " + StringConverter::toString(Root::getSingleton().getCurrentFrameNumber()) +
-	//	" ," + StringConverter::toString(cam->mNumVisQueries) + " vis queries");
+	mFrameStats.mTraversedNodes = cam->mNumVisQueries;
 }
 
@@ -1420,10 +1419,13 @@
 	if (fullVis || 
 		((vis = (cam->*getVisibility)(node->mAABB)) != KdTreeCamera::KDNV_NONE))
-		//((vis = (cam->*getVisibility)(node->mAABB)) != KdTreeCamera::KDNV_NONE))
 	{
 		visibleNodes.push_back(node);
 
 		bool v = (fullVis || vis == KdTreeCamera::KDNV_FULL);
+
 		node->queueVisibleObjects(currentFrame, cam, queue, onlyShadowCasters, showBoxes, v);
+
+		if (v || node->isLeaf())
+			++ mFrameStats.mRenderedNodes;
 
 		if (!v)
@@ -1437,4 +1439,8 @@
 				cam, queue, onlyShadowCasters, showBoxes, visibleNodes, v);
 		}
+	}
+	else
+	{
+		++ mFrameStats.mFrustumCulledNodes;
 	}
 }
