Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_arena
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_arena	(revision 2586)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_arena	(revision 2593)
@@ -14,8 +14,8 @@
 
 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
--rss_distributions=spatial \
+-rss_distributions=mutation+object_direction+spatial \
 -view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
 -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \
--preprocessor_ray_cast_method=1 \
+-preprocessor_ray_cast_method=2 \
 -preprocessor_stats=$PREFIX-i-spatial-b1-n4a.log \
 -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4a.hlog \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2592)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2593)
@@ -670,5 +670,5 @@
 		cout << "loading objects from " << buf << endl;
 
-		// load objects which will be used as pvs entries
+		// load scene objects used as pvs entries
 		ObjectContainer pvsObjects;
 		if (0) LoadObjects(buf, pvsObjects, mObjects);
@@ -731,7 +731,5 @@
 			{
 				if (!mViewCellsManager->LoadViewCellsGeometry(vcGeomFilename, extrudeBaseTriangles))
-				{
 					cerr << "loading view cells geometry failed" << endl;
-				}
 			}
 			else
@@ -1616,3 +1614,13 @@
 
 
-}
+bool Preprocessor::AddGeometry(const string &filename,
+							   ObjectContainer &pvsObjects, 
+							   const ObjectContainer &preprocessorObjects)
+{
+//	bool success = LoadBinaryObj(filename, mSceneGraph->GetRoot(), &mFaseParents);
+	bool success = LoadBinaryObj(filename, mSceneGraph->GetRoot(), NULL);
+
+	return success;
+}
+
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2587)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2593)
@@ -366,4 +366,10 @@
 			<File
 				RelativePath="..\src\Exporter.h">
+			</File>
+			<File
+				RelativePath=".\FilterBasedDistribution.cpp">
+			</File>
+			<File
+				RelativePath=".\FilterBasedDistribution.h">
 			</File>
 			<File
@@ -1059,8 +1065,8 @@
 			</File>
 			<File
+				RelativePath=".\sparsehash\src\windows\hash_fun.h">
+			</File>
+			<File
 				RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h">
-			</File>
-			<File
-				RelativePath=".\sparsehash\src\windows\hash_fun.h">
 			</File>
 			<File
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2591)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2593)
@@ -717,5 +717,5 @@
 		if (1 && mShowRays) 
 		{
-			RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod, mShowDistribution);
+			RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod, mShowDistribution, 1);
 		}
 	}
@@ -731,6 +731,8 @@
 	if (!mTopView)
 		GlRenderer::SetupCamera();
-	else {
-		if (0) {
+	else 
+	{
+		if (0) 
+		{
 			float dist = Magnitude(mSceneGraph->GetBox().Diagonal())*0.05;
 			Vector3 pos = mViewPoint - dist*Vector3(mViewDirection.x,
@@ -940,5 +942,6 @@
 	connect(mControlWidget,	SIGNAL(SetShowRays(bool)), this, SLOT(SetShowRays(bool)));
 
-	resize(1000, 500);
+	// setting the size here
+	resize(800, 600);
 	mControlWidget->show();
 }
@@ -1525,5 +1528,5 @@
 		const float importance = (vcRatio - minRatio) * scale;
 	
-		if (i < 20)
+		if (0 && (i < 20))
 		{
 			cout << "pvs1: " << vc->GetPvs().GetSize() << " pvs2: " << compareInfo[i].mPvsSize << " importance: " << importance << endl;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 2573)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp	(revision 2593)
@@ -46,5 +46,5 @@
 QSize QtGlViewer::sizeHint() const 
 {
-	return QSize(500, 500);
+	return QSize(640, 480);
 }
   
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2588)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2593)
@@ -179,9 +179,9 @@
 	Vector3 GetParentNormal(const int index) const;
 
-	/** Sets a Preprocessor thread.
+	/** Sets a preprocessor thread.
 	*/
 	void SetThread(PreprocessorThread *t);
 
-	/** Returns a Preprocessor thread.
+	/** Returns a preprocessor thread.
 	*/
 	PreprocessorThread *GetThread() const;
@@ -194,7 +194,10 @@
 
 	static bool LoadObjects(const string &filename,
-				ObjectContainer &pvsObjects, 
-				const ObjectContainer &preprocessorObject);
-
+							ObjectContainer &pvsObjects, 
+							const ObjectContainer &preprocessorObject);
+
+	/** Adds new geometry to the existing one.
+	*/
+	bool AddGeometry(const string &filename, ObjectContainer &pvsObjects, const ObjectContainer &prepObjects);
 
 	/////////////////////////
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2588)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2593)
@@ -2735,5 +2735,4 @@
 #endif
 
-	bool hasContri = false;
 	// if ray not outside of view space
 	float relContribution = 0.0f;
@@ -2746,13 +2745,9 @@
 		hasAbsContribution = viewCell->GetPvs().AddSampleDirtyCheck(obj, ray.mPdf);
 		//hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf);
-#if MYSTATS
 		
 		if (hasAbsContribution)
 		{
 			UpdateStatsForViewCell(viewCell, obj);
-			hasContri = true;
-		}
-#endif
-
+		}
 	}
 	else 
@@ -2796,5 +2791,5 @@
 #endif
 
-	return hasContri;
+	return hasAbsContribution;
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2591)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2593)
@@ -14,4 +14,5 @@
 #include "KdTree.h"
 #include "SamplingStrategy.h"
