Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 2743)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h	(revision 2745)
@@ -179,5 +179,5 @@
 		with respect to the previous ray.
 	*/
-	void EnqueueRays(const VssRayContainer &samples);
+	int EnqueueRays(const VssRayContainer &samples);
 	/** Hepler function for adaptive border sampling. It finds 
 		new sample points around a triangle in a eps environment
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2743)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2745)
@@ -34,4 +34,6 @@
 static VizStruct currentViz;
 
+static int successfullReverseRays = 0;
+
 
 ///////////
@@ -200,5 +202,5 @@
 
 	mGvsStats.mReverseSamples += (int)reverseRays.size();
-	EnqueueRays(reverseRays);
+	successfullReverseRays = EnqueueRays(reverseRays);
 
 	return (int)reverseRays.size();
@@ -477,6 +479,16 @@
 
 	// cast reverse rays if necessary
-	if (USE_REVERSE_SAMPLING) castRays += CheckDiscontinuity(*newRay, hitTriangle, oldRay);
-	
+	if (USE_REVERSE_SAMPLING) 
+	{
+		castRays += CheckDiscontinuity(*newRay, hitTriangle, oldRay);
+	
+		// also test reverse direction
+		if (newRay->mTerminationObject)
+		{
+			TriangleIntersectable *tObj = static_cast<TriangleIntersectable *>(newRay->mTerminationObject);
+			castRays += CheckDiscontinuity(oldRay, tObj->GetItem(), *newRay);
+		}
+	}
+
 	if (GVS_DEBUG)
 		currentViz.enlargedTriangle.push_back(p);
@@ -604,5 +616,14 @@
 		{
 			if (USE_REVERSE_SAMPLING)
+			{
 				castRays += CheckDiscontinuity(*vssRays[i], hitTriangle, currentRay);
+				
+				// also test reverse direction
+				if (vssRays[i]->mTerminationObject)
+				{
+					TriangleIntersectable *tObj = static_cast<TriangleIntersectable *>(vssRays[i]->mTerminationObject);
+					castRays += CheckDiscontinuity(currentRay, tObj->GetItem(), *vssRays[i]);
+				}
+			}
 
 			castRays += SubdivideEdge(hitTriangle,
@@ -946,6 +967,7 @@
 
 
-void GvsPreprocessor::EnqueueRays(const VssRayContainer &samples)
-{
+int GvsPreprocessor::EnqueueRays(const VssRayContainer &samples)
+{
+	int success = 0;
 	rayTimer.Entry();
 
@@ -955,8 +977,10 @@
 	{
 		VssRay *ray = *vit;
-		HandleRay(ray);
+		if (HandleRay(ray)) ++ success;
 	}
 
 	rayTimer.Exit();
+
+	return success;
 }
 
@@ -1609,4 +1633,6 @@
 			cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl;
 			cout << "obj contri=" << mCurrentViewCell->GetPvs().GetSize() - oldPvsSize << " (of " << mMinContribution << ")" << endl;
+			cout << "successful reverse rays=" << successfullReverseRays << endl;
+			cout << "cast reverse rays=" << mGvsStats.mReverseSamples << endl;
 
 			// termination criterium
@@ -1618,5 +1644,7 @@
 			mGvsStats.mPassContribution = 0;
 			passSamples = 0;
+			successfullReverseRays = 0;
 			
+
 			// compute the pixel error of this visibility solution
 			if (1 && mEvaluatePixelError)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2744)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp	(revision 2745)
@@ -815,18 +815,21 @@
 	direction = UniformRandomVector(r[0], r[1]);
 	
-##if 0
-	origin = mViewCell->GetBox().GetRandomPoint();
-#else
-	origin = mViewCell->GetBox().GetUniformRandomSurfacePoint();
-
-	//origin = mViewCell->GetBox().GetRandomSurfacePoint();
-	//mViewCell->GetRandomEdgePoint(origin, normal);
-	//origin = Vector3(680.682, 189.552, -278.177);
-
-	// move a little bit back to avoid piercing through walls
-	// that bound the view cell
-	origin -= 0.01f * normal;
-#endif
-		
+
+	if (1)
+	{
+		origin = mViewCell->GetBox().GetRandomPoint();
+	}
+	else
+	{
+		origin = mViewCell->GetBox().GetUniformRandomSurfacePoint();
+
+		//origin = mViewCell->GetBox().GetRandomSurfacePoint();
+		//mViewCell->GetRandomEdgePoint(origin, normal);
+		//origin = Vector3(680.682, 189.552, -278.177);
+
+		// move a little bit back to avoid piercing through walls
+		// that bound the view cell
+		origin -= 1e-4f * normal;
+	}
 
 	static const float pdf = 1.0f;
