Index: /trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env	(revision 321)
+++ /trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env	(revision 322)
@@ -101,11 +101,11 @@
 	#splitPlaneStrategy 72
 	
-	splitPlaneStrategy 72
+	splitPlaneStrategy 1
 	
 	maxCandidates 50
 	
 	Termination {
-		maxPolysForAxisAligned 100
-		maxPolygons 30
+		maxPolysForAxisAligned 1000
+		maxPolygons 50
 		maxDepth 100
 	}
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h	(revision 321)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h	(revision 322)
@@ -27,5 +27,5 @@
 };
 
-class BspTreeStatistics // TODO: should have common superclass with KdTreeStatistics
+class BspTreeStatistics
 {
 public:
@@ -40,28 +40,14 @@
   // minimal depth
   int minDepth;
-  // total number of query domains
-  int queryDomains;
-  // total number of ray references
-  int rayRefs;
-  // refs in non empty leafs
-  int rayRefsNonZeroQuery;
-  // total number of query references
-  int objectRefs;
-  // nodes with zero queries
-  int zeroQueryNodes;
   // max depth nodes
   int maxDepthNodes;
   // max number of rays per node
   int maxObjectRefs;
-  // number of dynamically added ray refs
-  int addedRayRefs;
-  // number of dynamically removed ray refs
-  int removedRayRefs;
-  // accumulated depth (used to compute average)
+   // accumulated depth (used to compute average)
   int accumDepth;
   // number of initial polygons
   int polys;
-  /// number of view cells in leaf
-  int viewCellLeaves;
+  /// number of view cells different to the view cell representing unbounded space.
+  int viewCells;
 
   // Constructor
@@ -80,16 +66,10 @@
 	  nodes = 0;
 	  splits = 0;
-	  rays = queryDomains = 0;
-	  rayRefs = rayRefsNonZeroQuery = objectRefs = 0;
-	  zeroQueryNodes = 0;
       maxDepthNodes = 0;
-
-	  maxObjectRefs = 0;
-	  addedRayRefs = removedRayRefs = 0;
 	  maxDepth = 0;
 	  minDepth = 99999;
 	  polys = 0;
 	  accumDepth = 0;
-	  viewCellLeaves = 0;
+	  viewCells = 0;
   }
 
@@ -331,8 +311,4 @@
 	BspNode *GetRoot() const;
 
-	/** If the view cell polygons are stored in the nodes.
-	*/
-	bool StorePolys() const;
-
 	/** Exports Bsp tree to file.
 	*/
@@ -376,5 +352,5 @@
 		@returns the cost of the candidate split plane
 	*/
-	float EvalSplitPlane(PolygonContainer &polys, 
+	float SplitPlaneCost(PolygonContainer &polys, 
 						 const Plane3 &candidatePlane);
 
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 319)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp	(revision 322)
@@ -25,10 +25,14 @@
 
 //-- factors for bsp tree split plane heuristics
+
 float BspTree::sLeastSplitsFactor = 1.0f;
-float BspTree::sBalancedPolysFactor = 2.0f;
-float BspTree::sBalancedViewCellsFactor = 2.0f;
-float BspTree::sVerticalSplitsFactor = 1.0f; // very important criterium for 2.5d scenes
+float BspTree::sBalancedPolysFactor = 1.0f;
+float BspTree::sBalancedViewCellsFactor = 1.0f;
+// NOTE:  very important criterium for 2.5d scenes
+float BspTree::sVerticalSplitsFactor = 1.0f;
 float BspTree::sLargestPolyAreaFactor = 1.0f;
 float BspTree::sBlockedRaysFactor = 1.0f;
+
+bool BspTree::sStoreSplitPolys = false;
 
 /** Evaluates split plane classification with respect to the plane's 
@@ -41,6 +45,4 @@
 float BspTree::sBalancedPolysTable[] = {-1, 1, 0, 0};
 
-//int counter = 0;
-
 /****************************************************************/
 /*                  class BspNode implementation                */
