Index: trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env	(revision 385)
+++ trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env	(revision 389)
@@ -129,5 +129,5 @@
 	
 	maxPolyCandidates 50
-	maxRayCandidates 50
+	maxRayCandidates 0
 	
 	Termination {
@@ -135,5 +135,5 @@
 		maxRays 300
 		maxPolygons 0
-		maxDepth 80
+		maxDepth 50
 		
 		# axis aligned splits
@@ -151,8 +151,14 @@
 	}
 	
-		
-	# if split polys are stored for visualization
-	storeSplitPolys false
-	# x3d visualization of the split planes
-	exportSplits true
+	
+	Visualization
+	{
+		# if split polys are stored for visualization
+		storeSplitPolys false
+		# x3d visualization of the split planes
+		exportSplits true
+		# how much samples should be used in visualization
+	
+		samples 2000
+	}
 }
Index: trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp	(revision 382)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp	(revision 389)
@@ -1203,5 +1203,5 @@
 	  optInt,
 	  "-bsp_postprocessing_samples=",
-	  "206000");
+	  "200000");
 
   RegisterOption("BspTree.Construction.sideTolerance",
@@ -1255,9 +1255,4 @@
 		 "100");
 
-  RegisterOption("BspTree.storeSplitPolys",
-		 optBool,
-		 "-bsp_store_split_polys=",
-		 "false");
-
   RegisterOption("BspTree.splitPlaneStrategy",
 		 optString,
@@ -1279,9 +1274,20 @@
 	  "-view_cells_max_viewcells=",
 	  "0");
-  
-  RegisterOption("BspTree.exportSplits",
+
+  
+  RegisterOption("Bsptree.Visualization.samples",
+	  optInt,
+	  "-bsp_visualization_samples=",
+	  "20000");
+
+  RegisterOption("BspTree.Visualization.exportSplits",
 	  optBool,
-	  "-bsp_exportSplits",
+	  "-bsp_visualization.exportSplits",
 	  "false");
+
+  RegisterOption("BspTree.Visualization.storePolys",
+		 optBool,
+		 "-bsp_visualization_store_polys=",
+		 "false");
 
   RegisterOption("Preprocessor.type",
Index: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 385)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 389)
@@ -1580,5 +1580,5 @@
 	environment->GetFloatValue("BspTree.AxisAligned.splitBorder", sSplitBorder);
 	
-	environment->GetBoolValue("BspTree.storeSplitPolys", sStoreSplitPolys);
+	environment->GetBoolValue("BspTree.Visualization.storePolys", sStoreSplitPolys);
 
 	environment->GetFloatValue("BspTree.Construction.sideTolerance", Vector3::sDistTolerance);
@@ -1735,8 +1735,10 @@
 				farChild = in->GetBack(); // plane splits ray			
 			}
-			else // ray and plane are coincident // WHAT TO DO IN THIS CASE ?
+			else // ray and plane are coincident
+			// WHAT TO DO IN THIS CASE ?
 			{
-				node = in->GetFront();
-				continue;
+				break;
+				//node = in->GetFront();
+				//continue;
 			}
 
Index: trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 388)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 389)
@@ -15,4 +15,6 @@
   environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples);
   environment->GetIntValue("ViewCells.PostProcessing.samples", mPostProcessSamples);
+  environment->GetIntValue("BspTree.visualizationSamples", mVisualizationSamples);
+
   mKdPvsDepth = 100;
   mStats.open("stats.log");
@@ -605,5 +607,5 @@
 		//-- visualization of the BSP splits
 		bool exportSplits = false;
-		environment->GetBoolValue("BspTree.exportSplits", exportSplits);
+		environment->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits);
 		
 		cout << "exporting splits ... ";
@@ -726,5 +728,6 @@
 	}
 	// save rays for post processing
-	else if ((int)mSampleRays.size() < mPostProcessSamples)
+	else if ((int)mSampleRays.size() < mPostProcessSamples) ||
+			(((int)mSampleRays.size() < mVisualizationSamples))
 	{
 		mSampleRays.push_back(new Ray(ray));
@@ -740,12 +743,16 @@
 	vector<Ray::BspIntersection>::const_iterator iit;
 
-	for (rit = rays.begin(); rit != rays.end(); ++ rit)
+	int limit = min((int)mSampleRays.size(), mPostProcessSamples);
+
+	for (int i = 0; i < limit; ++i)
 	{  
+		Ray *ray = mSamplesRays[i];
+
 		// traverse leaves stored in the rays and compare and merge consecutive
 		// leaves (i.e., the neighbors in the tree)
-		if ((*rit)->bspIntersections.empty())
+		if (ray->bspIntersections.empty())
 			continue;
 
-		iit = (*rit)->bspIntersections.begin();
+		iit = ray->bspIntersections.begin();
 
 		BspLeaf *previousLeaf = (*iit).mLeaf;
@@ -834,5 +841,5 @@
 
 	//-- some rays for output
-	const int raysOut = min((int)mSampleRays.size(), 20000);
+	const int raysOut = min((int)mSampleRays.size(), mVisualizationSamples);
 	vector<Ray *> vcRays[leafOut];
 
@@ -991,4 +998,8 @@
 			Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() << endl;
 
+			
+			// export rays piercing this view cell
+			exporter->ExportRays(vcRays[i], 10000, RgbColor(0, 1, 0));
+
 			m.mDiffuseColor = RgbColor(1, 0, 0);
 			exporter->SetForcedMaterial(m);
