Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 2121)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp	(revision 2145)
@@ -162,5 +162,6 @@
 mViewCellsLoaded(false),
 mUseVisibilityFilter(false),
-mFloorDist(2)
+mFloorDist(2),
+mFlushQueue(false)
 {
 	//mInputDevice = PlatformManager::getSingleton().createInputReader();
@@ -261,6 +262,19 @@
 	setTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves);
 
-	mSceneMgr->setOption("UseDepthPass", &mUseDepthPass);
-	
+	//mSceneMgr->setOption("UseDepthPass", &mUseDepthPass);
+	mSceneMgr->getOption("UseDepthPass", &mUseDepthPass);
+
+	if (mUseDepthPass)
+		mUseDepthPassInfo->setCaption(": true");
+	else
+		mUseDepthPassInfo->setCaption(": false");
+	
+	mSceneMgr->getOption("FlushQueue", &mFlushQueue);
+	
+	if (mFlushQueue)
+		LogManager::getSingleton().logMessage("initial setting: flushing queue");
+	else
+		LogManager::getSingleton().logMessage("initial setting: not flushing queue");
+
 	mSceneMgr->setOption("ShowOctree", &mShowOctree);
 	mSceneMgr->setOption("ShowViewCells", &mShowViewCells);
@@ -1289,4 +1303,23 @@
 }
 //-----------------------------------------------------------------------
+void TerrainFrameListener::toggleFlushQueue()
+{
+	mFlushQueue = !mFlushQueue;
+
+	mSceneMgr->setOption("FlushQueue", &mFlushQueue);
+	
+	if (mFlushQueue)
+	{
+		LogManager::getSingleton().logMessage("flushing queue");
+		//mFlushQueueInfo->setCaption(": true");
+	}
+	else
+	{
+		LogManager::getSingleton().logMessage("not flushing queue");
+		//mFlushQueueInfo->setCaption(": false");
+	}
+}
+
+//-----------------------------------------------------------------------
 void TerrainFrameListener::toggleShowViz()
 {
@@ -1363,4 +1396,12 @@
 	switch(e->getKey())
 	{
+	
+	case KC_SUBTRACT:
+		changeThreshold(-10);
+		break;
+	case KC_ADD:
+		changeThreshold(10);
+		break;
+
 	case KC_ESCAPE:
 		mShutdownRequested = true;
@@ -1371,38 +1412,12 @@
 		nextAlgorithm();
 		break;
-	
-    case KC_F:
-		nextFilter();
-		break;
-	case KC_R:
-		nextSceneDetailLevel();
-		break;
-	case KC_P:
-		toggleDisplayCameraDetails();
-		break;
-	case KC_G:
-		mTestGeometryForVisibleLeaves = !mTestGeometryForVisibleLeaves;
-		setTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves);
-		break;
-	case KC_T:
-		toggleShowOctree();
-		break;
-	case KC_X:
-		toggleUseDepthPass();
-		break;
-	case KC_H:
-		toggleShowShadows();
-		break;
-
-	case KC_I:
-		mUseItemBuffer = !mUseItemBuffer;
-		break;
-	case KC_Z:
-		mCamNode->resetOrientation();
-		break;
-	case KC_U:
-		mCamNode->resetOrientation();
-		mCamNode->setPosition(mApplication->mInitialPosition);
-		break;
+
+	case KC_LSHIFT:
+		mShiftPressed = true;
+		break;
+	case KC_DELETE:
+		mDeleteObjects = true;
+		break;
+
 	case KC_C:
 		if (mItemBufferMode != GtpVisibility::QueryManager::GEOMETRY_VISIBILITY)
@@ -1415,14 +1430,60 @@
 		}
 		break;