@@ -179,13 +181,10 @@
 		{
 			case Polygon3::COINCIDENT:
-				//Debug << "coincident" << endl;	
 				coincident.push_back(poly);
 				break;			
 			case Polygon3::FRONT_SIDE:	
-				//Debug << "front" << endl;
 				frontPolys.push_back(poly);
 				break;
 			case Polygon3::BACK_SIDE:
-				//Debug << "back" << endl;
 				backPolys.push_back(poly);
 				break;
@@ -262,7 +261,5 @@
 BspTree::BspTree(ViewCell *viewCell): 
 mRoot(NULL), 
-mRootCell(viewCell),
-//mStoreSplitPolys(true)
-mStoreSplitPolys(false)
+mRootCell(viewCell)
 {
 	Randomize(); // initialise random generator for heuristics
@@ -280,9 +277,4 @@
 	app << setprecision(4);
 
-	app << "#N_RAYS Number of rays )\n"
-		<< rays << endl;
-	app << "#N_DOMAINS  ( Number of query domains )\n"
-		<< queryDomains <<endl;
-
 	app << "#N_NODES ( Number of nodes )\n" << nodes << "\n";
 
@@ -292,25 +284,4 @@
 
 	app << "#N_SPLITS ( Number of splits )\n" << splits << "\n";
-
-	app << "#N_RAYREFS ( Number of rayRefs )\n" <<
-	rayRefs << "\n";
-
-	app << "#N_RAYRAYREFS  ( Number of rayRefs / ray )\n" <<
-	rayRefs/(double)rays << "\n";
-
-	app << "#N_LEAFRAYREFS  ( Number of rayRefs / leaf )\n" <<
-	rayRefs/(double)Leaves() << "\n";
-
-	app << "#N_MAXOBJECTREFS  ( Max number of rayRefs / leaf )\n" <<
-	maxObjectRefs << "\n";
-
-	app << "#N_NONEMPTYRAYREFS  ( Number of rayRefs in nonEmpty leaves / non empty leaf )\n" <<
-	rayRefsNonZeroQuery/(double)(Leaves() - zeroQueryNodes) << "\n";
-
-	app << "#N_LEAFDOMAINREFS  ( Number of query domain Refs / leaf )\n" <<
-	objectRefs/(double)Leaves() << "\n";
-
-	app << "#N_PEMPTYLEAVES  ( Percentage of leaves with zero query domains )\n"<<
-	zeroQueryNodes*100/(double)Leaves() << endl;
 
 	app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maxdepth )\n"<<
@@ -323,12 +294,5 @@
 	app << "#AVGDEPTH ( average depth )\n" << AvgDepth() << endl;
 
-	app << "#N_ADDED_RAYREFS  ( Number of dynamically added ray references )\n"<<
-	addedRayRefs << endl;
-
-	app << "#N_REMOVED_RAYREFS  ( Number of dynamically removed ray references )\n" <<
-	removedRayRefs << endl;
-
-	app << "#N_INPUT_POLYGONS (number of input polygons )\n" <<
-		polys << endl;
+	app << "#N_INPUT_POLYGONS (number of input polygons )\n" <<	polys << endl;
 
 	app << "#N_ROUTPUT_INPUT_POLYGONS ( ratio polygons after subdivision / input polygons )\n" <<
@@ -394,5 +358,5 @@
 
 			//-- filter view cell polygons down the tree until a leaf is reached
-			if ((int)tData.mPolygons->size() > 0)
+			if (!tData.mPolygons->empty())
 			{
 				PolygonContainer *frontPolys = new PolygonContainer();
@@ -408,5 +372,5 @@
 										coincident,
 										splits, 
-										mStoreSplitPolys);
+										sStoreSplitPolys);
 				
 				// extract view cells associated with the split polygons
@@ -425,11 +389,18 @@
 
 				// don't need coincident polygons anymore
