Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/scripts/IVReader.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/scripts/IVReader.vcproj	(revision 343)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/scripts/IVReader.vcproj	(revision 1139)
@@ -20,9 +20,10 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
+				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;_DEBUG;_WINDOWS;_USRDLL;IVREADER_EXPORTS"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="1"
-				UsePrecompiledHeader="3"
+				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="TRUE"
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/ivmanualmeshloader.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/ivmanualmeshloader.cpp	(revision 870)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/ivmanualmeshloader.cpp	(revision 1139)
@@ -62,4 +62,5 @@
 	return data->boundingBox;
 }
+
 
 void IVManualMeshLoader::loadResource(Ogre::Resource *resource)
@@ -153,3 +154,2 @@
 
 }
-
Index: /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/ivnode.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/ivnode.cpp	(revision 187)
+++ /GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/ivnode.cpp	(revision 1139)
@@ -7,4 +7,6 @@
 	typ = IV_STRING;
 }
+
+
 IVField::~IVField()
 {
@@ -14,4 +16,5 @@
 }
 
+
 IVNode::IVNode()
 {
@@ -20,4 +23,5 @@
 	fields = NULL;
 }
+
 
 IVNode::IVNode(const char *s)
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.h	(revision 1138)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.h	(revision 1139)
@@ -52,4 +52,8 @@
 	
 
+	/** Pointer to kd leaf object that was hit during ray casting.
+	*/
+	Intersectable *mHitObject;
+
 protected:
 	
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp	(revision 1121)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp	(revision 1139)
@@ -14,4 +14,6 @@
 #include "RssTree.h"
 #include "Beam.h"
+#include "KdIntersectable.h"
+
 
 namespace GtpVisibilityPreprocessor {
@@ -171,6 +173,8 @@
 		break;
 	case Intersectable::VIEW_CELL:
-		ExportViewCell((ViewCell *)object);
+		ExportViewCell(dynamic_cast<ViewCell *>(object));
 		break;
+	case Intersectable::KD_INTERSECTABLE:
+		ExportKdIntersectable(*(dynamic_cast<KdIntersectable *>(object)));
 	default:
 		cerr << "Sorry the export for object not yet defined" << endl;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 1134)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp	(revision 1139)
@@ -2212,8 +2212,8 @@
 					"0.99");
 
-	RegisterOption("VspTree.pvsCountMethod",
-					optInt,
-					"vsp_pvs_count_method=",
-					"1");
+	RegisterOption("VspTree.useKdPvs",
+					optBool,
+					"vsp_pvs_use_kd_pvs=",
+					"true");
 
 	
@@ -2307,9 +2307,4 @@
 			"osp_construction_render_cost_decrease_weight=",
 			"0.99");
-
-	RegisterOption("OspTree.Construction.useEqualWeightForHeuristics",
-		optBool,
-		"osp_construction_use_equal_weight_for_heuristics=",
-		"false");
 
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h	(revision 1121)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h	(revision 1139)
@@ -28,4 +28,5 @@
 class Beam;
 class OspTree;
+class KdIntersectable;
 
 
@@ -146,4 +147,6 @@
 
   virtual void ExportViewpoint(const Vector3 &point, const Vector3 &direction) = 0;
+
+  void ExportKdIntersectable(const KdIntersectable &kdObj);
 };
  
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1138)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp	(revision 1139)
@@ -17,4 +17,5 @@
 #include "Beam.h"
 #include "KdTree.h"
+#include "KdIntersectable.h"
 
 
@@ -363,5 +364,5 @@
 	Environment::GetSingleton()->GetBoolValue("VspTree.simulateOctree", mCirculatingAxis);
 	
-	Environment::GetSingleton()->GetIntValue("VspTree.pvsCountMethod", mPvsCountMethod);
+	Environment::GetSingleton()->GetBoolValue("VspTree.useKdPvs", mUseKdPvs);
 
 	char subdivisionStatsLog[100];
@@ -399,5 +400,5 @@
 	Debug << "maxband: " << mMaxBand << endl;
 
-	if (mPvsCountMethod == 0)
+	if (!mUseKdPvs)
 		Debug << "pvs count method: per object" << endl;
 	else
