Index: trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp	(revision 202)
+++ trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp	(revision 254)
@@ -9,5 +9,5 @@
 #include <OgreEntity.h>
 #include <OgreSubEntity.h>
-
+#include <OgreConfigFile.h>
 
 namespace Ogre {
@@ -24,9 +24,11 @@
 mLeavePassesInQueue(0),
 mDelayRenderTransparents(true),
+//mDelayRenderTransparents(false),
+//mUseDepthPass(true),
 mUseDepthPass(false),
-mRenderDepthPass(false),
+mIsDepthPassPhase(false),
 mUseItemBuffer(false),
 //mUseItemBuffer(true),
-mRenderItemBuffer(false),
+mIsItemBufferPhase(false),
 mCurrentEntityId(1),
 mEnableDepthWrite(true),
@@ -44,4 +46,6 @@
 	// TODO: set maxdepth to reasonable value
 	mMaxDepth = 50;
+
+	//loadVisibilityConfig("GtpVisibility.cfg");
 }
 //-----------------------------------------------------------------------
@@ -145,5 +149,5 @@
 {
 	// set depth fill pass if we currently do not make an aabb occlusion query
-	Pass *usedPass = (mRenderDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ? 
+	Pass *usedPass = (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery() ? 
 					  mDepthPass : pass);
 
@@ -152,5 +156,5 @@
 	// set illumination stage to NONE so no shadow material is used 
 	// for depth pass or for occlusion query
-	if (mRenderDepthPass || mHierarchyInterface->IsBoundingBoxQuery())
+	if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery())
 	{
 		mIlluminationStage = IRS_NONE;
@@ -158,5 +162,5 @@
 
 	//-- set vertex program of current pass in order to set correct depth
-	if (mRenderDepthPass && mExecuteVertexProgramForAllPasses && pass->hasVertexProgram())
+	if (mIsDepthPassPhase && mExecuteVertexProgramForAllPasses && pass->hasVertexProgram())
     {
 		// add vertex program of current pass to depth pass
@@ -311,6 +315,6 @@
 
 		//-- reset parameters
-		mRenderDepthPass = false;
-		mRenderItemBuffer = false;
+		mIsDepthPassPhase = false;
+		mIsItemBufferPhase = false;
 		mSkipTransparents = false;
 		mIsHierarchicalCulling = false;
@@ -498,5 +502,5 @@
 {
 	// skip all but first pass if we are doing the depth pass
-	if ((mRenderDepthPass || mRenderItemBuffer) && pass->getIndex() > 0)
+	if ((mIsDepthPassPhase || mIsItemBufferPhase) && pass->getIndex() > 0)
 	{
 		return false;
@@ -507,5 +511,5 @@
 void VisibilityOctreeSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup)
 {
-	if (!mRenderItemBuffer)
+	if (!mIsItemBufferPhase)
 	{
 		OctreeSceneManager::renderQueueGroupObjects(pGroup);
@@ -513,5 +517,5 @@
 	}
 
-	// --- item buffer
+	//-- renders item buffer
 
     // Iterate through priorities
@@ -559,5 +563,5 @@
 	}
 
-	// -- TRANSPARENT LOOP: must be handled differently 
+	//-- TRANSPARENT LOOP: must be handled differently 
 
 	// transparents are treated either as solids or completely discarded
@@ -637,5 +641,5 @@
 
 	// set depth pass flag before rendering
-	mRenderDepthPass = mUseDepthPass;
+	mIsDepthPassPhase = mUseDepthPass;
 
 	mIsHierarchicalCulling = true; // during hierarchical culling
@@ -644,5 +648,5 @@
 	if (mUseItemBuffer) 
 	{
-		mRenderItemBuffer = true;
+		mIsItemBufferPhase = true;
 		setAmbientLight(ColourValue(1,1,1,1));
 	}
@@ -739,67 +743,7 @@
 		}
 	}
-	else
+	else // render the rest of the passes
 	{
 		OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup);
-
-		/*RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-	    LightList lightList;
-		
-		while (groupIt.hasMoreElements())
-		{
-		
-			RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
-
-			// Sort the queue first
-			pPriorityGrp->sort(mCameraInProgress);
-
-			// Clear light list
-			lightList.clear();
-
-			// Now iterate per light
-			mIlluminationStage = IRS_PER_LIGHT;
-	
-		    // Iterate over lights, render all volumes to stencil
-	        LightList::const_iterator li, liend;
-		    liend = mLightsAffectingFrustum.end();
-	
-		    for (li = mLightsAffectingFrustum.begin(); li != liend; ++li)
-			{
-				LogManager::getSingleton().logMessage("iterating over lights");
-				Light* l = *li;
-				// Set light state
-
-				if (l->getCastShadows())
-				{
-					// Clear stencil
-					mDestRenderSystem->clearFrameBuffer(FBT_STENCIL);
-					renderShadowVolumesToStencil(l, mCameraInProgress);
-					// turn stencil check on
-					mDestRenderSystem->setStencilCheckEnabled(true);
-					// NB we render where the stencil is equal to zero to render lit areas
-					mDestRenderSystem->setStencilBufferParams(CMPF_EQUAL, 0);
-				}
-
-				// render lighting passes for this light
-				if (lightList.empty())
-					lightList.push_back(l);
-				else
-					lightList[0] = l;
-				OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPassesDiffuseSpecular(), false, &lightList);
-
-				// Reset stencil params
-				mDestRenderSystem->setStencilBufferParams();
-				mDestRenderSystem->setStencilCheckEnabled(false);
-				mDestRenderSystem->_setDepthBufferParams();
-
-			}// for each light
-
-			// Now render decal passes, no need to set lights as lighting will be disabled
-			mIlluminationStage = IRS_DECAL;
-			OctreeSceneManager::renderObjects(pPriorityGrp->_getSolidPassesDecal(), false);
-	    }// for each priority
-	
-		// reset lighting stage
-	    mIlluminationStage = IRS_NONE;*/
 	}
 }
@@ -828,3 +772,26 @@
    }
 }
-}   // namespace Ogre
+//-------------------------------------------------------------------------
+void VisibilityOctreeSceneManager::loadVisibilityConfig(const String& filename)
+{
+	/// Set up the options
+	ConfigFile config;
+	String val;
+
+	config.load(filename);
+
+	val = config.getSetting("Algorithm");
+
+    if (!val.empty())
+	{
+		 VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).setOption("Algorithm", val.c_str());
+	}
+
+	val = config.getSetting("UseDepthPass");
+
+	if (!val.empty())
+	{
+		 setOption("UseDepthPass", val.c_str());
+	}
+}
+}  // namespace Ogre