-				interior->ProcessPolygons(&coincident, mStoreSplitPolys);
+				interior->ProcessPolygons(&coincident, sStoreSplitPolys);
 
 				mStat.splits += splits;
 
 				// push the children on the stack
-				tStack.push(BspTraversalData(interior->GetFront(), frontPolys, tData.mDepth + 1, frontViewCell));
-				tStack.push(BspTraversalData(interior->GetBack(), backPolys, tData.mDepth + 1, backViewCell));
+				tStack.push(BspTraversalData(interior->GetFront(), 
+											 frontPolys, 
+											 tData.mDepth + 1, 
+											 frontViewCell));
+
+				tStack.push(BspTraversalData(interior->GetBack(), 
+											 backPolys, 
+											 tData.mDepth + 1, 
+											 backViewCell));
 			}
 
@@ -439,9 +410,9 @@
 		else // reached leaf => subdivide current viewcell
 		{
-			//if (tData.mPolygons->size() > 0) Debug << "Subdividing further: polygon size: " << (int)tData.mPolygons->size() << ", view cell: " << tData.mViewCell << endl;
 			BspNode *root = Subdivide(tStack, tData);		
 
 			if (viewCells && root->IsLeaf())
-			{	// generate new view cell for each leaf
+			{	
+				// generate new view cell for each leaf
 				ViewCell *viewCell = new ViewCell();
 				viewCells->push_back(viewCell);
@@ -459,6 +430,5 @@
 {
 	FaceContainer::const_iterator fi;
-	int polysNum = 0;
-
+	
 	// copy the face data to polygons
 	for (fi = mesh->mFaces.begin(); fi != mesh->mFaces.end(); ++ fi)
@@ -467,27 +437,28 @@
 		poly->mParent = parent; // set parent intersectable
 		polys.push_back(poly);
-
-		//if (!poly->Valid())
-		//	Debug << "Input polygon not valid: " << *poly << endl << "Area: " << poly->GetArea() << endl;
-		
-		++ polysNum;
-	}
-	return polysNum;
-}
-
-int BspTree::AddToPolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects)
-{
-	int limit = (maxObjects > 0) ? Min((int)viewCells.size(), maxObjects) : (int)viewCells.size();
+	}
+	return (int)mesh->mFaces.size();
+}
+
+int BspTree::AddToPolygonSoup(const ViewCellContainer &viewCells, 
+							  PolygonContainer &polys, 
+							  int maxObjects)
+{
+	int limit = (maxObjects > 0) ? 
+		Min((int)viewCells.size(), maxObjects) : (int)viewCells.size();
   
-	for (int i = 0; i < limit; ++i)
-	{//if ((i == 12) ||(i==14))
+	int polysSize = 0;
+
+	for (int i = 0; i < limit; ++ i)
+	{
 		if (viewCells[i]->GetMesh()) // copy the mesh data to polygons
 		{
 			mBox.Include(viewCells[i]->GetBox()); // add to BSP tree aabb
-			AddMeshToPolygons(viewCells[i]->GetMesh(), polys, viewCells[i]);
-		}
-	}
-
-	return (int)polys.size();
+			polysSize += AddMeshToPolygons(viewCells[i]->GetMesh(), 
+										   polys, viewCells[i]);
+		}
+	}
+
+	return polysSize;
 }
 
@@ -644,5 +615,5 @@
 		// clean up
 		// remaining polygons are discarded or added to node
-		leaf->ProcessPolygons(tData.mPolygons, mStoreSplitPolys);
+		leaf->ProcessPolygons(tData.mPolygons, sStoreSplitPolys);
 		DEL_PTR(tData.mPolygons);
 
@@ -682,5 +653,5 @@
 	
 	// don't need coincident polygons anymore
-	interior->ProcessPolygons(&coincident, mStoreSplitPolys);
+	interior->ProcessPolygons(&coincident, sStoreSplitPolys);
 
 	// push the children on the stack
