Index: trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
===================================================================
--- trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h	(revision 133)
+++ trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h	(revision 139)
@@ -90,5 +90,8 @@
 	/** Fills render queue so that a visualization can be rendered. 
 	*/
-	void ShowVisualization(Camera *cam);
+	void PrepareVisualization(Camera *cam);
+	
+	void InitVisibilityCulling(Camera *cam);
+
 
 	OctreeHierarchyInterface *mHierarchyInterface;
@@ -96,5 +99,4 @@
 
 	bool mShowVisualization;
-	bool mSkipTransparents;
 	bool mVisualizeCulledNodes;
 
@@ -106,4 +108,5 @@
 	bool mRenderItemBuffer;
 	bool mEnableDepthWrite;
+	bool mSkipTransparents;
 
 	Pass *mDepthPass;
@@ -113,4 +116,7 @@
 
 	PlatformQueryManager *mQueryManager;
+
+	int mLeavePassesInQueue;
+	ShadowTechnique mSavedShadowTechnique;
 };
 
Index: trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
===================================================================
--- trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h	(revision 130)
+++ trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h	(revision 139)
@@ -67,5 +67,5 @@
 	
 	/** Prepares visualization of hierarchical culling. */
-	void ShowVisualization(Camera *cam);
+	void PrepareVisualization(Camera *cam);
 	OctreeHierarchyInterface *mHierarchyInterface;
 	GtpVisibility::VisibilityManager *mVisibilityManager;
Index: trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
===================================================================
--- trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h	(revision 130)
+++ trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h	(revision 139)
@@ -53,5 +53,5 @@
 	*/
 	void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL, 
-		bool leaveTransparentsInQueue = false);
+		int leavePassesInQueue = 0);
 	/** Checks if the node is visible from the current view frustum.
 		@param node the current node
@@ -162,5 +162,5 @@
 
 	bool mOnlyShadowCasters;
-	bool mLeaveTransparentsInQueue;
+	int mLeavePassesInQueue;
 	bool mIsBoundingBoxQuery;
 };
Index: trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp	(revision 130)
+++ trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp	(revision 139)
@@ -19,5 +19,5 @@
 void SceneNodeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node)
 {
-	mNumTraversedNodes ++;
+	++ mNumTraversedNodes;
 	
 	SceneNode *sceneNode = static_cast<SceneNode *>(node);
@@ -47,5 +47,5 @@
 		mRenderedNodes.push_back(node);
 
-		mSceneManager->_renderSceneNode(mCamera, sceneNode, mLeaveTransparentsInQueue);
+		mSceneManager->_renderSceneNode(mCamera, sceneNode, mLeavePassesInQueue);
 	}
 #endif
@@ -151,6 +151,5 @@
 		{
 			Entity *ent = static_cast<Entity *>(movable);
-			//std::stringstream d; d << "ent " << ent->getName(); 
-			//LogManager::getSingleton().logMessage(d.str());
+			//std::stringstream d; d << "ent " << ent->getName(); LogManager::getSingleton().logMessage(d.str());
 			geometryList->push_back(ent);
 		}
Index: trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 137)
+++ trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 139)
@@ -21,10 +21,12 @@
 mRenderNodesContentForViz(false),
 mVisualizeCulledNodes(false),
-mSkipTransparents(false),
+mLeavePassesInQueue(0),
 mDelayRenderTransparents(true),
 mUseDepthPass(false),
 mRenderItemBuffer(false),
 mCurrentEntityId(0),
-mEnableDepthWrite(true)
+mEnableDepthWrite(true),
+mSkipTransparents(false),
+mSavedShadowTechnique(SHADOWTYPE_NONE)
 {
 	mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem);
@@ -32,4 +34,5 @@
 
 	mVisibilityManager->SetQueryManager(mQueryManager);
+	
 	//mDisplayNodes = true;
 	//mShowBoundingBoxes = true;
@@ -97,5 +100,5 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::ShowVisualization(Camera *cam)
+void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam)
 {
 	// add player camera for visualization purpose
@@ -128,8 +131,11 @@
 			if (mRenderNodesForViz)
 			{
-				//getRenderQueue()->addRenderable(*it);
+				OctreeNode *node = *it;	
+				if ((node->numAttachedObjects() > 0) && (node->numChildren() == 0)
+					&& node->getAttachedObject(0)->getMovableType() == "Entity")
+				getRenderQueue()->addRenderable(node);
 
 				// addbounding boxes instead of node itself
-				(*it)->_addBoundingBoxToQueue(getRenderQueue());
+				//(*it)->_addBoundingBoxToQueue(getRenderQueue());
 			}
 			if (mRenderNodesContentForViz) 
@@ -143,5 +149,6 @@
 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass)
 {
-	//Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); // setting vertex program is not efficient
+	// TODO: setting vertex program is not efficient
+	//Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); 
 	
 	// set depth fill pass only if depth write enabled
@@ -182,4 +189,5 @@
 
 	bool IsDepthWrite = usedPass->getDepthWriteEnabled();
+
 	// global option which enables / disables depth writes
 	if (!mEnableDepthWrite)
@@ -187,5 +195,4 @@
 		usedPass->setDepthWriteEnabled(false);
 	}
-
 	//else if (mIsItemBufferPass) {usedPass = mItemBufferPass;}
 	
@@ -207,120 +214,106 @@
 {
 	// needs full ambient lighting for item colors to be exact
-	/*if (mRenderItemBuffer)
-	{	setAmbientLight(ColourValue(1,1,1,1)); }*/
+	//if (mRenderItemBuffer) {setAmbientLight(ColourValue(1,1,1,1));}
 	
 	//-- show visible scene nodes and octree bounding boxes from last frame
 	if (mShowVisualization)
     {
-		ShowVisualization(cam);
-	}
-	
+		PrepareVisualization(cam);
+	}
+	else
+	{	
+		// we interleave identification and rendering of objects 
+		// in _renderVisibibleObjects
+
+		// only shadow casters will be rendered in shadow texture pass
+		mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
+		//InitVisibilityCulling(cam);
+	}
 	//TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
 	
 	mVisible.clear();
 	mBoxes.clear();
