Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2726)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2727)
@@ -42,7 +42,7 @@
 -gvs_total_samples=1000000 \
 -gvs_samples_per_pass=1000000 \
--gvs_initial_samples=2000 \
+-gvs_initial_samples=50 \
 -gvs_max_viewcells=1 \
--gvs_min_contribution=50 \
+-gvs_min_contribution=500 \
 -gvs_per_viewcell=true \
 -preprocessor_detect_empty_viewspace+ \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp	(revision 2723)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp	(revision 2727)
@@ -35,56 +35,31 @@
 
 		// already processed node (=> objects already in pvs)?
-		if (1)//!node->Mailed())
+		//node->Mail();
+		if (node->IsLeaf())
 		{
-			//node->Mail();
-			if (node->IsLeaf())
+			KdLeaf *leaf = static_cast<KdLeaf *>(node);
+
+			// Objects already accounted for can only be found among those
+			// which are referenced in more than one leaf
+			ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end();
+
+			for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit)
 			{
-				KdLeaf *leaf = static_cast<KdLeaf *>(node);
-#if USE_MULTIPLE_OBJECTS				
-				// add #objects exclusivly in this node
-				pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size());
+				Intersectable *obj = *oit;						
 
-				// Objects already accounted for can only be found among those
-				// which are referenced in more than one leaf
-				ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end();
-						
-				for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit)
+				if (!obj->Mailed2())
 				{
-					Intersectable *obj = *oit;						
-                            
-					if (1)//!obj->Mailed())
-					{
-						//obj->Mail();
-						if (dummyPvs.AddSample(obj))
-							++ pvs;
-					}
+					//if (dummyPvs.AddSample(obj, 1.0f))++ pvs;
+					obj->Mail2();
+					++ pvs;
 				}
-#else
+			}
+		}
+		else // traverse tree
+		{
+			KdInterior *interior = static_cast<KdInterior *>(node);
 
-				// Objects already accounted for can only be found among those
-				// which are referenced in more than one leaf
-				ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end();
-				
-				for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit)
-				  {
-					Intersectable *obj = *oit;						
-					
-					if (!obj->Mailed2())
-					  {
-						  //if (dummyPvs.AddSample(obj, 1.0f))++ pvs;
-						  obj->Mail2();
-						  ++pvs;
-					  }
-				  }
-				
-#endif
-			}
-			else // traverse tree
-			{
-				KdInterior *interior = static_cast<KdInterior *>(node);
-
-				tStack.push(interior->mFront);
-				tStack.push(interior->mBack);
-			}
+			tStack.push(interior->mFront);
+			tStack.push(interior->mBack);
 		}
 	}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GtpVisibility05.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GtpVisibility05.vcproj	(revision 2720)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GtpVisibility05.vcproj	(revision 2727)
@@ -770,12 +770,4 @@
 				</File>
 				<File
-					RelativePath=".\IntelRayCaster.h"
-					>
-				</File>
-				<File
-					RelativePath=".\InternalRayCaster.h"
-					>
-				</File>
-				<File
 					RelativePath=".\Intersectable.h"
 					>
@@ -855,8 +847,4 @@
 				<File
 					RelativePath=".\Ray.h"
-					>
-				</File>
-				<File
-					RelativePath=".\RayCaster.h"
 					>
 				</File>
@@ -988,12 +976,4 @@
 				</File>
 				<File
-					RelativePath=".\IntelRayCaster.cpp"
-					>
-				</File>
-				<File
-					RelativePath=".\InternalRayCaster.cpp"
-					>
-				</File>
-				<File
 					RelativePath=".\Intersectable.cpp"
 					>
@@ -1052,8 +1032,4 @@
 				</File>
 				<File
-					RelativePath=".\RayCaster.cpp"
-					>
-				</File>
-				<File
 					RelativePath=".\RayInfo.cpp"
 					>
@@ -1132,4 +1108,32 @@
 				</File>
 			</Filter>
+		</Filter>
+		<Filter
+			Name="raycaster"
+			>
+			<File
+				RelativePath=".\IntelRayCaster.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\IntelRayCaster.h"
+				>
+			</File>
+			<File
+				RelativePath=".\InternalRayCaster.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\InternalRayCaster.h"
+				>
+			</File>
+			<File
+				RelativePath=".\RayCaster.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\RayCaster.h"
+				>
+			</File>
 		</Filter>
 	</Files>
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2726)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2727)
@@ -1573,7 +1573,7 @@
 	int i = 0;
 
-	// $ tmp matt: somehow this is not properly initialised
-	ClearErrorBuffer();
-	cout << "here4 " << mPvsErrorBuffer.size() << endl;
+	// $matt tmp: somehow this is not properly initialised
+	//ClearErrorBuffer();
+	
 	for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i) 
 	{
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ReverseGvs.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ReverseGvs.cpp	(revision 2686)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ReverseGvs.cpp	(revision 2727)
@@ -411,5 +411,5 @@
 
 	if (counter < 50) {
-	  sprintf(filename, "reverse_rays_%03d.x3d", counter++);
+	  sprintf_s(filename, "reverse_rays_%03d.x3d", counter++);
 	  
 	  VssRay tRay(origin, termination, NULL, NULL);
@@ -454,10 +454,10 @@
 Vector3
 ReverseGvs::ComputeSilhouetteTerminationMutation(const VssRay &ray,
-																const Vector3 &origin,
-																const AxisAlignedBox3 &box,
-																const Vector3 &U,
-																const Vector3 &V,
-																const float radius
-																)
+												 const Vector3 &origin,
+												 const AxisAlignedBox3 &box,
+												 const Vector3 &U,
+												 const Vector3 &V,
+												 const float radius
+												 )
 {
 #ifdef GTP_INTERNAL
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2726)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2727)
@@ -425,4 +425,5 @@
 	castTimer.Entry();
 	// cast single ray to check if a triangle was missed
