Index: trunk/VUT/GtpVisibility/include/CoherentHierarchicalCullingManager.h
===================================================================
--- trunk/VUT/GtpVisibility/include/CoherentHierarchicalCullingManager.h	(revision 142)
+++ trunk/VUT/GtpVisibility/include/CoherentHierarchicalCullingManager.h	(revision 146)
@@ -16,11 +16,12 @@
 	CoherentHierarchicalCullingManager();
 	void RenderScene();
-	/** Sets assumed visibility which is a decition variable 
-		wether an occlusion query should be issued or not.
-		@param assumedVisibility indicates that same visibility should be assumed
-		 for approximately assumedVisibility frames. 
-		 if 0, no assumedVisibility will be tested.
+	/** Sets assumed visibility which is a an estimation for e 
+		how many frames the visibility is considered to be valied
+		@param assumedVisibility indicates for how many frames the 
+		same visibility is be assumed.
+		if 0, the visibility is tested deterministically for each frame.
 	*/
-	void SetAssumedVisibility(int assumedVisibility);
+	void SetAssumedVisibility(unsigned int assumedVisibility);
+
 protected:
 	/** Decides wether occlusion query should be issued depending on some 
@@ -29,5 +30,10 @@
 	*/
 	bool DecideQueryTest(HierarchyNode *node) const;
-	int mAssumedVisibility;
+
+	unsigned int mAssumedVisibility;
+	/** Threshold for rand function to return positive result with respect to
+		mAssumedVisibility.
+	*/
+	unsigned int mThreshold;
 };
 
Index: trunk/VUT/GtpVisibility/include/VisibilityManager.h
===================================================================
--- trunk/VUT/GtpVisibility/include/VisibilityManager.h	(revision 130)
+++ trunk/VUT/GtpVisibility/include/VisibilityManager.h	(revision 146)
@@ -55,4 +55,8 @@
 	*/
 	void SetUseChcOptimization(bool useOptimization);
+	/** Indicates for how long a frame is considered to be visible.
+		@param assumedVisibility estimation for how long visibility is assumed to be valid.
+	*/
+	void SetAssumedVisibility(unsigned int assumedVisibility);
 	/** Sets pointer to a query manager. 
 	*/
@@ -71,5 +75,5 @@
 
 	unsigned int mVisibilityThreshold;
-
+	unsigned int mAssumedVisibility;
 };
 } // namespace GtpVisibility
Index: trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 142)
+++ trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 146)
@@ -6,5 +6,5 @@
 //-----------------------------------------------------------------------
 CoherentHierarchicalCullingManager:: CoherentHierarchicalCullingManager():
-mAssumedVisibility(0)
+mAssumedVisibility(0), mThreshold(0)
 {
 	// initialise random generator because of assumed visibility
@@ -111,14 +111,19 @@
 }
 //-----------------------------------------------------------------------
-void CoherentHierarchicalCullingManager::SetAssumedVisibility(int assumedVisibility)
+void CoherentHierarchicalCullingManager::SetAssumedVisibility(unsigned int assumedVisibility)
 {
 	mAssumedVisibility = assumedVisibility;
+	
+	mThreshold = 0;
+
+	if (mAssumedVisibility)
+	{
+		mThreshold =  RAND_MAX / mAssumedVisibility;
+	}
 }
 //-----------------------------------------------------------------------
 bool CoherentHierarchicalCullingManager::DecideQueryTest(HierarchyNode *node) const
 {
-	bool result = false;
-	rand();
-	return result;
+	return rand() < mThreshold;
 }
 } // namespace GtpVisibility
Index: trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
===================================================================
--- trunk/VUT/GtpVisibility/src/VisibilityManager.cpp	(revision 130)
+++ trunk/VUT/GtpVisibility/src/VisibilityManager.cpp	(revision 146)
@@ -46,4 +46,6 @@
 		case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING:
 			mCullingManager = new CoherentHierarchicalCullingManager();
+			dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
+				SetAssumedVisibility(mAssumedVisibility);
 			break;
 
@@ -93,3 +95,14 @@
 	return mQueryManager;
 }