-	
-	// if there is no depth pass =>
-	// we interleave identification and rendering of objects 
-	// in _renderVisibibleObjects
-
-	// only shadow casters will be rendered in shadow texture pass
-	mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
-
-	bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass;
-
-	// possible two cameras (one for culling, one for rendering)
-	mHierarchyInterface->InitFrame(mOctree, cam, //mCameraInProgress, 
-						mCullCamera ? getCamera("CullCamera") : NULL,
-						leaveTransparentsInQueue);
+
 }
 //-----------------------------------------------------------------------
 void VisibilityTerrainSceneManager::_renderVisibleObjects()
 {
-	// increase terrain renderlevel
-	int renderLevel = TerrainRenderable::getCurrentRenderLevelIndex() + 1;
-
-	if (TerrainRenderable::getCurrentRenderLevelIndex() >= 10)
-	{   // max. 10 different renderlevels
-		renderLevel = 0;
-	}
-
 	// visualization: apply standard rendering
 	if (mShowVisualization)
 	{	
+		IlluminationRenderStage savedStage = mIlluminationStage; 
+	
+		// disable illumination stage so we have no shadow rendering
+		mIlluminationStage = IRS_NONE;
+	
 		TerrainSceneManager::_renderVisibleObjects();
-		TerrainRenderable::setCurrentRenderLevelIndex(renderLevel);
-		return;
-	}
-
-	InitDepthPass(); 	// create material for depth pass
-	InitItemBufferPass(); // create material for item buffer pass
-
-	//-- hierarchical culling
-	// the objects of different layers (e.g., background, scene, 
-	// overlay) must be identified and rendered one after another
-
-	// frame initialisation to reset culling manager stats
-	mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes);
-	
-	mSkipTransparents = false;
-
-	//-- render background, in case there is one
-	clearSpecialCaseRenderQueues();
-	addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
-	addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
-	setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
-
-	TerrainSceneManager::_renderVisibleObjects();
+	}
+	else
+	{
+		//-- hierarchical culling
+		// the objects of different layers (e.g., background, scene, 
+		// overlay) must be identified and rendered one after another
+
+		//-- render all early skies
+		clearSpecialCaseRenderQueues();
+		addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
+		addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
+		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
+
+		TerrainSceneManager::_renderVisibleObjects();
 
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups(false);
+		_deleteRenderedQueueGroups();
 #endif
 
-	//-- render visible objects (i.e., all but overlay and skies late)
-	clearSpecialCaseRenderQueues();
-	addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE);
-	addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
-	setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
-
-	// transparents are skipped from hierarchical rendering
-	// => they need sorting, thus we render them afterwards
-	mSkipTransparents = mDelayRenderTransparents;
-
-	// set state for depth pass
-    mRenderDepthPass = mUseDepthPass;
-	
-	/** 
-	  * the hierarchical culling algorithm
-	  * for depth pass: will just find objects and update depth buffer
-	  * for delayed rendering: will render all but transparents
-	**/
-	
-	mVisibilityManager->ApplyVisibilityCulling();
-
-	// delete remaining renderables from queue (or all but transparents)
+		//-- prepare queue for visible objects (i.e., all but overlay and skies late)
+		clearSpecialCaseRenderQueues();
+		addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE);
+		addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
+		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
+
+
+		//-- set all necessary parameters for hierarchical visibility culling and rendering
+		InitVisibilityCulling(mCameraInProgress);
+
+		/** 
+		* the hierarchical culling algorithm
+		* if using depth pass: will just find objects and update depth buffer
+		* for "delayed" rendering: will render some passes afterwards, e.g. transparents
+		**/
+		
+		mVisibilityManager->ApplyVisibilityCulling();
+
+		// delete remaining renderables from queue (all not in mLeavePassesInQueue)
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups(mSkipTransparents);
+		_deleteRenderedQueueGroups(mLeavePassesInQueue);
 #endif
 
