Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1789)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1790)
@@ -1956,18 +1956,4 @@
 }
 
-/*
-void
-ViewCellsManager::AddSampleContributions(const VssRayContainer &rays)
-{
-  if (!ViewCellsConstructed())
-	return;
-
-  VssRayContainer::const_iterator it, it_end = rays.end();
-cout <<"here60"<<endl;
-  for (it = rays.begin(); it != it_end; ++ it) {
-	AddSampleContributions(*(*it));
-  }
-}
-*/
 
 int ViewCellsManager::GetMinPvsSize() const
@@ -1983,35 +1969,9 @@
 }
 
-/*
-void
-ViewCellsManager::AddSampleContributions(VssRay &ray)
-{cout << "here12" << endl;
-	// assumes viewcells have been stored...
-	ViewCellContainer *viewcells = &ray.mViewCells;
-	ViewCellContainer::const_iterator it;
-
-	if (!ray.mTerminationObject)
-		return;
-
-	Intersectable *obj = GetIntersectable(ray, true);
-
-	for (it = viewcells->begin(); it != viewcells->end(); ++it) 
-	{
-		ViewCell *viewcell = *it;
-		if (viewcell->GetValid()) 
-		{
-			Intersectable *entry = GetIntersectable(ray, true);
-			if (entry)    
-				// if ray not outside of view space
-				viewcell->GetPvs().AddSample(entry, ray.mPdf);
-		}
-	}
-}
-*/
 
 float ViewCellsManager::ComputeSampleContribution(VssRay &ray,
 												  const bool addRays,
 												  const bool storeViewCells)
-{cout << "$$$$$$$$$$$$$4here10" << endl;
+{
 	ViewCellContainer viewcells;
 
@@ -6041,4 +6001,5 @@
 	
 
+#define PVS_ADD_DIRTY 1
 float VspOspViewCellsManager::ComputeSampleContribution(VssRay &ray,
 														const bool addRays,
@@ -6094,10 +6055,11 @@
 			{
 				// todo: maybe not correct for kd node pvs
-			/*	if (viewcell->GetPvs().GetSampleContribution(
-					terminationObj, ray.mPdf, contribution))
+				if (viewcell->GetPvs().GetSampleContribution(
+							terminationObj, ray.mPdf, contribution))
 				{
 					++ ray.mPvsContribution;
 				}
-				ray.mRelativePvsContribution += contribution;*/
+
+				ray.mRelativePvsContribution += contribution;
 			}
 
@@ -6109,5 +6071,5 @@
 #if SAMPLE_ORIGIN_OBJECTS
 
-		/*	if (originObj && 
+			if (originObj && 
 				viewcell->GetPvs().GetSampleContribution(originObj,
 														 ray.mPdf,
@@ -6116,5 +6078,5 @@
 				++ ray.mPvsContribution;
 				ray.mRelativePvsContribution += contribution;
-			}*/
+			}
 #endif
 		}
@@ -6135,44 +6097,22 @@
 
 		//$$JB hack
-		float contrib;
-		//viewCell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf, contrib);
-		viewCell->GetPvs().AddSample(terminationObj, ray.mPdf);//, contrib);
-
-		if (viewCell->GetPvs().GetSize() == 50)
-		//if (viewCell->GetPvs().RequiresResort())
-		{Intersectable::NewMail();
-		cout << "\nbefore sort: " << viewCell->GetPvs().GetLastSorted() << " \n";
-			ObjectPvsIterator pit = viewCell->GetPvs().GetIterator(); int i = 0;
-			while (pit.HasMoreEntries())
-			{		
-				ObjectPvsEntry entry = pit.Next();
-                Intersectable *object = entry.mObject;
-
-				if ((i ++) == viewCell->GetPvs().GetLastSorted())
-					cout << "| ";
-				
-				//if (object->Mailed())	cout << "error!!"<<endl;
-				object->Mail();
-				cout << (int)object << " ";
-			}
-
-			//viewCell->GetPvs().Sort();
-			
-			/*cout << "\nafter sort\n";
-			pit = viewCell->GetPvs().GetIterator(); i = 0;
-			while (pit.HasMoreEntries())
-			{		
-				ObjectPvsEntry entry = pit.Next();
-                Intersectable *object = entry.mObject;
-
-				if ((i ++) == viewCell->GetPvs().GetLastSorted())
-					cout << "| ";	
-				cout << (int)object << " ";
-			}*/
-		}
-		//else cout << "b";
+
+#if PVS_ADD_DIRTY
+		viewCell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf);
+#else
+		viewCell->GetPvs().AddSample(terminationObj, ray.mPdf);
+#endif
+
 #if SAMPLE_ORIGIN_OBJECTS
-		//viewCell->GetPvs().AddSample(originObj, ray.mPdf);
+#if PVS_ADD_DIRTY
+		viewCell->GetPvs().AddSampleDirtyCheck(originObj, ray.mPdf);
+#else
+		viewCell->GetPvs().AddSample(originObj, ray.mPdf);
 #endif
+#endif
+		if (viewCell->GetPvs().RequiresResort())
+		{
+			viewCell->GetPvs().Sort();			
+		}
 	}
 
@@ -6310,4 +6250,5 @@
 			//////////////
 			// filtered stats
+
 			sprintf(suffix, "-%09d-eval-filter.log", castSamples);
 			const string filename2 = string(statsPrefix) + string(suffix);
