Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj	(revision 2353)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj	(revision 2532)
@@ -81,5 +81,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 2455)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 2532)
@@ -72,5 +72,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp	(revision 2502)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp	(revision 2532)
@@ -104,5 +104,8 @@
 				if (mHierarchyInterface->IsNodeFullyVisible(node))
 				{
+					int nodesTested = 0;
+
 					// use different algorithm for finding random candidates
+#if 1
 					HierarchyNodeContainer mynodes;
 					mHierarchyInterface->CollectLeaves(node, mynodes);
@@ -112,5 +115,4 @@
 					HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end();
 
-					int nodesTested = 0;
 					for (nit = mynodes.begin(); nit != nit_end; ++ nit)
 					{
@@ -120,6 +122,13 @@
 							continue;
 
+						bool intersects = false;
+						const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects);
+
+						// don't test in these cases ...
+						if (frustumCulled || intersects)
+							continue;
+		
 						++ nodesTested;
-
+						
 						mHierarchyInterface->SetNodeVisible(leaf, false);
 
@@ -130,9 +139,33 @@
 						mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves);
 					}
-		
+
 					//std::stringstream d; d << "rc: " << mRandomCandidates << " tested: " << nodesTested << " of " << (int)mynodes.size();
 					//CullingLogManager::GetSingleton()->LogMessage(d.str());
 
+#else
+					
+					HierarchyNode *leaf = mHierarchyInterface->GetRandomLeaf(node);
+					
+					bool intersects = false;
+					const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects);
+
+					if (frustumCulled || intersects) // don't test in these cases ...
+						continue;
+
+					++ nodesTested;
+
+					mHierarchyInterface->SetNodeVisible(leaf, false);
+
+					// update node's visited flag: this is important as we are not testing
+					// all nodes in the hierarchy in this mode
+					mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId());
+					// issue the query
+					mHierarchyInterface->IssueNodeOcclusionQuery(leaf, mTestGeometryForVisibleLeaves);
+
+#endif
+					
 					mHierarchyInterface->RenderNodeRecursive(node);
+
+					// bail out here, recursion has finished
 					continue;
 				}
@@ -171,11 +204,4 @@
 					const bool testGeometry = wasVisible && mHierarchyInterface->IsLeaf(node) && mTestGeometryForVisibleLeaves;
 
-					// previously invisible node
-#if TODO	
-					if (!mHierarchyInterface->IsNodeVisible(node))
-					{
-						// batch queries so we can test invisible nodes
-					}
-#endif
 					queryQueue.push(QueryPair(node, mHierarchyInterface->
 						IssueNodeOcclusionQuery(node, testGeometry)));
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSolidBoundingBox.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSolidBoundingBox.cpp	(revision 2455)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSolidBoundingBox.cpp	(revision 2532)
@@ -129,4 +129,5 @@
 
 		Pass *queryPass = m_pMaterial->getTechnique(0)->getPass(0);
+
 		queryPass->setColourWriteEnabled(false);
 		queryPass->setDepthWriteEnabled(false);
@@ -137,5 +138,5 @@
 }
 
-// Override this method to prevent parent transforms (rotation,translation,scale)
+// Override this method to prevent parent transforms (rotation, translation, scale)
 void SolidBoundingBox::getWorldTransforms(Matrix4* xform) const
 {
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2513)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2532)
@@ -92,5 +92,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include\CEGUI&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSolidHalfBoundingBox.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSolidHalfBoundingBox.cpp	(revision 1146)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSolidHalfBoundingBox.cpp	(revision 2532)
@@ -101,4 +101,4 @@
 }
 
+
 } // namespace Ogre
-
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 2513)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp	(revision 2532)
@@ -217,32 +217,23 @@
 	GtpVisibility::QueryList::iterator projQueryIt = queryList[1].begin();
 	
-	if (1)
-	{	
-		// collect occlusion queries for hierarchy nodes
-		CollectNodeVisibility(visQueryIt, 
+	// collect occlusion queries for hierarchy nodes
+	CollectNodeVisibility(visQueryIt, 
 			projQueryIt, 
 			&nodeList, 
 			visibleNodes, 
 			relativeVisibility);
-	}
-
-	if (1)
-	{	
-		CollectGeometryVisibility(visQueryIt, 
+	
+	CollectGeometryVisibility(visQueryIt, 
 			projQueryIt, 
 			&geometryList, 
 			visibleGeometry, 
 			relativeVisibility);
-	}
-
-	if (1)
-	{
-		// collect occlusion queries for patches
-		CollectPatchVisibility(visQueryIt, 
+
+	// collect occlusion queries for patches
+	CollectPatchVisibility(visQueryIt, 
 			projQueryIt, 
 			&patchList, 
 			visiblePatches, 
 			relativeVisibility);
-	}
 
 
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2353)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj	(revision 2532)
@@ -81,5 +81,5 @@
 				OptimizeForWindowsApplication="TRUE"
 				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\OgreMain\include&quot;;&quot;$(OGRE_PATH)\Dependencies\include&quot;;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;..\include;..\..\..\Preprocessing\src"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
