Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj	(revision 1926)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/IVReader.vcproj	(revision 2100)
@@ -73,5 +73,5 @@
 				Name="VCCLCompilerTool"
 				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"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
@@ -225,30 +225,41 @@
 			<Tool
 				Name="VCCLCompilerTool"
+				Optimization="3"
+				GlobalOptimizations="TRUE"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="TRUE"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="TRUE"
+				EnableFiberSafeOptimizations="TRUE"
+				OptimizeForProcessor="3"
+				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"
-				RuntimeLibrary="2"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="TRUE"
-				DebugInformationFormat="3"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib"
-				OutputFile="$(OutDir)/IVReader.dll"
-				LinkIncremental="1"
-				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;"
+				StringPooling="TRUE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib"
+				OutputFile="$(OutDir)/IVReader.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\OgreMain\lib\Release&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;..\..\GtpVisibility\lib\Release;..\..\lib\Release;..\lib\Release;&quot;$(OGRE_PATH)\Dependencies\lib\Release&quot;"
 				GenerateDebugInformation="TRUE"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
-				ImportLibrary="$(OutDir)/IVReader.lib"
-				TargetMachine="1"/>
-			<Tool
-				Name="VCMIDLTool"/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="copy $(OutDir)\$(TargetFileName) &quot;$(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)&quot;"/>
+				OptimizeForWindows98="1"
+				ImportLibrary="$(OutDir)/IVReader.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(OutDir)\$(TargetFileName) &quot;$(OGRE_PATH)\Samples\Common\bin\Release&quot;"/>
 			<Tool
 				Name="VCPreBuildEventTool"/>
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 1926)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj	(revision 2100)
@@ -62,12 +62,19 @@
 			<Tool
 				Name="VCCLCompilerTool"
+				Optimization="3"
 				GlobalOptimizations="TRUE"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="TRUE"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
-				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\Preprocessing\src"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
-				RuntimeLibrary="2"
-				RuntimeTypeInfo="TRUE"
+				EnableFiberSafeOptimizations="TRUE"
+				OptimizeForProcessor="3"
+				OptimizeForWindowsApplication="TRUE"
+				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\Preprocessing\src"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+				StringPooling="TRUE"
+				RuntimeLibrary="2"
+				EnableEnhancedInstructionSet="2"
+				RuntimeTypeInfo="FALSE"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
@@ -188,9 +195,18 @@
 			<Tool
 				Name="VCCLCompilerTool"
-				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\Preprocessing\src"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
-				RuntimeLibrary="2"
-				RuntimeTypeInfo="TRUE"
+				Optimization="3"
+				GlobalOptimizations="TRUE"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="TRUE"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="TRUE"
+				EnableFiberSafeOptimizations="TRUE"
+				OptimizeForProcessor="3"
+				OptimizeForWindowsApplication="TRUE"
+				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\Preprocessing\src"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+				RuntimeLibrary="2"
+				EnableEnhancedInstructionSet="2"
+				RuntimeTypeInfo="FALSE"
 				UsePrecompiledHeader="0"
 				BrowseInformation="1"
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2069)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj	(revision 2100)
@@ -87,8 +87,8 @@
 				OmitFramePointers="TRUE"
 				EnableFiberSafeOptimizations="TRUE"
-				OptimizeForProcessor="0"
+				OptimizeForProcessor="3"
 				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;..\..\..\Preprocessing\src\Timer"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_KD_TERRAIN_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -280,6 +280,6 @@
 		<Configuration
 			Name="Release Internal|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
 			ConfigurationType="2"
 			CharacterSet="2"
@@ -295,12 +295,13 @@
 				OmitFramePointers="TRUE"
 				EnableFiberSafeOptimizations="TRUE"
-				OptimizeForProcessor="2"
-				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"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GTP_VISIBILITY_MODIFIED_OGRE"
+				OptimizeForProcessor="3"
+				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;..\IVReader\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GTP_VISIBILITY_MODIFIED_OGRE;PLUGIN_KD_TERRAIN_EXPORTS"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
 				BufferSecurityCheck="FALSE"
 				EnableFunctionLevelLinking="TRUE"