-
-	case KC_SUBTRACT:
-		changeThreshold(-10);
-		break;
-	case KC_ADD:
-		changeThreshold(10);
-		break;
+	 case KC_E: // hack for recording demo using precomputed fps
+		mSavePrecomputedFps = !mSavePrecomputedFps;
+		break;
+
+    case KC_F:
+		nextFilter();
+		break;
+	case KC_G:
+		mTestGeometryForVisibleLeaves = !mTestGeometryForVisibleLeaves;
+		setTestGeometryForVisibleLeaves(mTestGeometryForVisibleLeaves);
+		break;
+	case KC_H:
+		toggleShowShadows();
+		break;
+	case KC_L:
+		toggleShowViewCells();
+		break;
+	case KC_M: // hack for recording demo using precomputed fps
+		mRecordDemo = !mRecordDemo;
+		break;
+   	case KC_O:
+		switchMouseMode();
+		break;
+	case KC_P:
+		toggleDisplayCameraDetails();
+		break;
+	case KC_V:
+		toggleUseViewCells();
+		break;
+	case KC_Q:
+		toggleUseVisibilityFilter();
+		break;
+	case KC_R:
+		nextSceneDetailLevel();
+		break;
+	case KC_T:
+		toggleShowOctree();
+		break;
+	case KC_U:
+		mCamNode->resetOrientation();
+		mCamNode->setPosition(mApplication->mInitialPosition);
+		break;
+	case KC_X:
+		toggleUseDepthPass();
+		break;
+	case KC_I:
+		toggleFlushQueue();
+		break;
+	case KC_Z:
+		mCamNode->resetOrientation();
+		break;
+
 
 	///////////////
 	//-- visualization
+
 	case KC_1:
 		toggleShowViz();
@@ -1431,5 +1492,20 @@
 		nextNodeVizMode();
 		break;
-
+	case KC_7:
+		mTerrainContentGenerator->WriteObjects(objects_out_filename);
+		break;
+	case KC_8:
+		changeAssumedVisibility(-5);
+		// changeAssumedVisibility(-500);
+		break;
+	case KC_9:
+		changeAssumedVisibility(5);
+		// changeAssumedVisibility(500);
+		break;
+
+//#if USE_PERFHUD
+	case KC_F1:
+		toggleShowHelp();
+		break;
 	case KC_F2:
 		mStatsOn = !mStatsOn;
@@ -1441,8 +1517,4 @@
 	case KC_F4:
 		toggleRecord();
-		break;
-//#if USE_PERFHUD
-	case KC_F1:
-		toggleShowHelp();
 		break;
 
@@ -1477,39 +1549,6 @@
 		takeScreenshot();
 		break;
-	case KC_7:
-		mTerrainContentGenerator->WriteObjects(objects_out_filename);
-		break;
-	case KC_8:
-		changeAssumedVisibility(-5);
-		// changeAssumedVisibility(-500);
-		break;
-	case KC_9:
-		changeAssumedVisibility(5);
-		// changeAssumedVisibility(500);
-		break;
-	case KC_LSHIFT:
-		mShiftPressed = true;
-		break;
-	case KC_DELETE:
-		mDeleteObjects = true;
-		break;
-	case KC_M: // hack for recording demo using precomputed fps
-		mRecordDemo = !mRecordDemo;
-		break;
-    case KC_E: // hack for recording demo using precomputed fps
-		mSavePrecomputedFps = !mSavePrecomputedFps;
-		break;
-	case KC_O:
-		switchMouseMode();
-		break;
-	case KC_V:
-		toggleUseViewCells();
-		break;
-	case KC_L:
-		toggleShowViewCells();
-		break;
-	case KC_Q:
-		toggleUseVisibilityFilter();
-		break;
+	
+	
 	//KEY_PRESSED(KC_F3, 0.3, writeFrames());
 	//KEY_PRESSED(KC_F4, 0.3, loadFrames());
Index: /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h
===================================================================
--- /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h	(revision 2108)
+++ /GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h	(revision 2145)
@@ -225,7 +225,11 @@
 	*/
 	void toggleUseDepthPass();
+
+	void toggleFlushQueue();
+
 	/** Toggles whether the visualization is shown.
 	*/
 	void toggleShowViz();
+
 	/** Toggles whether the frames are recorded.
 	*/
