Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2011)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2021)
@@ -90,13 +90,7 @@
 		mutationRays++;
 		
-		Intersectable *newObject =
-		  mPreprocessor.mViewCellsManager->GetIntersectable(
-															*vssRays[i],
-															true);
-
-		Intersectable *oldObject =
-		  mPreprocessor.mViewCellsManager->GetIntersectable(
-															*mRays[vssRays[i]->mGeneratorId].mRay,
-															true);
+		Intersectable *newObject = vssRays[i]->mTerminationObject;
+
+		Intersectable *oldObject =mRays[vssRays[i]->mGeneratorId].mRay->mTerminationObject;
 		
 		if (oldObject == newObject)
@@ -131,8 +125,5 @@
 #define DIST_THRESHOLD 3.0f
 
-		Intersectable *oldObject =
-		  mPreprocessor.mViewCellsManager->GetIntersectable(
-															*oldRay,
-															true);
+		Intersectable *oldObject = oldRay->mTerminationObject;
 		
 
@@ -156,8 +147,5 @@
 		mutationRays++;
 		
-		Intersectable *newObject =
-		  mPreprocessor.mViewCellsManager->GetIntersectable(
-															*vssRays[i],
-															true);
+		Intersectable *newObject = vssRays[i]->mTerminationObject;
 
 
@@ -370,7 +358,5 @@
   Vector3 line = 2.0f*(oldPivot - newPivot);
 
-  Intersectable *occluder = mPreprocessor.mViewCellsManager->GetIntersectable(
-																			  newRay,
-																			  true);
+  Intersectable *occluder = newRay.mTerminationObject;
   
   AxisAlignedBox3 box = occluder->GetBox();
@@ -442,7 +428,6 @@
 	  exporter->SetFilled();
 	  
-	  Intersectable *occludee = mPreprocessor.mViewCellsManager->GetIntersectable(
-																				  oldRay,
-																				  true);
+	  Intersectable *occludee = 
+		oldRay.mTerminationObject;
 	  
 	  exporter->SetForcedMaterial(RgbColor(0,0,1));
@@ -734,7 +719,5 @@
   VssRay *ray = mRays[index].mRay;
 
-  Intersectable *object = mPreprocessor.mViewCellsManager->GetIntersectable(
-																			*ray,
-																			true);
+  Intersectable *object = ray->mTerminationObject;
   
   AxisAlignedBox3 box = object->GetBox();
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2016)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/run_test2	(revision 2021)
@@ -3,5 +3,5 @@
 
 #COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+"
-COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -samples_per_pass=1000000"
+COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter- -samples_per_pass=1000000"
 
 #SCENE="../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d"
@@ -58,4 +58,5 @@
 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
 -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
+-view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
 -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4j.xml \
 -preprocessor_stats=$PREFIX-i-mixed-b1-n4j.log \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 2017)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 2021)
@@ -3454,5 +3454,5 @@
 			BspInterior *in = static_cast<BspInterior *>(node);
 
-			Plane3 splitPlane = in->GetPlane();
+			Plane3 &splitPlane = in->GetPlane();
 			
 			const int entSide = splitPlane.Side(entp, thresh);
@@ -3503,8 +3503,8 @@
 			
 			// question: always contribute to leaf or to currently active view cell?
-			if (0)
-				viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell());
-			else
-				viewCell = leaf->GetViewCell();
+			//			if (0)
+			//				viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell());
+			//			else
+			viewCell = leaf->GetViewCell();
 
 			if (!viewCell->Mailed())
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2017)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2021)
@@ -381,4 +381,10 @@
   SortViewCellPvs();
 
+  // map the ray intersection objects from triangles to high level objects...
+  void
+  DeterminePvsObjects(
+					  VssRayContainer &rays,
+					  const bool useHitObjects = false);
+	
 	/** Sets validity of view cell
 	*/
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2017)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2021)
@@ -1300,4 +1300,8 @@
 #endif
 	}
+
+	mViewCellsManager->DeterminePvsObjects(vssRays
+										   );
+	
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2019)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2021)
@@ -2615,4 +2615,22 @@
 
 
+void
+ViewCellsManager::DeterminePvsObjects(
+									  VssRayContainer &rays,
+									  const bool useHitObjects)
+{
+  if (!useHitObjects) {
+	VssRayContainer::const_iterator it, it_end = rays.end();
+	for (it = rays.begin(); it != it_end; ++ it) {
+	  VssRay *vssRay = *it;
+	  // set only the termination object
+	  vssRay->mTerminationObject = GetIntersectable(
+													*vssRay,
+													true);
+	}
+  }
+}
+
+
 float ViewCellsManager::ComputeSampleContribution(VssRay &ray,
 												  const bool addRays,
@@ -2629,8 +2647,5 @@
 	Intersectable *terminationObj;
 
-	if (!useHitObjects)
-		terminationObj = GetIntersectable(ray, true);
-	else
-		terminationObj = ray.mTerminationObject;
+	terminationObj = ray.mTerminationObject;
 
 	ComputeViewCellContribution(currentViewCell, 
@@ -2716,13 +2731,10 @@
 	Intersectable *terminationObj;
 	
-	objTimer.Entry();
+	//	objTimer.Entry();
 
 	// obtain pvs entry (can be different from hit object)
-	if (!useHitObjects)
-	  terminationObj = GetIntersectable(ray, true);
-	else
-	  terminationObj = ray.mTerminationObject;
-	
-	objTimer.Exit();
+	terminationObj = ray.mTerminationObject;
+	
+	//	objTimer.Exit();
 	
 	pvsTimer.Entry();
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2019)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2021)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: po 22. I 22:05:05 2007
+# Generated by qmake (2.00a) (Qt 4.1.2) on: út 23. I 00:22:45 2007
 # Project:  preprocessor.pro
 # Template: app
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2014)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2021)
@@ -312,8 +312,9 @@
 		Debug<<"PR2c"<<flush;
 #endif
-
+		
 		if (validA)
-			vssRay->mFlags |= VssRay::Valid;
-
+		  vssRay->mFlags |= VssRay::Valid;
+
+		
 		vssRay->mDistribution = simpleRay.mDistribution;
 		vssRay->mGeneratorId = simpleRay.mGeneratorId;
@@ -343,4 +344,5 @@
 			vssRay->mFlags |= VssRay::Valid;
 
+		  
 		vssRay->mDistribution = simpleRay.mDistribution;
 		vssRay->mGeneratorId = simpleRay.mGeneratorId;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2015)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2021)
@@ -87,5 +87,5 @@
 	
 	mMixtureDistribution->GenerateSamples(mSamplesPerPass, rays);
-
+	
 	bool doubleRays = true;
 	CastRays(rays, vssRays, doubleRays, pruneInvalidRays);