-				RuntimeTypeInfo="TRUE"
+				RuntimeTypeInfo="FALSE"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
@@ -312,15 +313,16 @@
 				Name="VCLinkerTool"
 				IgnoreImportLibrary="TRUE"
-				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplib.lib Preprocessor.lib xerces-c_2.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib glew32.lib glew32s.lib"
+				AdditionalDependencies="OgreMain.lib CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib GtpVisibility.lib zdll.lib zziplib.lib Preprocessor.lib xerces-c_2.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib glew32.lib glew32s.lib RTScene.lib RTWorld.lib IVReader.lib"
 				OutputFile="$(OutDir)/Plugin_VisibilitySceneManager.dll"
 				Version="0.99"
 				LinkIncremental="1"
 				SuppressStartupBanner="TRUE"
-				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;&quot;..\..\GtpVisibility\lib\$(ConfigurationName)&quot;;&quot;..\..\lib\$(ConfigurationName)&quot;;&quot;..\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)&quot;;&quot;..\..\..\Preprocessing\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;&quot;$(CG_LIB_PATH)&quot;;..\..\..\..\..\..\..\NonGTP\Zlib\lib"
+				AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\Release&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\Release&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;..\..\GtpVisibility\lib\Release;..\..\lib\Release;..\lib\Release;&quot;$(OGRE_PATH)\Dependencies\lib\Release&quot;;..\..\..\Preprocessing\lib\Release;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;&quot;$(CG_LIB_PATH)&quot;;..\..\..\..\..\..\..\NonGTP\Zlib\lib"
 				ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def"
-				GenerateDebugInformation="TRUE"
+				GenerateDebugInformation="FALSE"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
+				OptimizeForWindows98="1"
 				ImportLibrary="$(OutDir)/Plugin_VisibilitySceneManager.lib"
 				TargetMachine="1"/>
@@ -329,5 +331,5 @@
 			<Tool
 				Name="VCPostBuildEventTool"
-				CommandLine="copy $(OutDir)\$(TargetFileName) $(OGRE_PATH)\Samples\Common\bin\$(ConfigurationName)"/>
+				CommandLine="copy $(OutDir)\$(TargetFileName) $(OGRE_PATH)\Samples\Common\bin\Release"/>
 			<Tool
 				Name="VCPreBuildEventTool"/>
Index: GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.vcproj	(revision 1926)
+++ GTP/trunk/Lib/Vis/Preprocessing/EvalStats/EvalStats.vcproj	(revision 2100)
@@ -205,20 +205,30 @@
 			<Tool
 				Name="VCCLCompilerTool"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="3"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="TRUE"
-				DebugInformationFormat="3"/>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile="$(OutDir)/EvalStats.exe"
-				LinkIncremental="1"
-				GenerateDebugInformation="TRUE"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
+				Optimization="3"
+				GlobalOptimizations="TRUE"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="TRUE"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="TRUE"
+				EnableFiberSafeOptimizations="TRUE"
+				OptimizeForProcessor="3"
+				OptimizeForWindowsApplication="TRUE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="0"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/EvalStats.exe"
+				LinkIncremental="1"
+				GenerateDebugInformation="TRUE"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="1"
 				TargetMachine="1"/>
 			<Tool
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2092)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2100)
@@ -206,6 +206,6 @@
 		<Configuration
 			Name="Release Internal|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
 			ConfigurationType="4"
 			CharacterSet="2">
@@ -419,4 +419,7 @@
 			</File>
 			<File
+				RelativePath=".\DefaultPvs.h">
+			</File>
+			<File
 				RelativePath="..\src\dual_depth.cg">
 			</File>
@@ -482,4 +485,7 @@
 			</File>
 			<File