-	// for depth pass: add visible nodes found with the visibility culling
-	if (mUseDepthPass)
-	{
-		for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
-		{
-			(*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false);
-		}
+		//-- reset parameters
 		mRenderDepthPass = false;
-	}
-
-	mSkipTransparents = false;
-
-	//-- now we can render all remaining queue objects
-	// for depth pass: all
-	// for delayed rendering: transparents, overlay 
-	clearSpecialCaseRenderQueues();
-	TerrainSceneManager::_renderVisibleObjects();
-
-	TerrainRenderable::setCurrentRenderLevelIndex(renderLevel);
+		mSkipTransparents = false;
+		mLeavePassesInQueue = 0;
+		mShadowTechnique = mSavedShadowTechnique;
+
+
+		// add visible nodes found by the visibility culling algorithm
+		if (mUseDepthPass)
+		{
+			for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
+			{
+				(*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false);
+			}
+		}
+		
+		//-- now we can render all remaining queue objects
+		// for depth pass, transparents, overlay 
+		clearSpecialCaseRenderQueues();
+		TerrainSceneManager::_renderVisibleObjects();
+	}
+		
+	// set the new render level index afterwards => new level in the next frame 
+	TerrainRenderable::setCurrentRenderLevelIndex(
+		(TerrainRenderable::getCurrentRenderLevelIndex() + 1) % 10);
+
 	getRenderQueue()->clear();
 	//WriteLog(); // write out stats
@@ -346,5 +339,5 @@
 		return true;
 	}
-	if (key == "ShowVisualization")
+	if (key == "PrepareVisualization")
 	{
 		mShowVisualization = (*static_cast<const bool *>(val));
@@ -453,6 +446,7 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 
-            bool doLightIteration, const LightList* manualLightList)
+void VisibilityTerrainSceneManager::renderObjects(
+	const RenderPriorityGroup::TransparentRenderablePassList& objs, 
+    bool doLightIteration, const LightList* manualLightList)
 {
 	// for correct rendering, transparents must be rendered after hierarchical culling
@@ -519,12 +513,8 @@
 			std::stringstream d; d << "itembuffer, pass name: " << 
 				ipass->first->getParent()->getParent()->getName();
-				//<< ", renderable name: " << irend->
-
+				
 			LogManager::getSingleton().logMessage(d.str());
 			
-			//if(ipass->first->getParent()->getParent()->getName() == "Examples/Athene")
-				//<< ", renderable name: " << irend->
-				RenderSingleObjectForItemBuffer(*irend, ipass->first);
-				//RenderSingleObjectForOcclusionQuery(
+			RenderSingleObjectForItemBuffer(*irend, ipass->first);
 		}
 	}
