Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_soda
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_soda	(revision 2564)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_soda	(revision 2587)
@@ -14,5 +14,5 @@
 
 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
--rss_distributions=direction \
+-rss_distributions=mutation+object_direction+spatial \
 -view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
 -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2584)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj	(revision 2587)
@@ -411,4 +411,10 @@
 			<File
 				RelativePath=".\HashPvs.h">
+			</File>
+			<File
+				RelativePath=".\HavranRayCaster.cpp">
+			</File>
+			<File
+				RelativePath=".\HavranRayCaster.h">
 			</File>
 			<File
@@ -1053,10 +1059,10 @@
 			</File>
 			<File
+				RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h">
+			</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_map.h">
 			</File>
@@ -1075,4 +1081,71 @@
 			<File
 				RelativePath=".\sparsehash\src\windows\stl_hash_fun.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="havran"
+			Filter="">
+			<File
+				RelativePath=".\havran\allocgo2.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\allocgo2.h">
+			</File>
+			<File
+				RelativePath=".\havran\configh.h">
+			</File>
+			<File
+				RelativePath=".\havran\ktb.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\ktb.h">
+			</File>
+			<File
+				RelativePath=".\havran\ktb8b.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\ktb8b.h">
+			</File>
+			<File
+				RelativePath=".\havran\ktbai.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\ktbai.h">
+			</File>
+			<File
+				RelativePath=".\havran\ktball.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\ktball.h">
+			</File>
+			<File
+				RelativePath=".\havran\ktbconf.h">
+			</File>
+			<File
+				RelativePath=".\havran\ktbftrav.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\ktbtrav.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\ktbtrav.h">
+			</File>
+			<File
+				RelativePath=".\havran\raypack.h">
+			</File>
+			<File
+				RelativePath=".\havran\sbbox.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\sbbox.h">
+			</File>
+			<File
+				RelativePath=".\havran\subdivm.h">
+			</File>
+			<File
+				RelativePath=".\havran\timer.cpp">
+			</File>
+			<File
+				RelativePath=".\havran\timer.h">
 			</File>
 		</Filter>
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2584)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2587)
@@ -717,5 +717,5 @@
 		if (1 && mShowRays) 
 		{
-			RenderRays(mViewCellsManager->mVizBuffer.GetRays());
+			RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod);
 		}
 	}
@@ -880,4 +880,5 @@
 	mSpatialFilterSize = 0.01;
 	mPvsSize = 0;
+	mRayVisualizationMethod = 0;
 	mRenderError = 0.0f;
 	mShowRays = false;
@@ -925,4 +926,10 @@
 	connect(mControlWidget, SIGNAL(SetShowWeightedTriangles(bool)), this, SLOT(SetShowWeightedTriangles(bool)));
 
+	connect(mControlWidget, SIGNAL(UseConstColorForRayViz(bool)), this, SLOT(UseConstColorForRayViz(bool)));
+	connect(mControlWidget, SIGNAL(UseRayLengthForRayViz(bool)), this, SLOT(UseRayLengthForRayViz(bool)));
+	connect(mControlWidget, SIGNAL(SetShowContribution(bool)), this, SLOT(SetShowContribution(bool)));
+	connect(mControlWidget, SIGNAL(SetShowDistribution(bool)), this, SLOT(SetShowDistribution(bool)));
+
+
 	connect(mControlWidget,
 		SIGNAL(SetShowRays(bool)),
@@ -1543,16 +1550,17 @@
 	QRadioButton *rb1, *rb2, *rb3, *rb4, *rb5;
 	
+	rb1 = new QRadioButton("wireframe", parent);
+	rb1->setText("wireframe");
+	connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWireFrame(bool)));
+
 	// Create a check box to be in the group box
-	rb1 = new QRadioButton("piercing rays", parent);
-	rb1->setText("piercing rays");
+	rb2 = new QRadioButton("piercing rays", parent);
+	rb2->setText("piercing rays");
 	//vl->addWidget(rb1);
-	connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool)));
-
-	rb2 = new QRadioButton("pvs size", parent);
-	rb2->setText("pvs size");
-	connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool)));
-
-	rb3 = new QRadioButton("wireframe", parent);
-	rb3->setText("wireframe");
+	connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool)));
+
+	rb3 = new QRadioButton("pvs size", parent);
+	rb3->setText("pvs size");
+	connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool)));
 	
 	rb4 = new QRadioButton("weighted rays", parent);
