Index: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 379)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 380)
@@ -692,5 +692,5 @@
 
 	Debug << "**** Finished polygon extraction ****" << endl;
-	Debug << (int)polys->size() << " polys extracted from " << (int)rays->size() << " rays" << endl;
+	Debug << (int)polys->size() << " polys extracted from " << (int)sampleRays.size() << " rays" << endl;
 	Debug << "extraction time: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl;
 
@@ -786,4 +786,5 @@
 	ViewCell *backViewCell = mRootCell;
 
+	
 #ifdef _DEBUG	
 	if (frontPolys->empty() && backPolys->empty() && (coincident.size() > 2))
@@ -1650,10 +1651,10 @@
 	mStat.accumDepth += data.mDepth;
 	
-#ifdef _DEBUG
+//#ifdef _DEBUG
 	Debug << "BSP stats: "
 		  << "Depth: " << data.mDepth << " (max: " << sTermMaxDepth << "), "
 		  << "#polygons: " << (int)data.mPolygons->size() << " (max: " << sTermMaxPolygons << "), "
 		  << "#rays: " << (int)data.mRays->size() << " (max: " << sTermMaxRays << ")" << endl;
-#endif
+//#endif
 }
 
Index: trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h	(revision 373)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h	(revision 380)
@@ -74,9 +74,6 @@
 		@param contributingSamples samples contributing to pvs
 		@param sampleContributions contribution of the samples
-
-		@returns true if BSP tree has been constructed, false if not yet
-
 	*/
-	bool ProcessBspViewCells(Ray &ray,
+	void ProcessBspViewCells(Ray &ray,
 							 Intersectable *object,
 							 int faceIndex,
Index: trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp	(revision 379)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp	(revision 380)
@@ -187,19 +187,18 @@
 
 
-	if (maxPvs == 0)
+	if (maxPvs > 0)
 		mUseForcedMaterial = true;
 
 	for (it = viewCells.begin(); it != it_end; ++ it)
 	{
-		mForcedMaterial.mDiffuseColor.b = 1.0f;
-  
-		float importance = 0;
-
 		if (maxPvs > 0)
-			importance = (float)(*it)->GetPvs().GetSize() / (float)maxPvs;
-
-		mForcedMaterial.mDiffuseColor.r = importance;
-		mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r;
-		
+		{
+			mForcedMaterial.mDiffuseColor.b = 1.0f;
+  			float importance = (float)(*it)->GetPvs().GetSize() / (float)maxPvs;
+
+			mForcedMaterial.mDiffuseColor.r = importance;
+			mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r;
+		}
+
 		if ((*it)->GetMesh())
 			ExportViewCell(*it);
Index: trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 379)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 380)
@@ -557,6 +557,6 @@
 			if (exporter)
 			{
-				//exporter->ExportBspViewCellPartition(*mBspTree, stat.maxPvs);
-				exporter->ExportBspViewCellPartition(*mBspTree, 0);
+				exporter->ExportBspViewCellPartition(*mBspTree, stat.maxPvs);
+				//exporter->ExportBspViewCellPartition(*mBspTree, 0);
 				delete exporter;
 			}
@@ -592,6 +592,6 @@
 			if (exporter)
 			{
-				//exporter->ExportBspViewCellPartition(*mBspTree, stat.maxPvs);
-				exporter->ExportBspViewCellPartition(*mBspTree, 0);
+				exporter->ExportBspViewCellPartition(*mBspTree, stat.maxPvs);
+				//exporter->ExportBspViewCellPartition(*mBspTree, 0);
 				delete exporter;
 			}
@@ -686,5 +686,5 @@
 }
 
-bool SamplingPreprocessor::ProcessBspViewCells(Ray &ray,
+void SamplingPreprocessor::ProcessBspViewCells(Ray &ray,
 											   Intersectable *object,
 											   int faceIndex,
@@ -693,40 +693,41 @@
 {
 	// save rays for bsp tree construction
-	if ((BspTree::sConstructionMethod == BspTree::FROM_RAYS) &&
-		(mSampleRays.size() < mBspConstructionSamples))
+	if (!mBspTree)
 	{
-		// also add origin to sample in order to extract it as input polygons
-		MeshInstance *mi = dynamic_cast<MeshInstance *>(object);
-		ray.sourceObject = Ray::Intersection(0.0, mi, faceIndex);
+		if ((BspTree::sConstructionMethod == BspTree::FROM_RAYS) &&
+			((int)mSampleRays.size() < mBspConstructionSamples))
+		{
+			// also add origin to sample in order to extract it as input polygons
+			MeshInstance *mi = dynamic_cast<MeshInstance *>(object);
+			ray.sourceObject = Ray::Intersection(0.0, mi, faceIndex);
 							
-        mSampleRays.push_back(new Ray(ray));
-		
-		return false;
-	}
-	
-	if (!mBspTree) // construct BSP tree using the samples
+			mSampleRays.push_back(new Ray(ray));
+			Debug << "abba " << mSampleRays.size() << endl;
+		}
+		else
+		{
+			// construct BSP tree using the samples
+			cout << "building bsp tree from " << mSampleRays.size() << " samples " << endl;
+			BuildBspTree();
+		
+			// add contributions of saved samples to PVS
+			contributingSamples += mBspTree->GetStat().contributingSamples;
+			sampleContributions += mBspTree->GetStat().sampleContributions;
+
+			BspTreeStatistics(Debug);	
+
+			if (0) Export("vc_bsptree.x3d", false, false, true);
+
+			// throw away samples because BSP leaves not stored in order 
+			// Need ordered rays for post processing => collect new rays
+			CLEAR_CONTAINER(mSampleRays);
+		}
+	}
+	// save rays for post processing
+	else if ((int)mSampleRays.size() < mPostProcessSamples)
 	{
-        cout << "building bsp tree from " << mSampleRays.size() << " samples " << endl;
-		BuildBspTree();
-		
-		// add contributions of saved samples to PVS
-		contributingSamples += mBspTree->GetStat().contributingSamples;
-		sampleContributions += mBspTree->GetStat().sampleContributions;
-
-		BspTreeStatistics(Debug);	
-
-		if (0) Export("vc_bsptree.x3d", false, false, true);
-
-		// throw away samples because BSP leaves not stored in order 
-		// Need ordered rays for post processing => collect new rays
-		CLEAR_CONTAINER(mSampleRays);
-	}
-	
-	if ((int)mSampleRays.size() < mPostProcessSamples)
-	{
+		Debug << "police " << mSampleRays.size() << endl;
 		mSampleRays.push_back(new Ray(ray));
 	}
-
-	return true;
 }
 