@@ -556,6 +546,6 @@
 	mItemBufferPass->setAmbient(ColourValue(0, 1, 1));
 	//mItemBufferPass->setDiffuse(ColourValue(0, col, 0));
-//	mItemBufferPass->setSpecular(ColourValue(0, col, 0));
-//	mItemBufferPass->_load();
+    //mItemBufferPass->setSpecular(ColourValue(0, col, 0));
+    //mItemBufferPass->_load();
 
 	// set vertex program of current pass
@@ -579,9 +569,8 @@
 	}
 
-	//LogManager::getSingleton().logMessage("has vertex program");
 	Pass *usedPass = setPass(mItemBufferPass); 
 	//Pass *usedPass = setPass(pass);
-	std::stringstream d;
-	d << "item buffer id: " << rend->getId() << ", col: " << col;
+	
+	std::stringstream d; d << "item buffer id: " << rend->getId() << ", col: " << col;
 	LogManager::getSingleton().logMessage(d.str());
 
@@ -607,4 +596,94 @@
 	return ent;
 }
-
+//-----------------------------------------------------------------------
+void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam)
+{
+	InitDepthPass(); 	  // create material for depth pass
+	InitItemBufferPass(); // create material for item buffer pass
+
+	// save shadow technique so after first pass it can be reset
+	mSavedShadowTechnique = mShadowTechnique;
+
+
+	// set passes which should be stored in render queue for rendering afterwards
+	mLeavePassesInQueue = 0;
+	
+/*	if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE)
+	{
+		mShadowTechnique = SHADOWTYPE_NONE;
+
+		if (!mUseDepthPass)
+		{
+			// TODO: remove this
+			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW;
+
+			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DECAL;
+			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DIFFUSE_SPECULAR;
+			mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
+		}
+	}
+	if (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE)
+	{
+		mShadowTechnique = SHADOWTYPE_NONE;
+
+		if (!mUseDepthPass)
+		{
+			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW;
+			mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
+		}
+	}
+	*/
+	if (mDelayRenderTransparents && (!mUseDepthPass))
+	{
+		mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
+	}
+	std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;
+	LogManager::getSingleton().logMessage(d.str());
+
+	// possible two cameras (one for culling, one for rendering)
+	mHierarchyInterface->InitFrame(mOctree, cam, 
+						mCullCamera ? getCamera("CullCamera") : NULL,
+						mLeavePassesInQueue);
+		
+	
+	// reset culling manager stats
+	mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes);
+
+	// set depth pass flag before rendering
+    mRenderDepthPass = mUseDepthPass;
+	
+	// set flag for skipping transparents for this rendering pass
+	mSkipTransparents = mUseDepthPass || (mLeavePassesInQueue & 
+		RenderPriorityGroup::TRANSPARENT_PASSES);
+}
+
+//-----------------------------------------------------------------------
+/*void VisibilityTerrainSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup)
+{
+    // Basic render loop
+    // Iterate through priorities
+    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
+
+    while (groupIt.hasMoreElements())
+    {
+        RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
+
+        // Sort the queue first
+        pPriorityGrp->sort(mCameraInProgress);
+
+		//TODO: render other splid passes for shadows
+        // Do solids
+        renderObjects(pPriorityGrp->_getSolidPassesNoShadows(), true);
+
+		// do solid passes no shadows if addititive stencil shadows
+		if (mSavedShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE)
+			renderObjects(pPriorityGrp->_getSolidPassesNoShadows(), true);
+		
+        // Do transparents
+        renderObjects(pPriorityGrp->_getTransparentPasses(), true);
+
+
+    }// for each priority
+}
+*/
 } // namespace Ogre
Index: trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp	(revision 115)
+++ trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp	(revision 139)
@@ -43,5 +43,5 @@
 		mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress);
 
-		// call initframe to reset culling manager stats
+		// reset culling manager stats
 		mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes);
 	}
@@ -68,5 +68,5 @@
 
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups(false);
+	_deleteRenderedQueueGroups();
 #endif
 
@@ -84,5 +84,5 @@
 
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	//_deleteRenderedQueueGroups();
+	_deleteRenderedQueueGroups();
 #endif
 