@@ -1565,42 +1573,4 @@
 
 	QGroupBox *groupBox = new QGroupBox("Visualization options");
-
-	QVBoxLayout *vbox2 = new QVBoxLayout;
-    
-	vbox2->addWidget(rb3);
-	vbox2->addWidget(rb1);
-	vbox2->addWidget(rb2);
-	vbox2->addWidget(rb4);
-	vbox2->addWidget(rb5);
-	
-	rb3->setChecked(true);
-
-	vbox2->addStretch(1);
-	groupBox->setLayout(vbox2);
-
-	return groupBox;
-}
-
-
-
-QGroupBox *QtRendererControlWidget::CreateRenderCostPanel(QWidget *parent)
-{
-	QRadioButton *rb1, *rb2, *rb3;
-	
-	// Create a check box to be in the group box
-	rb1 = new QRadioButton("triangles", parent);
-	rb1->setText("triangles");
-	//vl->addWidget(rb1);
-	connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedTriangles(bool)));
-
-	rb2 = new QRadioButton("distance weighted pvs", parent);
-	rb2->setText("distance weighted");
-	connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedPvs(bool)));
-
-	rb3 = new QRadioButton("distance weighted triangles", parent);
-	rb3->setText("distance weighted triangles");
-	connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedTriangles(bool)));
-
-	QGroupBox *groupBox = new QGroupBox("Render cost options");
 
 	QVBoxLayout *vbox2 = new QVBoxLayout;
@@ -1609,6 +1579,82 @@
 	vbox2->addWidget(rb2);
 	vbox2->addWidget(rb3);
-	
-	rb2->setChecked(true);
+	vbox2->addWidget(rb4);
+	vbox2->addWidget(rb5);
+	
+	rb1->setChecked(true);
+
+	vbox2->addStretch(1);
+	groupBox->setLayout(vbox2);
+
+	return groupBox;
+}
+
+
+
+QGroupBox *QtRendererControlWidget::CreateRenderCostPanel(QWidget *parent)
+{
+	QRadioButton *rb1, *rb2, *rb3;
+	
+	// Create a check box to be in the group box
+	rb1 = new QRadioButton("triangles", parent);
+	rb1->setText("triangles");
+	connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedTriangles(bool)));
+
+	rb2 = new QRadioButton("distance weighted pvs", parent);
+	rb2->setText("distance weighted");
+	connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedPvs(bool)));
+
+	rb3 = new QRadioButton("distance weighted triangles", parent);
+	rb3->setText("distance weighted triangles");
+	connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedTriangles(bool)));
+
+	QGroupBox *groupBox = new QGroupBox("Render cost options");
+
+	QVBoxLayout *vbox2 = new QVBoxLayout;
+    
+	vbox2->addWidget(rb1);
+	vbox2->addWidget(rb2);
+	vbox2->addWidget(rb3);
+	
+	rb1->setChecked(true);
+
+	vbox2->addStretch(1);
+	groupBox->setLayout(vbox2);
+
+	return groupBox;
+}
+
+
+QGroupBox *QtRendererControlWidget::CreateRayVisualizationPanel(QWidget *parent)
+{
+	QRadioButton *rb1, *rb2, *rb3, *rb4;
+	
+	// Create a check box to be in the group box
+	rb1 = new QRadioButton("const color", parent);
+	rb1->setText("const color");
+	//vl->addWidget(rb1);
+	connect(rb1, SIGNAL(toggled(bool)), SIGNAL(UseConstColorForRayViz(bool)));
+
+	rb2 = new QRadioButton("ray length", parent);
+	rb2->setText("ray length");
+	connect(rb2, SIGNAL(toggled(bool)), SIGNAL(UseRayLengthForRayViz(bool)));
+	
+	rb3 = new QRadioButton("contribution", parent);
+	rb3->setText("contribution");
+	connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowContribution(bool)));
+	
+	rb4 = new QRadioButton("distribution", parent);
+	rb4->setText("distribution");
+	connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowDistribution(bool)));
+
+	QGroupBox *groupBox = new QGroupBox("Ray visualization options");
+	QVBoxLayout *vbox2 = new QVBoxLayout;
+    
+	vbox2->addWidget(rb1);
+	vbox2->addWidget(rb2);
+	vbox2->addWidget(rb3);
+	vbox2->addWidget(rb4);
+	
+	rb1->setChecked(true);
 
 	vbox2->addStretch(1);