@@ -871,4 +872,17 @@
 		if (obj) 
 		{
+			Intersectable *entry;
+
+			// potentially visible kd cells
+			if (mUseKdPvs)
+			{
+				KdLeaf *leaf = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode);
+				KdIntersectable *kdObj = new KdIntersectable(leaf);
+
+				entry = kdObj;
+			}
+			else
+				entry = obj;
+
 			if (vc->AddPvsSample(obj, ray->mPdf, contribution))
 			{
@@ -877,16 +891,23 @@
 
 			sc += contribution;
+		}
+
+		obj = ray->mOriginObject;
+
+		if (obj) 
+		{
+			Intersectable *entry;
 
 			// potentially visible kd cells
-			KdLeaf *leaf = 
-				mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode);
-			float kdcontri;
-			vc->AddKdPvsSample(leaf, 1, kdcontri);
-		}
-
-		obj = ray->mOriginObject;
-
-		if (obj) 
-		{
+			if (mUseKdPvs)
+			{
+				KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode);
+				KdIntersectable *kdObj = new KdIntersectable(leaf);
+
+				entry = kdObj;				
+			}
+			else
+				entry = obj;
+
 			if (vc->AddPvsSample(obj, ray->mPdf, contribution))
 			{
@@ -895,11 +916,4 @@
 
 			sc += contribution;
-	
-			// potentially visible kd cells
-			const bool origin = true;
-			KdLeaf *leaf =
-				mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode);
-			float kdcontri;
-			vc->AddKdPvsSample(leaf, 1, kdcontri);
 		}
 