+#include "Preprocessor.h"
 
 
@@ -145,14 +146,8 @@
 void GlRenderer::RenderIntersectable(Intersectable *object)
 {
-	if (!object)
+	if (!object || (object->mRenderedFrame == mCurrentFrame))
 		return;
 
-	if (object->mRenderedFrame == mCurrentFrame)
-		return;
-
 	object->mRenderedFrame = mCurrentFrame;
-
-	//if (object->Mailed())	return;
-	//object->Mail();
 
 	glPushAttrib(GL_CURRENT_BIT);
@@ -205,11 +200,11 @@
 
 
-void GlRenderer::RenderRays(const VssRayContainer &rays, int colorType, int showDistribution)
-{
+void GlRenderer::RenderRays(const VssRayContainer &rays, int colorType, int showDistribution, int maxAge)
+{
+	float importance;
+
+	glBegin(GL_LINES);
+
 	VssRayContainer::const_iterator it = rays.begin(), it_end = rays.end();
-
-	glBegin(GL_LINES);
-	
-	float importance;
 
 	for (; it != it_end; ++it) 
@@ -221,5 +216,6 @@
 			((ray->mDistribution == SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION) && ((showDistribution & 2) == 0)) ||
 			((ray->mDistribution == SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION) && ((showDistribution & 4) == 0)) ||
-			((ray->mDistribution == SamplingStrategy::MUTATION_BASED_DISTRIBUTION) && ((showDistribution & 8) == 0)))
+			((ray->mDistribution == SamplingStrategy::MUTATION_BASED_DISTRIBUTION) && ((showDistribution & 8) == 0)) ||
+			((mViewCellsManager->GetPreprocessor()->mPass - ray->mPass) >= maxAge))
 		{
 			continue;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h	(revision 2575)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h	(revision 2593)
@@ -44,10 +44,4 @@
   int mMailbox;
 	
-  // side of the ray - used for the ray classification
-  //  char mSide;
-	
-  // computed t
-  //  float mT;
-
   // inverse of the ray size
   float mInvSize;
@@ -76,18 +70,18 @@
   short mPass;
 
-  // Distribution used to generate this ray
+  /// Distribution used to generate this ray
   short mDistribution;
   
-  // number of cells where this ray made a contribution to the PVS
+  /// number of cells where this ray made a contribution to the PVS
   int mPvsContribution;
   
-  // sum of relative ray contributions per object
+  /// sum of relative ray contributions per object
   float mRelativePvsContribution;
 
-  // weighted contribution to the pvs (based on the pass the ray was casted at)
-  // computed by the prperocessor
+  /// weighted contribution to the pvs (based on the pass the ray was casted at)
+  /// computed by the prperocessor
   float mWeightedPvsContribution;
 
-  // probability of this ray
+  /// probability of this ray
   float mPdf;
   
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 2582)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp	(revision 2593)
@@ -338,5 +338,5 @@
 		// $$matt
 		preprocessor->renderer = 
-			new QtGlRendererBuffer(1024, 1024,
+			new QtGlRendererBuffer(512, 512,
 			preprocessor->mSceneGraph,
 			preprocessor->mViewCellsManager,
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2586)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2593)
@@ -67,5 +67,5 @@
 
   int lastEvaluation = 0;
-  //  int totalVssRays = 0;
+ 
   mPass = 0;
   
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp	(revision 2176)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp	(revision 2593)
@@ -68,5 +68,5 @@
 	else
 	{
-		mTermination = ray.Extrap(1e6);//TODO: should be Limits::Infinity
+		mTermination = ray.Extrap(1e6); //TODO: should be Limits::Infinity
 		mTerminationObject = NULL;
 	}
@@ -80,5 +80,4 @@
 	mFlags = 0;
 	Vector3 dir = GetDir();
-//mFlags |= BorderSample;
 #define BIDIRECTIONAL_RAY 0
 #if BIDIRECTIONAL_RAY
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2591)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2593)
@@ -30,9 +30,9 @@
 
 struct VssRayContainer;
-
-  struct GLUquadric;
-  
-struct PvsRenderStatistics {
-  
+struct GLUquadric;
+
+
+struct PvsRenderStatistics 
+{ 
   float maxError;
   float sumError;
@@ -43,5 +43,6 @@
   PvsRenderStatistics() { Reset(); }
   
-  void Reset() {
+  void Reset() 
+  {
 	maxError = 0.0f;
 	sumError = 0.0f;
@@ -58,20 +59,22 @@
 };
 
-	struct PvsCache {
-		
-		PvsCache():mViewCell(NULL), mUnfilteredPvsSize(0) {}
-
-		void Reset()
-		{ 
-			mViewCell = NULL; mPvs.Clear(); 
-			filteredBoxes.clear(); 
-			mUnfilteredPvsSize = 0;
-		}
-		
-		ViewCell *mViewCell;
-		ObjectPvs mPvs;
-		int mUnfilteredPvsSize;
-		vector<AxisAlignedBox3> filteredBoxes;
-	};
+
+struct PvsCache 
+{
+
+	PvsCache():mViewCell(NULL), mUnfilteredPvsSize(0) {}
+
+	void Reset()
+	{ 
+		mViewCell = NULL; mPvs.Clear(); 
+		filteredBoxes.clear(); 
+		mUnfilteredPvsSize = 0;
+	}
+
+	ViewCell *mViewCell;
+	ObjectPvs mPvs;
+	int mUnfilteredPvsSize;
+	vector<AxisAlignedBox3> filteredBoxes;
+};
 
 
@@ -129,5 +132,5 @@
 
   void
-  RenderRays(const VssRayContainer &rays, int colorType = 0, int showDistribution = 15);
+  RenderRays(const VssRayContainer &rays, int colorType = 0, int showDistribution = 15, int maxAge = 9999999);
 
   void