+				RelativePath=".\HashPvs.h">
+			</File>
+			<File
 				RelativePath=".\HierarchyManager.cpp">
 			</File>
@@ -750,4 +756,7 @@
 			<File
 				RelativePath="..\src\Pvs.h">
+			</File>
+			<File
+				RelativePath=".\PvsBase.h">
 			</File>
 			<File
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2096)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2100)
@@ -27,4 +27,6 @@
 #include "PerfTimer.h"
 
+#include "HashPvs.h"
+
 
 
@@ -1543,4 +1545,5 @@
 		
 		castSamples += samplesPerPass;
+HashPvs<int> dummy;
 
 		Real timeDiff = TimeDiff(startTime, GetTime());
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 2071)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 2100)
@@ -1162,5 +1162,5 @@
 
 
-inline int AddedPvsSize(ObjectPvs pvs1, const ObjectPvs &pvs2)
+inline int AddedPvsSize(const ObjectPvs &pvs1, const ObjectPvs &pvs2)
 {
 	ObjectPvs interPvs;
@@ -2267,5 +2267,6 @@
 
 	int entriesInPvs = rootEntries;
-    const int entryStorage = sizeof(PvsData) + sizeof(int); // one entry into the pvs
+	// one entry into the pvs
+    const int entryStorage = sizeof(PvsData) + sizeof(int); 
 
 	storageFunction.push_back(rootEntries);
@@ -2319,5 +2320,4 @@
 	}
 }
-
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 2077)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 2100)
@@ -106,5 +106,5 @@
 	}
 
-	////////////////////////////
+	///////////////
 	//  Mailing stuff
 