Index: trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp	(revision 135)
+++ trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp	(revision 139)
@@ -16,5 +16,5 @@
 void OctreeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node)
 {
-	mNumTraversedNodes ++;
+	++ mNumTraversedNodes;
 
 	Octree *octree = static_cast<Octree *>(node);
@@ -107,5 +107,5 @@
 
 		dynamic_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, 
-			octant, mOnlyShadowCasters, mLeaveTransparentsInQueue);
+			octant, mOnlyShadowCasters, mLeavePassesInQueue);
 
 		mRenderedNodes.push_back(node);
@@ -134,9 +134,10 @@
 AxisAlignedBox *OctreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node)
 {
-	if(node != mPreviousNode)
+	if (node != mPreviousNode)	
 	{
 		mPreviousNode = node;
-	//	static_cast<Octree *>(node)->_getCullBounds(&mBox);
+	    //static_cast<Octree *>(node)->_getCullBounds(&mBox);
 		mBox = static_cast<Octree *>(node)->_getWorldAABB();
+		//std::stringstream d; d << mBox;LogManager::getSingleton().logMessage(d.str()); 
 	}
 
Index: trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp	(revision 122)
+++ trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp	(revision 139)
@@ -21,7 +21,7 @@
 mRenderNodesContentForViz(false),
 mVisualizeCulledNodes(false),
-mSkipTransparents(false),
 mDelayRenderTransparents(true),
-mUseDepthPass(true)
+mUseDepthPass(true),
+mSkipTransparents(false)
 {
 	mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem);
@@ -101,8 +101,9 @@
 }
 //-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::ShowVisualization(Camera *cam)
+void VisibilityOctreeSceneManager::PrepareVisualization(Camera *cam)
 {
 	// add player camera for visualization purpose
-	try {
+	try 
+	{
 		Camera *c;
 		if ((c = getCamera("PlayerCam")) != NULL)
@@ -129,5 +130,4 @@
 		for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
 		{
-
 			if (mRenderNodesForViz)
 			{
@@ -150,5 +150,5 @@
 	if (mShowVisualization)
     {
-		ShowVisualization(cam);
+		PrepareVisualization(cam);
 	}
 	else 
@@ -189,5 +189,5 @@
 							leaveTransparentsInQueue);
 
-	// call initframe to reset culling manager stats
+	// reset culling manager stats
 	mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes);
 	
@@ -204,5 +204,5 @@
 
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups(false);
+	_deleteRenderedQueueGroups();
 #endif
 
@@ -272,5 +272,5 @@
 		return true;
 	}
-	if (key == "ShowVisualization")
+	if (key == "PrepareVisualization")
 	{
 		mShowVisualization = (*static_cast<const bool *>(val));
Index: trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp	(revision 135)
+++ trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp	(revision 139)
@@ -13,5 +13,5 @@
 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys):
 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), mCamera(NULL), 
-mCullCamera(NULL), mOnlyShadowCasters(false), mLeaveTransparentsInQueue(false),
+mCullCamera(NULL), mOnlyShadowCasters(false), mLeavePassesInQueue(0),
 mIsBoundingBoxQuery(false)
 {
@@ -131,16 +131,13 @@
 //-----------------------------------------------------------------------
 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, 
-										   Camera *cam, Camera *cullCam, bool leaveTransparentsInQueue)
+										   Camera *cam, Camera *cullCam, int leavePassesInQueue)
 {
 	GtpVisibility::HierarchyInterface::InitFrame(root);
 	
 	mPreviousNode = NULL;
-	mLeaveTransparentsInQueue = leaveTransparentsInQueue;
+	mLeavePassesInQueue = leavePassesInQueue;
 
 	mCamera = cam;
 	mCullCamera = cullCam ? cullCam : cam;
-
-	//if (mCullCamera != mCamera)
-	//	LogManager::getSingleton().logMessage("cullcamera is not camera");
 
 	// create materials for node visualization
@@ -268,5 +265,5 @@
 void PlatformHierarchyInterface::RenderGeometry(GtpVisibility::Mesh *geom)
 {
-	mSceneManager->_renderMovableObject(geom, mLeaveTransparentsInQueue);
+	mSceneManager->_renderMovableObject(geom, mLeavePassesInQueue);
 }
 //-----------------------------------------------------------------------