+void VisibilityManager::SetAssumedVisibility(unsigned int assumedVisibility)
+{
+	mAssumedVisibility = assumedVisibility;
+
+	if (VisibilityManager::GetCullingManagerType() == 
+		VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
+	{
+		dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
+				SetAssumedVisibility(mAssumedVisibility);
+	}
+}
 } // namespace GtpVisibility
Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 145)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 146)
@@ -54,4 +54,5 @@
 mTerrainContentGenerator(sceneGenerator),
 mVisibilityThreshold(0),
+mAssumedVisibility(0),
 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING),
 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING),
@@ -109,5 +110,8 @@
 	mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AlgorithmInfo");
 	mThresholdInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ThresholdInfo");
-	
+	mUseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo");
+	mUseDepthPassInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseDepthPassInfo");
+	mAssumedVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AssumedVisibilityInfo");
+
 	mFrustumCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/FrustumCulledNodesInfo");
 	mQueryCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueryCulledNodesInfo");
@@ -116,6 +120,4 @@
 	mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo");
 	mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo");
-	mUseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo");
-	mUseDepthPassInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseDepthPassInfo");
 	mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo");
 	
@@ -131,4 +133,5 @@
 	mUseDepthPassInfo->setCaption(": false");
 	mQueriesIssuedInfo->setCaption(": 0");
+	mAssumedVisibilityInfo->setCaption(": 0");
 
 
@@ -596,4 +599,15 @@
 }
 //-----------------------------------------------------------------------
+void TerrainFrameListener::changeAssumedVisibility(int incr)
+{
+	mAssumedVisibility += incr; 
+	if(mAssumedVisibility < 0) mAssumedVisibility = 0;
+	
+	char str[100]; sprintf(str,": %d", mAssumedVisibility);
+
+	mSceneMgr->setOption("AssumedVisibility", &mAssumedVisibility); 
+	mAssumedVisibilityInfo->setCaption(str);
+}
+//-----------------------------------------------------------------------
 void TerrainFrameListener::zoomVizCamera(int zoom)
 {
@@ -869,4 +883,10 @@
 		break;
 
+	case KC_8:
+		changeAssumedVisibility(-1);
+		break;
+	case KC_9:
+		changeAssumedVisibility(1);
+		break;
 	case KC_LSHIFT:
 		mShiftPressed = true;
Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h	(revision 144)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h	(revision 146)
@@ -107,5 +107,5 @@
 	void nextAppState();
     void changeThreshold(int incr);
-	
+	void changeAssumedVisibility(int incr);
 	void toggleUseOptimization();
 	void toggleShowOctree();
@@ -136,4 +136,5 @@
 	int mCurrentAlgorithm;
 	int mVisibilityThreshold;
+	int mAssumedVisibility;
 	// the current frame number
 	int mCurrentFrame;
@@ -149,4 +150,5 @@
 	OverlayElement *mAlgorithmInfo;
 	OverlayElement *mThresholdInfo;
+	OverlayElement *mAssumedVisibilityInfo;
 	OverlayElement *mFrustumCulledNodesInfo;
 	OverlayElement *mQueryCulledNodesInfo;
Index: trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp	(revision 100)
+++ trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp	(revision 146)
@@ -22,4 +22,9 @@
 	{
 		mVisibilityManager->SetVisibilityCullingThreshold(*static_cast<const int *>(val));
+		return true;
+	}
+	if (key == "AssumedVisibility")
+	{
+		mVisibilityManager->SetAssumedVisibility(*static_cast<const int *>(val));
 		return true;
 	}
Index: trunk/VUT/Ogre/resources/VisibilityDemo.overlay
===================================================================
--- trunk/VUT/Ogre/resources/VisibilityDemo.overlay	(revision 135)
+++ trunk/VUT/Ogre/resources/VisibilityDemo.overlay	(revision 146)
@@ -23,5 +23,5 @@
 		top 5
 		width 400
-		height 75
+		height 90
 		material Core/StatsBlockCenter
         	border_size 1 1 1 1
@@ -101,5 +101,21 @@
 			caption :
 		}
-
+		element TextArea(Example/Visibility/AssumedVisibility): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			top 65
+			width 90
+			height 30
+			caption [A] Assumed Visibility
+		}
+		
+		element TextArea(Example/Visibility/AssumedVisibilityInfo): Example/Visibility/Templates/BasicText
+		{
+			left 155
+			top 65
+			width 90
+			height 30
+			caption :
+		}
 	}
 