@@ -172,12 +172,12 @@
 {
 	template<typename T, typename S>
-	friend class PvsIterator;
+		friend class PvsIterator;
 
 public:
-  
+
 	Pvs(): mSamples(0), mEntries(), mLastSorted(0), mQueriesSinceSort(0) {}
 
 	/** creates pvs and initializes it with the given entries. 
-		Assumes that entries are sorted-
+	Assumes that entries are sorted-
 	*/
 	Pvs(const vector<PvsEntry<T, S> > &samples);
@@ -186,22 +186,36 @@
 	/** Compresses PVS lossless or lossy.
 	*/
-	int Compress() {return 0;}
-	int GetSize() const {return (int)mEntries.size();}
-	bool Empty() const {return mEntries.empty();}
-
-	void Reserve(const int n) { mEntries.reserve(n); }
+	int Compress() 
+	{
+		return 0;
+	}
+	
+	int GetSize() const 
+	{
+		return (int)mEntries.size();
+	}
+	
+	bool Empty() const 
+	{
+		return mEntries.empty();
+	}
+
+	void Reserve(const int n) 
+	{ 
+		mEntries.reserve(n); 
+	}
 
 	/** Normalize the visibility of entries in order to get 
-		comparable results.
+	comparable results.
 	*/
 	void NormalizeMaximum();
 
 	/** Merges pvs of a into this pvs.
-		Warning: very slow!
+	Warning: very slow!
 	*/
 	void MergeInPlace(const Pvs<T, S> &a);
 
 	/** Difference of pvs to pvs b.
-		@returns number of different entries.
+	@returns number of different entries.
 	*/
 	int Diff(const Pvs<T, S> &b);
@@ -209,7 +223,7 @@
 	/** Finds sample in PVS.
 		@param checkDirty if dirty part of the pvs should be checked for entry 
-			(warning: linear runtime in dirty part)
+		(warning: linear runtime in dirty part)
 		@returns iterator on the sample if found, else the place where 
-			it would be added in the sorted vector.
+		it would be added in the sorted vector.
 	*/
 	bool Find(T sample,
@@ -239,12 +253,7 @@
 	void Sort();
 
-  /** Sort pvs entries assume that the pvs contains unique entries
-   */
-  void SimpleSort();
-
-	/** Adds sample to PVS. Assumes that the pvs is sorted
-		@returns contribution of sample (0 or 1)
-	*/
-	//float AddSamples(const vector<PvsEntry<T, S> > &samples);
+	/** Sort pvs entries assume that the pvs contains unique entries
+	*/
+	void SimpleSort();
 
 	/** Adds sample to PVS.
@@ -269,5 +278,5 @@
 
 	/** Removes sample from PVS if reference count is zero.
-		@param visibleSamples number of references to be removed
+	@param visibleSamples number of references to be removed
 	*/
 	bool RemoveSample(T sample, const float pdf);
@@ -293,4 +302,55 @@
 
 	static void Merge(Pvs<T, S> &mergedPvs, const Pvs<T, S> &a, const Pvs<T, S> &b);
+
+	int GetSamples() const
+	{
+		return mSamples;
+	}
+
+	bool IsDirty() const
+	{
+		return mLastSorted < mEntries.size();
+	}
+
+	bool RequiresResort() const
+	{
+		// the last part should not be more than log of the sorted part. this
+		// way we can achieve logarithmic behaviour for insertion and find
+		const int n = mEntries.size();
+		const int dirtySize = n - mLastSorted;
+
+#define LOG2E 1.442695040f
+
+		const float logN = log((float)max(1, n))/LOG2E;
+		const float logS = log((float)max(1, mLastSorted))/LOG2E;
+		const float logD = log((float)max(1, dirtySize))/LOG2E;
+
+		if (8*(n + 2*dirtySize*logD) <
+			mQueriesSinceSort*((mLastSorted*logS + dirtySize*dirtySize/2)/n - logN)) 
+		{
+				//		cout<<"Q="<<mQueriesSinceSort<<" N="<<n<<" D="<<dirtySize<<endl;
+			return true;
+		}
+		
+		return false;
+	}
+
+	bool RequiresResortLog() const
+	{
+		// the last part should not be more than log of the sorted part. this
+		// way we can achieve logarithmic behaviour for insertion and find
+		const int dirtySize = (int)mEntries.size() - mLastSorted;
+		return dirtySize > 4 * (int)(log((double)mEntries.size()) / log(2.0));
+	}
+
+
+	int GetLastSorted() const
+	{
+		return mLastSorted;
+	}
+
+	typename PvsIterator<T, S> GetIterator() const;
+
+protected:
 
 	static void Merge(Pvs<T, S> &mergedPvs, 
@@ -302,64 +362,14 @@
 					  const int bSamples);
 
-	int GetSamples() const
-	{
-		return mSamples;
-	}
-
-
-	bool IsDirty() const
-	{
-		return mLastSorted < mEntries.size();
-	}
-
-	bool RequiresResort() const
-	{
-	  // the last part should not be more than log of the sorted part. this
-	  // way we can achieve logarithmic behaviour for insertion and find
-	  const int n = mEntries.size();
-	  const int dirtySize = n - mLastSorted;
-
-#define LOG2E 1.442695040f
-	  
-	  const float logN = log((float)max(1, n))/LOG2E;
-	  const float logS = log((float)max(1, mLastSorted))/LOG2E;
-	  const float logD = log((float)max(1, dirtySize))/LOG2E;
-	  
-	  if (8*(n + 2*dirtySize*logD) <
-		  mQueriesSinceSort*((mLastSorted*logS + dirtySize*dirtySize/2)/n - logN)) {
-		//		cout<<"Q="<<mQueriesSinceSort<<" N="<<n<<" D="<<dirtySize<<endl;
-		return true;
-	  }
-	  return false;
-	}
-
-  bool RequiresResortLog() const
-  {
-	// the last part should not be more than log of the sorted part. this
-	// way we can achieve logarithmic behaviour for insertion and find
-	const int dirtySize = (int)mEntries.size() - mLastSorted;
-	return dirtySize > 4*(int)(log((double)mEntries.size()) / log(2.0));
-  }
-  
-  
-	int GetLastSorted() const
-	{
-		return mLastSorted;
-	}
-
-	typename PvsIterator<T, S> GetIterator() const;
-
-protected:
-
 	/// vector of PVS entries
 	vector<PvsEntry<T, S> > mEntries; 
-	
+
 	/// Number of samples used to create the PVS
 	int mSamples;
-  
+
 	/// Last sorted entry in the pvs (important for find and merge)
 	int mLastSorted;
 
-  int mQueriesSinceSort;
+	int mQueriesSinceSort;
 };
 
@@ -379,5 +389,4 @@
 {
 	std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted;
-	//std::vector<PvsEntry<T, S> >::const_iterator it = mEntries.begin() + mLastSorted;
 	std::vector<PvsEntry<T, S> >::iterator it_end = mEntries.end();
 
@@ -385,5 +394,4 @@
 	std::vector<PvsEntry<T, S> >::iterator newEnd = unique(it, it_end);
 	sort(it, newEnd);
-	//sort(mEntries.begin(), mEntries.end());
 	
 	// now merge sorted ranges
@@ -452,12 +460,17 @@
 		const float diff = bSumPdf - aSumPdf;
 
-		if (diff > 0.0f) {
+		if (diff > 0.0f) 
+		{
 			pvsEnlargement += diff;
-		} else {
+		} 
+		else 
+		{
 			pvsReduction += -diff;
 		}
 #else
 		if (!entryFound)
+		{
 			pvsEnlargement += 1.0f;
+		}
 #endif
 	}
@@ -467,10 +480,12 @@
 		float aSumPdf = (*it).mData.mSumPdf;
 		float bSumPdf = 0.0f;
-		if (aSumPdf < 0.0f) {
-		
+		if (aSumPdf < 0.0f) 
+		{
 			// this entry was already accounted for!
 			// just revert it back
 			(*it).mData.mSumPdf = -aSumPdf;
-		} else {
+		} 
+		else 
+		{
 			vector<PvsEntry<T, S> >::iterator oit;
 		
@@ -592,6 +607,4 @@
 				mergedPvs.mEntries.push_back(*bit);
 			}
-			
-			//bObjOld = bObj;
 		}
 
@@ -669,34 +682,4 @@
 }
 
-/*
-template <typename T, typename S> 
-bool Pvs<T, S>::Find(T sample,
-					 typename vector<PvsEntry<T, S> >::iterator &it,
-					 const bool checkDirty)
-{
-	PvsEntry<T, S> dummy(sample, PvsData());
-	mQueriesSinceSort++;
-
-	// only check clean part
-	vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted;
-
-	// binary search
-	it = lower_bound(mEntries.begin(), sorted_end, dummy);
-
-	if ((it != mEntries.end()) && ((*it).mObject == sample))
-		return true;
-
-	// sample not found yet => search further in the unsorted part
-	if (checkDirty) 
-	{
-		for (it = sorted_end; (it != mEntries.end()) && ((*it).mObject != sample); ++ it);
-
-		if (it != mEntries.end())
-			return true;
-	}
-
-	return false;
-}
-*/
 
 template <typename T, typename S>
Index: GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp	(revision 2017)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp	(revision 2100)
@@ -392,5 +392,5 @@
 	// This is important during the subdivision
 
-//MailablePvsData::NewMail();
+	//MailablePvsData::NewMail();
 	UpdateViewCellsPvs(front, *frontData.mRays);
 	UpdateViewCellsPvs(back, *backData.mRays);
Index: GTP/trunk/Lib/Vis/GtpVisibility.sln
===================================================================
--- GTP/trunk/Lib/Vis/GtpVisibility.sln	(revision 1949)
+++ GTP/trunk/Lib/Vis/GtpVisibility.sln	(revision 2100)
@@ -10,5 +10,4 @@
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IVReader", "OnlineCullingCHC\IVReader\src\IVReader.vcproj", "{7319E499-473D-4CE5-9983-725D6E68A55D}"
 	ProjectSection(ProjectDependencies) = postProject
-		{80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}
 	EndProjectSection
 EndProject