@@ -1740,4 +1786,8 @@
 	QGroupBox *groupBox2 = CreateRenderCostPanel(hbox);
 	vh->addWidget(groupBox2, 0, 0);
+
+	
+	QGroupBox *groupBox3 = CreateRayVisualizationPanel(hbox);
+	vh->addWidget(groupBox3, 0, 0);
 
 	//////////////////////////////////
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2584)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2587)
@@ -98,4 +98,5 @@
   
   QGroupBox *CreateRenderCostPanel(QWidget *parent);
+  QGroupBox *CreateRayVisualizationPanel(QWidget *parent);
 
 
@@ -141,4 +142,9 @@
   void SetShowWeightedTriangles(bool);
   void SetShowDistanceWeightedPvs(bool);
+
+  void UseConstColorForRayViz(bool);
+  void UseRayLengthForRayViz(bool);
+  void SetShowContribution(bool);
+  void SetShowDistribution(bool);
 };
 
@@ -195,4 +201,6 @@
 	Vector3 mDummyViewPoint;
 
+	int mRayVisualizationMethod;
+
 	QtRendererControlWidget *mControlWidget;
 
@@ -430,4 +438,24 @@
 		mShowWeightedTriangles = b;
 		updateGL();
+	}
+
+	void UseConstColorForRayViz(bool b)
+	{
+		mRayVisualizationMethod = 0;
+	}
+    
+	void UseRayLengthForRayViz(bool b)
+	{
+		mRayVisualizationMethod = 1;
+	}
+
+	void SetShowContribution(bool b)
+	{
+		mRayVisualizationMethod = 2;
+	}
+    
+	void SetShowDistribution(bool b)
+	{
+		mRayVisualizationMethod = 3;
 	}
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2586)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2587)
@@ -13,4 +13,6 @@
 #include "BvHierarchy.h"
 #include "KdTree.h"
+#include "SamplingStrategy.h"
+
 
 #ifdef USE_CG
@@ -200,5 +202,5 @@
 
 
-void GlRenderer::RenderRays(const VssRayContainer &rays)
+void GlRenderer::RenderRays(const VssRayContainer &rays, int colorType)
 {
 	VssRayContainer::const_iterator it = rays.begin(), it_end = rays.end();
@@ -206,11 +208,47 @@
 	glBegin(GL_LINES);
 	
+	float importance;
+
 	for (; it != it_end; ++it) 
 	{
 		VssRay *ray = *it;
-		const float importance = log10(1e3*ray->mWeightedPvsContribution)/3.0f;
-		
-		//glColor3f(1.0f, 0.0f, 0.0f);
-		glColor3f(importance, importance, importance);
+
+		switch (colorType)
+		{
+		case 0:
+			glColor3f(1.0f, 0.0f, 0.0f);
+			break;
+
+		case 1:
+			importance = 1.0f * ray->Length() /  Magnitude(mViewCellsManager->GetViewSpaceBox().Diagonal());
+			glColor3f(importance, importance, importance);
+			break;
+
+		case 2:
+			importance = log10(1e3 * ray->mPvsContribution) / 3.0f;
+			glColor3f(importance, importance, importance);
+			break;
+
+		case 3:
+			{
+				// nested switches ok?
+				switch (ray->mDistribution)
+				{
+				case SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION:
+					glColor3f(1, 0, 0);
+					break;
+				case SamplingStrategy::MUTATION_BASED_DISTRIBUTION:
+					glColor3f(0, 1, 0);
+					break;
+				case SamplingStrategy::DIRECTION_BASED_DISTRIBUTION:
+					glColor3f(0, 1, 1);
+					break;
+					case SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION:
+					glColor3f(1, 1, 0);
+					break;
+				}
+			}
+		}		
+
 		glVertex3fv(&ray->mOrigin.x);
 		glVertex3fv(&ray->mTermination.x);
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2543)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2587)
@@ -129,5 +129,5 @@
 
   void
-  RenderRays(const VssRayContainer &rays);
+  RenderRays(const VssRayContainer &rays, int colorType = 0);
 
   void