@@ -360,4 +364,5 @@
 	bool mShowViewCells;
 	bool mUseDepthPass;
+	bool mFlushQueue;
 	bool mShowVisualization;
 	bool mCullCamera;
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 2123)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h	(revision 2145)
@@ -273,4 +273,7 @@
 
 	bool mShowTerrain;
+
+	int mFlushRate;
+	int mCurrentFrame;
 
 	ObjReader *mObjReader;
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2130)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp	(revision 2145)
@@ -62,5 +62,7 @@
 mShowTerrain(false),
 mViewCellsFilename(""),
-mFilename("terrain")
+mFilename("terrain"),
+mFlushRate(10),
+mCurrentFrame(0)
 {
 	Ogre::LogManager::getSingleton().
@@ -192,4 +194,5 @@
 	String val;
 
+	LogManager::getSingleton().logMessage("****** OcclusionCullingSceneManager Options ********");
 	config.load(stream);
 
@@ -203,4 +206,9 @@
 	}
 
+	if (mUseDepthPass)
+		LogManager::getSingleton().logMessage("using depth");
+	else
+		LogManager::getSingleton().logMessage("not using depth");
+	
 	val = config.getSetting("FlushQueue");
 	
@@ -210,4 +218,9 @@
 	}
 
+	if (mDeleteQueueAfterRendering)
+		LogManager::getSingleton().logMessage("flushing queue");
+	else
+		LogManager::getSingleton().logMessage("not flushing queue");
+	
    	val = config.getSetting("Scene");
 
@@ -382,4 +395,6 @@
 	// set the page source
 	selectPageSource(pageSourceName, optlist);
+
+	LogManager::getSingleton().logMessage("****** Finished OcclusionCullingSceneManager Options ********");
 }
 
@@ -675,5 +690,5 @@
 
 		// for the shadow pass we use only standard rendering
-		// because shadows have low occlusion snyway
+		// because shadows have low occlusion anyway
 		if (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 
 			mIlluminationStage == IRS_RENDER_TO_TEXTURE)
@@ -704,10 +719,6 @@
 void OcclusionCullingSceneManager::_renderVisibleObjects()
 {
-	// $$matt temp: Remove this!!
-	if (0) 
-	{
-		getDestinationRenderSystem()->_setCullingMode(CULL_NONE);
-		//LogManager::getSingleton().logMessage("warning: culling mode");
-	}
+	const bool flushQueue = mDeleteQueueAfterRendering && ((mCurrentFrame % mFlushRate) == 0);
+	++ mCurrentFrame;
 
 	if (mNormalExecution)
@@ -715,5 +726,5 @@
 		// the standard octree rendering mode
 		TerrainSceneManager::_renderVisibleObjects();
-		getRenderQueue()->clear(mDeleteQueueAfterRendering);
+		getRenderQueue()->clear(flushQueue);
 		return;
 	}
@@ -847,5 +858,5 @@
 
 	// almost same effect as below
-	getRenderQueue()->clear(mDeleteQueueAfterRendering);
+	getRenderQueue()->clear(flushQueue);
 
 	if (0) WriteLog(); // write out stats
@@ -935,5 +946,5 @@
 		return true;
 	}
-	else if (key == "DeleteRenderQueue")
+	else if (key == "FlushQueue")
 	{
 		mDeleteQueueAfterRendering = (*static_cast<const bool *>(val));
@@ -1052,4 +1063,9 @@
 		return true;
 	}
+	if (key == "FlushQueue")
+	{
+		* static_cast<bool *>(val) = (bool *)mDeleteQueueAfterRendering;
+		return true;
+	}
 	if (key == "NormalExecution")
 	{
@@ -1062,6 +1078,8 @@
 			mVisibilityManager->GetCullingManagerType();
 
-		* static_cast<unsigned int *>(val) = 
-			(unsigned int)algorithm;
+		* static_cast<unsigned int *>(val) = (unsigned int)algorithm;
+
+		getRenderQueue()->clear(true);
+
 		return true;
 	}