+	// note: not efficient!!
 	VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell);
 	castTimer.Exit();
@@ -433,10 +434,10 @@
 	if (!newRay) return castRays;
 
+	rayTimer.Entry();
+
 	// new triangle discovered? => add new ray to queue
-	rayTimer.Entry();
 	HandleRay(newRay);
+
 	rayTimer.Exit();
-
-
 
 #else
@@ -795,5 +796,5 @@
 	castTimer.Exit();
 
-	mGvsStats.mReverseSamples += reverseRays.size();
+	mGvsStats.mReverseSamples += (int)reverseRays.size();
 
 	return true;
@@ -809,12 +810,12 @@
 	simpleRays.clear();
 
-	
 	generationTimer.Entry();
+
 	ViewCellBorderBasedDistribution vcStrat(*this, mCurrentViewCell);
-    GenerateRays(numSamples, *mDistribution, simpleRays, sInvalidSamples);
+	GenerateRays(numSamples, *mDistribution, simpleRays, sInvalidSamples);
+
 	generationTimer.Exit();
 
-	//cout << "sr: " << simpleRays.size() << endl;
-	// generate vss rays
+	// cast generated samples 
 	static VssRayContainer samples;
 	samples.clear();
@@ -823,7 +824,33 @@
 	const bool pruneInvalidRays = true;
 	
+#if 0
 	castTimer.Entry();
+
 	CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays);
+	
 	castTimer.Exit();
+
+#else
+	static SimpleRayContainer jitteredRays;
+
+	for (size_t i = 0; i < simpleRays.size(); ++ i)
+	{
+		SimpleRay mainRay = simpleRays[i];
+		
+		jitteredRays.clear();
+		jitteredRays.push_back(mainRay);
+
+		generationTimer.Entry();
+
+		GenerateJitteredRays(jitteredRays, mainRay, 15, 0);
+
+		generationTimer.Exit();
+		castTimer.Entry();
+
+		CastRays(jitteredRays, samples, castDoubleRays, pruneInvalidRays);
+
+		castTimer.Entry();
+	}
+#endif
 
 	// add to ray queue
@@ -832,5 +859,5 @@
 	initialTimer.Exit();
 
-	return (int)simpleRays.size();
+	return (int)samples.size();
 }
 
@@ -1434,5 +1461,6 @@
 	int oldContribution = 0;
 	int passSamples = 0;
-	for (int i = 0; i < 0; ++ i)
+
+	for (int i = 0; i < 2; ++ i)
 		mGenericStats[i] = 0;
 
@@ -1558,30 +1586,33 @@
 		mGvsStats.mPvsCost = 0; // todo objectPvs.EvalPvsCost();
 	}
-	else if (0) // compute pvs kd nodes that intersect view cell
-	{
-		ObjectContainer mykdobjects;
-
-		// extract kd pvs
-		ObjectContainer::const_iterator it, it_end = mTrianglePvs.end();
-
-		for (it = mTrianglePvs.begin(); it != it_end; ++ it)
-		{
-			Intersectable *obj = *it;
-			// find intersecting objects not yet in pvs (i.e., only unmailed)
-			mKdTree->CollectKdObjects(obj->GetBox(), mykdobjects);
-		}
-
-		// add pvs
-		it_end = mykdobjects.end();
-
-		for (it = mykdobjects.begin(); it != it_end; ++ it)
-		{
-			mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f);
-		}
-
-		cout << "added " << (int)mykdobjects.size() << " new objects " << endl;
-
-		mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize();
-		mGvsStats.mPvsCost = mCurrentViewCell->GetPvs().EvalPvsCost();
+	else
+	{
+		 if (0) // compute pvs kd nodes that intersect view cell
+		 {
+			 ObjectContainer mykdobjects;
+
+			 // extract kd pvs
+			 ObjectContainer::const_iterator it, it_end = mTrianglePvs.end();
+
+			 for (it = mTrianglePvs.begin(); it != it_end; ++ it)
+			 {
+				 Intersectable *obj = *it;
+				 // find intersecting objects not yet in pvs (i.e., only unmailed)
+				 mKdTree->CollectKdObjects(obj->GetBox(), mykdobjects);
+			 }
+
+			 // add pvs
+			 it_end = mykdobjects.end();
+
+			 for (it = mykdobjects.begin(); it != it_end; ++ it)
+			 {
+				 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f);
+			 }
+		 
+			 cout << "added " << (int)mykdobjects.size() << " new objects " << endl;
+		 }
+
+		 mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize();
+		 mGvsStats.mPvsCost = mCurrentViewCell->GetPvs().EvalPvsCost();
 
 	}
@@ -1602,5 +1633,5 @@
 	     << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl;
 
-	cout << "invalid samples ratio: " << (float)sInvalidSamples / mGvsStats.mPerViewCellSamples << endl;
+	//cout << "invalid samples ratio: " << (float)sInvalidSamples / mGvsStats.mPerViewCellSamples << endl;
 
 	float rayTime = rayTimer.TotalTime();