@@ -1042,5 +1056,5 @@
 		if (oObject)
 		{
-			if (mPvsCountMethod == PER_OBJECT)
+			if (!mUseKdPvs)
 			{
 				if (!oObject->Mailed())
@@ -1066,5 +1080,5 @@
 		if (tObject)
 		{
-			if (mPvsCountMethod == PER_OBJECT)
+			if (!mUseKdPvs)
 			{
 				if (!tObject->Mailed())
@@ -1152,5 +1166,5 @@
 	if (oObject)
 	{	
-		if (mPvsCountMethod == PER_OBJECT)
+		if (!mUseKdPvs)
 		{
 			if (ci.type == SortableEntry::ERayMin)
@@ -1188,5 +1202,5 @@
 	if (tObject)
 	{	
-		if (mPvsCountMethod == PER_OBJECT)
+		if (!mUseKdPvs)
 		{
 			if (ci.type == SortableEntry::ERayMin)
@@ -2622,6 +2636,5 @@
 OspTree::OspTree():
 mRoot(NULL),
-mTimeStamp(1),
-mUseEqualWeightForHeuristics(false)
+mTimeStamp(1)
 {
 	bool randomize = false;
@@ -2664,6 +2677,4 @@
 	Environment::GetSingleton()->GetFloatValue("OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight);
 	
-	Environment::GetSingleton()->GetBoolValue("OspTree.Construction.useEqualWeightForHeuristics", mUseEqualWeightForHeuristics);
-
 
 	//-- debug output
@@ -3430,5 +3441,5 @@
 	ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end();
 
-	//TODO §§matt: have to evaluate view cell volume on left and right cell
+	// evaluate reverse pvs and view cell volume on left and right cell
 	for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit)
 	{
@@ -4057,6 +4068,6 @@
 	// makes no sense otherwise because only one kd cell available
 	// during view space partition
-	const int savedCountMethod = mVspTree.mPvsCountMethod;
-	mVspTree.mPvsCountMethod = VspTree::PER_OBJECT;
+	const bool savedCountMethod = mVspTree.mUseKdPvs;
+	mVspTree.mUseKdPvs = false;
 
 	mTQueue.Push(PrepareVsp(sampleRays, forcedViewSpace, *viewSpaceRays));
@@ -4137,5 +4148,5 @@
 	cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl;
 
-	mVspTree.mPvsCountMethod = savedCountMethod;
+	mVspTree.mUseKdPvs = savedCountMethod;
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1138)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1139)
@@ -18,4 +18,5 @@
 #include "GlRenderer.h"
 #include "ResourceManager.h"
+#include "KdIntersectable.h"
 
 
@@ -5467,6 +5468,5 @@
 		{	
 			//-- export pvs
-			ObjectPvsMap::const_iterator oit,
-				oit_end = pvs.mEntries.end();
+			ObjectPvsMap::const_iterator oit, oit_end = pvs.mEntries.end();
 
 			Intersectable::NewMail();
@@ -5482,8 +5482,7 @@
 			for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit)
 			{	
-				// export "original" pvs
 				Intersectable *obj = (*oit).first;
 
-				if (1 && !obj->Mailed())
+				if (!obj->Mailed())
 				{
 					exporter->ExportIntersectable(obj);
@@ -5491,42 +5490,20 @@
 				}					
 				
-				// TODO matt§§
-				// export kd pvs
-				KdLeaf *kdleaf = 0;
-
-				if (!kdleaf->Mailed())
+				// export "original" pvs
+				m.mDiffuseColor = RgbColor(0, 0, 1);
+				exporter->SetForcedMaterial(m);
+
+				if ((*oit).first->Type() == Intersectable::KD_INTERSECTABLE)
 				{
-					kdleaf->Mail();
-					kdLeaves.push_back(kdleaf);
+					KdIntersectable *kdObj = dynamic_cast<KdIntersectable *>(obj);
+					Intersectable *hitObj = kdObj->mHitObject;
+				
+					if (!hitObj->Mailed())
+					{
+						exporter->ExportIntersectable(hitObj);
+						hitObj->Mail();
+					}	
 				}
-			}
-
-			m.mDiffuseColor = RgbColor(0, 0, 1);
-			exporter->SetForcedMaterial(m);
-
-			//-- export kd node pvs
-			Intersectable::NewMail();
-
-			vector<KdLeaf *>::const_iterator kdit, kdit_end = kdLeaves.end();
-
-			for (kdit = kdLeaves.begin(); kdit != kdit_end; ++ kdit)
-			{
-				KdLeaf *kdleaf = *kdit;
-
-				//-- export kd node
-				
-				ObjectContainer::const_iterator oit, oit_end = kdleaf->mObjects.end();
-
-               	for (oit = kdleaf->mObjects.begin(); oit != oit_end; ++ oit)
-				{	
-					Intersectable *obj = *oit;
-
-					if (!obj->Mailed())
-					{
-						exporter->ExportIntersectable(obj);
-						obj->Mail();					
-					}				
-				}
-			}
+			}		
 		}
 	
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1121)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1139)
@@ -3,4 +3,5 @@
 #include "VspOspTree.h"
 #include "KdTree.h"
+#include "KdIntersectable.h"
 
 
@@ -72,3 +73,29 @@
 }
 
+void Exporter::ExportKdIntersectable(const KdIntersectable &kdObj)
+{
+	KdNode *node = kdObj.GetNode();
+	
+	Intersectable::NewMail();
+
+	if (node->IsLeaf())
+	{
+		KdLeaf *leaf = dynamic_cast<KdLeaf *>(node);
+		
+		ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end();
+
+		for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit)
+		{	
+			Intersectable *obj = *oit;
+        
+			if (!obj->Mailed())
+			{
+				ExportIntersectable(obj);
+				obj->Mail();					
+			}				
+		}
+	}
 }
+
+
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1135)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1139)
@@ -260,11 +260,4 @@
 
 
-bool ViewCell::AddKdPvsSample(KdLeaf *sample,
-							  const float pdf, 
-							  float &contribution)
-{
-	const bool result = mKdPvs.AddSample(sample, pdf, contribution);
-	return result;
-}
 
 /************************************************************************/
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h	(revision 1138)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h	(revision 1139)
@@ -1018,5 +1018,5 @@
 protected:
 
-	int mPvsCountMethod;
+	bool mUseKdPvs;
 
 	enum {PER_OBJECT, PER_KDLEAF};
@@ -1684,7 +1684,4 @@
 	float mEpsilon;
 
-
-	bool mUseEqualWeightForHeuristics;
-
 	/// subdivision stats output file
 	ofstream  mSubdivisionStats;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h	(revision 1133)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h	(revision 1139)
@@ -191,5 +191,4 @@
 	bool AddPvsSample(Intersectable *sample, const float pdf, float &contribution);
   
-	bool AddKdPvsSample(KdLeaf *sample, const float pdf, float &contribution);
 
 	/// Rays piercing this view cell.
