Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1934)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1941)
@@ -1553,28 +1553,28 @@
 	}
 
-	// only use a subset of the rays for visibility based heuristics
-	if (mUseCostHeuristics && useVisibilityBasedHeuristics)
+	// if #rays high consider only use a subset of the rays for 
+	// visibility based heuristics
+	VssRay::NewMail();
+
+	if ((mMaxTests < tData.mNumRays) &&	 mUseCostHeuristics && useVisibilityBasedHeuristics)
 	{
 		VssRayContainer rays;
+
 		// maximal 2 objects share the same ray
 		rays.reserve(tData.mNumRays * 2);
 		CollectRays(tData.mNode->mObjects, rays);
 
-		const float prop = (float)mMaxTests / (float)tData.mNumRays;
-
-		VssRay::NewMail();
+		const float prop = (float)mMaxTests / (float)rays.size();
 
 		VssRayContainer::const_iterator rit, rit_end = rays.end();
 
-		int nRays = 0;
-
+		// mail rays which will not be considered
 		for (rit = rays.begin(); rit != rit_end; ++ rit)
 		{
-			if ((mMaxTests >= (int)rays.size()) || (Random(1.0f) < prop))
+			if (Random(1.0f) > prop)
 			{
 				(*rit)->Mail();
-				++ nRays;
 			}
-		}
+		}		
 	}
 
@@ -1839,5 +1839,5 @@
 								  ViewCellContainer &viewCells,
 								  const bool setCounter,
-								  const bool onlyMailedRays) const
+								  const bool onlyUnmailedRays) const
 {
 	ViewCell::NewMail();
@@ -1849,5 +1849,5 @@
 	{
 		// always use only mailed objects
-		numRays += CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays);
+		numRays += CollectViewCells(*oit, viewCells, true, setCounter, onlyUnmailedRays);
 	}
 
@@ -1860,5 +1860,5 @@
 								  const bool useMailBoxing,
 								  const bool setCounter,
-								  const bool onlyMailedRays) const
+								  const bool onlyUnmailedRays) const
 {
 	VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end();
@@ -1870,5 +1870,5 @@
 		VssRay *ray = (*rit);
 
-		if (onlyMailedRays && !ray->Mailed())
+		if (onlyUnmailedRays && ray->Mailed())
 		{
 			continue;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1935)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1941)
@@ -125,5 +125,5 @@
   if (mUseFalseColors)
 	SetupFalseColor(object->mId);
-  
+  glColor3f(1, 1,1);
 
   switch (object->Type()) {
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1933)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1941)
@@ -822,5 +822,5 @@
 						 ViewCellContainer &viewCells,
 						 const bool setCounter,
-						 const bool onlyMailedRays) const;
+						 const bool onlyUnmailedRays) const;
 
 	/** Collects view cells which see an object.
@@ -828,5 +828,5 @@
 		only unmailed object should pass
 		@param setCounter counter for the sweep algorithm
-		@param onlyMailedRays if only mailed rays should be considered
+		@param onlyUnmailedRays if only unmailed rays should be considered
 	*/
 	int CollectViewCells(Intersectable *object, 
@@ -834,5 +834,5 @@
 						 const bool useMailBoxing,
 						 const bool setCounter,
-						 const bool onlyMailedRays) const;
+						 const bool onlyUnmailedRays) const;
 
 	/** Counts the view cells of this object. note: only
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h	(revision 1941)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h	(revision 1941)
@@ -0,0 +1,74 @@
+#ifndef __GLOBALLINESRENDERER_H
+#define __GLOBALLINESRENDERER_H
+
+#include "common.h"
+#include "Containers.h"
+
+class RenderTexture;
+
+namespace GtpVisibilityPreprocessor {
+
+class Beam;
+class Intersectable;
+class Preprocessor;
+class GlRenderer;
+
+struct VssRayContainer;
+
+class GlobalLinesRenderer
+{
+public:
+	/*GlobalLinesRenderer(RenderTexture *buffer1, 
+						RenderTexture *buffer2, 
+						Preprocessor *preprocessor,
+						GlRenderer *renderer);
+*/
+	GlobalLinesRenderer(Preprocessor *preprocessor, GlRenderer *renderer);
+
+	~GlobalLinesRenderer();
+
+	void CastGlobalLines(Beam &beam, const int samples);
+
+	void InitGl();
+
+	/** Computes rays from information gained with hw sampling
+	*/
+	void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays);
+
+	float GetPixelError(int &pvsSize);
+
+	int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
+
+	void RenderObject(Intersectable *obj);
+void DrawGeometry();
+void Run();
+protected:
+
+	void ProcessDepthBuffer();
+
+	/** Draws the geometry for one pass.
+	*/
+	
+
+	void ApplyDepthPeeling(Beam &beam, const int samples);
+
+	void SwitchRenderTextures();
+
+	void SetupProjection(const Vector3 &viewPoint, 
+						 const Beam &beam);
+
+	RenderTexture *mNewBuffer;
+	RenderTexture *mOldBuffer;
+
+	Preprocessor *mPreprocessor;
+	int mMaxDepth;
+
+	GlRenderer *mRenderer;
+};
+
+extern GlobalLinesRenderer *globalLinesRenderer;
+
+};
+
+#endif
+