@@ -753,5 +724,5 @@
 							coincident, 
 							splits, 
-							mStoreSplitPolys);
+							sStoreSplitPolys);
 	
  	mStat.splits += splits;
@@ -916,14 +887,10 @@
 			return Plane3(norm, position);
 		}
-		/*int axis = box.Size().DrivingAxis();
-		Vector3 norm(0,0,0); norm[axis] = 1;
-		Vector3 position = (box.Min()[axis] + box.Max()[axis]) * 0.5f;
-		return Plane3(norm, position);*/
 	}
 
 	// simplest strategy: just take next polygon
-	if (sSplitPlaneStrategy & NEXT_POLYGON)
-	{
-		return polys.front()->GetSupportingPlane();
+	if (sSplitPlaneStrategy & RANDOM_POLYGON)
+	{
+		return polys[Random((int)polys.size())]->GetSupportingPlane();
 	}
 
@@ -949,5 +916,5 @@
 		
 		// evaluate current candidate
-		float candidateCost = EvalSplitPlane(polys, candidatePlane);
+		float candidateCost = SplitPlaneCost(polys, candidatePlane);
 			
 		if (candidateCost < lowestCost)
@@ -964,6 +931,5 @@
 int BspTree::GetNextCandidateIdx(int currentIdx, PolygonContainer &polys)
 {
-	int candidateIdx = Random(currentIdx--);
-	
+	int candidateIdx = Random(currentIdx --);
 	//Debug << "new candidate " << candidateIdx << endl;
 
@@ -976,5 +942,5 @@
 }
 
-float BspTree::EvalSplitPlane(PolygonContainer &polys, 
+float BspTree::SplitPlaneCost(PolygonContainer &polys, 
 							  const Plane3 &candidatePlane)
 {
@@ -1029,9 +995,5 @@
 		{
 			if (classification == Polygon3::COINCIDENT)
-			{		
-				float area = (*it)->GetArea();
-				//Debug << "polygon area: " << area << " ";
-				sumPolyArea += area;
-			}
+				sumPolyArea += (*it)->GetArea();
 			//totalArea += area;
 		}
@@ -1150,4 +1112,5 @@
 	environment->GetFloatValue("MeshKdTree.splitBorder", sSplitBorder);
 	environment->GetFloatValue("MeshKdTree.Termination.maxCostRatio", sMaxCostRatio);
+	environment->GetBoolValue("BspTree.storeSplitPolys", sStoreSplitPolys);
 
     Debug << "BSP max depth: " << sTermMaxDepth << endl;
@@ -1156,6 +1119,6 @@
 	
 	Debug << "Split plane strategy: ";
-	if (sSplitPlaneStrategy & NEXT_POLYGON)
-		Debug << "next polygon ";
+	if (sSplitPlaneStrategy & RANDOM_POLYGON)
+		Debug << "random polygon ";
 	if (sSplitPlaneStrategy & AXIS_ALIGNED)
 		Debug << "axis aligned ";
@@ -1211,9 +1174,4 @@
 }
 
-bool BspTree::StorePolys() const
-{
-	return mStoreSplitPolys;
-}
-
 void BspTree::EvaluateLeafStats(const BspTraversalData &data)
 {
@@ -1222,8 +1180,5 @@
 
 	if (data.mDepth >= sTermMaxDepth)
-	{
 		++ mStat.maxDepthNodes;
-	}
-
 	// store maximal and minimal depth
 	if (data.mDepth > mStat.maxDepth)
@@ -1235,10 +1190,12 @@
 	mStat.accumDepth += data.mDepth;
 
-	if (leaf->mViewCell)
-		++ mStat.viewCellLeaves;
+	if (leaf->mViewCell != mRootCell)
+		++ mStat.viewCells;
 
 #ifdef _DEBUG
-	Debug << "BSP Traversal data. Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), #polygons: " << 
-	  data.mPolygons->size() << " (max: " << sTermMaxPolygons << ")" << endl;
+	Debug << "BSP Traversal data. Depth: " << data.mDepth 
+		  << " (max: " << mTermMaxDepth << "), #polygons: " 
+		  << data.mPolygons->size() << " (max: " 
+		  << sTermMaxPolygons << ")" << endl;
 #endif
 }
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp	(revision 321)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp	(revision 322)
@@ -57,8 +57,7 @@
 	
 	  p->BuildBspTree();
-	  
+	  p->Export("vc_bsptree.x3d", false, false, true);
 	  p->BspTreeStatistics(Debug);
-	  p->Export("vc_bsptree2.x3d", false, false, true);
-	 
+
 	  bool exportSplits = false;
 	  environment->GetBoolValue("BspTree.exportSplits", exportSplits);
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp	(revision 318)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp	(revision 322)
@@ -403,5 +403,5 @@
 	//ViewCellContainer foundViewCells;
 
-	if (tree.StorePolys())
+	if (BspTree::sStoreSplitPolys)
 	{
 		while (!tStack.empty()) 
@@ -411,13 +411,10 @@
 			tStack.pop();
 	
-			if (tree.StorePolys()) // extract the polygons
-			{
-				PolygonContainer::const_iterator it;
-				PolygonContainer::const_iterator it_end = node->GetPolygons()->end();
-
-				for (it = node->GetPolygons()->begin(); it != it_end; ++ it)
-					ExportPolygon(*it);
-			}
-
+			PolygonContainer::const_iterator it;
+			PolygonContainer::const_iterator it_end = node->GetPolygons()->end();
+
+			for (it = node->GetPolygons()->begin(); it != it_end; ++ it)
+				ExportPolygon(*it);
+			
 			if (!node->IsLeaf()) 
 			{
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp	(revision 321)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp	(revision 322)
@@ -165,5 +165,4 @@
 		// 3 vertices enough to decide coincident
 		else if (((++ count) >= 3) && !onFrontSide && !onBackSide)
-		//	&& (DotProd(GetSupportingPlane().mNormal, plane.mNormal)  > 0))
 		{   
 			return COINCIDENT; 
@@ -179,5 +178,5 @@
 		return FRONT_SIDE;
 	}
-	//if (DotProd(GetNormal(), plane.mNormal)  < 0) return FRONT_SIDE;
+
 	return COINCIDENT; // plane and polygon are coincident
 }
Index: /trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
===================================================================
--- /trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 321)
+++ /trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 322)
@@ -254,6 +254,4 @@
 		int index = 0;
 			
-		Debug << "starting new loop " << totalSamples << endl;
-
 		// construct Bsp tree if not
 		if ((mViewCellsType == Preprocessor::BSP_VIEW_CELLS) &&
@@ -262,5 +260,5 @@
 			BuildBspTree();
 		}
-Debug << "here" << totalSamples << endl;
+
 		for (i = 0; i < objects.size(); i++) {
 			KdNode *nodeToSample = NULL;
@@ -471,76 +469,71 @@
     delete exporter;
   }
-
   if (1) {
-	
-      if (mViewCellsType == BSP_VIEW_CELLS)
-	  {
-		   for (int j = 0; j < pvsViewCells.size(); ++ j)
-		   {
-			   ViewCell *vc = pvsViewCells[j];
-
-			   Intersectable::NewMail();
-    
-			   char s[64]; sprintf(s, "bsp-pvs%04d.x3d", j);
-			   Exporter *exporter = Exporter::GetExporter(s);
-			   exporter->SetFilled();
-
-			   ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin();
-
-			   Material m;//= RandomMaterial();
-			   m.mDiffuseColor = RgbColor(0, 1, 0);
-			   exporter->SetForcedMaterial(m);
-
-			   exporter->ExportViewCell(vc);
-
-			   Debug << "pvs size: " << (int)vc->GetPvs().GetSize() << " of " << (int)objects.size();
-			   Debug << " exporting rays: " << (int)vcRays[j].size() << endl;
-
-			   exporter->SetWireframe();
-			   
-			   m.mDiffuseColor = RgbColor(1, 0, 1);
-			   exporter->SetForcedMaterial(m);
-
-			   if (1)
-			   {
-				   exporter->ExportViewCells(mViewCells);
-			   }
-
-			   // export rays piercing this view cell
-			   exporter->ExportRays(vcRays[j], 1000, RgbColor(0, 1, 0));
-
-			   m.mDiffuseColor = RgbColor(1, 0, 0);
-			   exporter->SetForcedMaterial(m);
-
-			   // output pvs of view cell
-			   for (; it != vc->GetPvs().mEntries.end(); ++ it) 
-			   {
-				   Intersectable *intersect = (*it).first;
-				   if (!intersect->Mailed())
-				   {
-					   exporter->ExportIntersectable(intersect);
-					   intersect->Mail();
-				   }			
-			   }
-
-			   // output rest of the objects
-			   if (1)
-			   {
-				   Material m;//= RandomMaterial();
-				   m.mDiffuseColor = RgbColor(0, 0, 1);
-				   exporter->SetForcedMaterial(m);
-                 
-				   for (int j = 0; j < objects.size(); ++ j)
-					   if (!objects[j]->Mailed())
-					   {
-						   exporter->ExportIntersectable(objects[j]);
-						   objects[j]->Mail();
-					   }
-			   }
-			   DEL_PTR(exporter);
-		   }
-	  }	  
-
-    for (int k=0; k < pvsOut; k++) {
+  if (mViewCellsType == BSP_VIEW_CELLS)
+  {
+	  for (int j = 0; j < pvsViewCells.size(); ++ j)
+		{
+			ViewCell *vc = pvsViewCells[j];
+
+			Intersectable::NewMail();
+
+			char s[64]; sprintf(s, "bsp-pvs%04d.x3d", j);
+			Exporter *exporter = Exporter::GetExporter(s);
+			exporter->SetFilled();
+
+			ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin();
+
+			Material m;//= RandomMaterial();
+			m.mDiffuseColor = RgbColor(0, 1, 0);
+			exporter->SetForcedMaterial(m);
+
+			exporter->ExportViewCell(vc);
+
+			Debug << "pvs size: " << (int)vc->GetPvs().GetSize() << " of " << (int)objects.size();
+			Debug << " exporting rays: " << (int)vcRays[j].size() << endl;
+
+			exporter->SetWireframe();
+
+			// export view cells
+			m.mDiffuseColor = RgbColor(1, 0, 1);
+			exporter->SetForcedMaterial(m);
+			exporter->ExportViewCells(mViewCells);
+			
+			// export rays piercing this view cell
+			exporter->ExportRays(vcRays[j], 1000, RgbColor(0, 1, 0));
+
+			m.mDiffuseColor = RgbColor(1, 0, 0);
+			exporter->SetForcedMaterial(m);
+
+			// output pvs of view cell
+			for (; it != vc->GetPvs().mEntries.end(); ++ it) 
+			{
+				Intersectable *intersect = (*it).first;
+				if (!intersect->Mailed())
+				{
+					exporter->ExportIntersectable(intersect);
+					intersect->Mail();
+				}			
+			}
+
+			// output rest of the objects
+			if (1)
+			{
+				Material m;//= RandomMaterial();
+				m.mDiffuseColor = RgbColor(0, 0, 1);
+				exporter->SetForcedMaterial(m);
+                
+				for (int j = 0; j < objects.size(); ++ j)
+					if (!objects[j]->Mailed())
+					{
+						exporter->ExportIntersectable(objects[j]);
+						objects[j]->Mail();
+					}
+			}
+			DEL_PTR(exporter);
+		}
+  }  
+
+   for (int k=0; k < pvsOut; k++) {
       Intersectable *object = objects[k];
       char s[64];
