Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2722)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2723)
@@ -2,5 +2,5 @@
 
 # add bin to path
-export PATH=../bin:../:$PATH
+export PATH=../bin:$PATH
 
 #TARGET=debug
@@ -11,19 +11,19 @@
 echo "starting $TARGET version"
 
-SCENE=../data/Arena/arena-high-lods.obj
-SCENE=../data/Arena/arena_trees.obj
-VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz
-SCENE=../data/vienna/vienna_cropped.obj
-#SCENE=../data/vienna/city_full_hp.obj
+#SCENE=../data/Arena/arena-high-lods.obj
+#VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz
+#SCENE=../data/vienna/vienna_cropped.obj
+#SCENE=../data/roofs_new.obj
+SCENE=../data/vienna/city_full_hp.obj
 #SCENE=../data/vienna/vienna_rep.obj
 
+
 #SCENE=../data/vienna/vienna_cropped.obj
-#VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 
-#VIEWPOINTS=../data/vienna/testwalk.vp
-VIEWPOINTS=../data/arena/arena_key.vp
+VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
+VIEWPOINTS=../data/vienna/testwalk.vp
 
 #LOG_PREFIX=../src/SG08/rebut-arena-pixel2
 #LOG_PREFIX=../src/SG08/full
-LOG_PREFIX=../src/SG08/arena_trees
+LOG_PREFIX=../src/SG08/city_full
 
 ENVIRONMENT=gvs.env
@@ -42,6 +42,6 @@
 -gvs_samples_per_pass=1000000 \
 -gvs_initial_samples=16 \
--gvs_max_viewcells=20000 \
--gvs_min_contribution=4000 \
+-gvs_max_viewcells=5000 \
+-gvs_min_contribution=500 \
 -gvs_per_viewcell=true \
 -preprocessor_detect_empty_viewspace+ \
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2722)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2723)
@@ -8,12 +8,12 @@
 
 
-SCENE=../data/vienna/vienna_cropped.obj
+#SCENE=../data/vienna/vienna_cropped.obj
 #SCENE=../data/vienna/city_full.obj
-#SCENE=../data/vienna/city_full_hp.obj
+SCENE=../data/vienna/city_full_hp.obj
 #SCENE=../data/vienna/vienna_rep.obj
 
 VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
 #VIEWCELLS=../data/vienna/vienna_cropped-seq-3000-false-20-viewcells.xml.gz
-#VIEWCELLS=../data/vienna/vienna_cropped-57000-viewcells.xml.gz
+VIEWCELLS=../data/vienna/vienna_cropped-57000-viewcells.xml.gz
 VIEWPOINTS=../data/vienna/testwalk.vp
 
@@ -40,5 +40,5 @@
  -preprocessor_detect_empty_viewspace+ \
  -preprocessor_use_vbos- \
- -preprocessor_ray_cast_method=1 \
+ -preprocessor_ray_cast_method=3 \
  -view_cells_random_viewpoint_list=$VIEWPOINTS \
  demo1.env
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp	(revision 2670)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ObjectPvs.cpp	(revision 2723)
@@ -161,7 +161,5 @@
 
 	Intersectable::NewMail2();
-	//KdNode::NewMail();
-	dummyPvs.Clear();
-
+	
 	ObjectPvsIterator pit = GetIterator();
 
@@ -196,3 +194,4 @@
 }
 
+
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2722)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2723)
@@ -1702,5 +1702,5 @@
 	float renderCost = 0;
 	int i = 0;
-	cout<<"size: " << vc->GetPvs().GetSize() << endl;
+	
 	// first mark all objects from this pvs
 	while (pit.HasMoreEntries()) 	
@@ -1731,4 +1731,9 @@
 			//}
 		}
+		else if (obj->Type() == Intersectable::SCENEGRAPHLEAF_INTERSECTABLE)
+		{
+			renderCost += (float)static_cast<SceneGraphLeafIntersectable *>(obj)->GetItem()->mGeometry.size();
+		}
+		
 	}
 
@@ -1759,9 +1764,10 @@
   for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 
   {
-	  ObjectPvs &pvs = (*vit)->GetPvs();
+	  ViewCell *vc = *vit;
+	  ObjectPvs &pvs = vc->GetPvs();
 
 	  bool pvsChanged = false;
 
-	  if (Overlap(box, (*vit)->GetBox())) 
+	  if (Overlap(box, vc->GetBox())) 
 	  {
 		  pvs.Clear();
@@ -1771,6 +1777,6 @@
 	  else 
 	  {
-		  //	cout<<(*vit)->GetBox()<<" "<<box<<endl;
-		  shadowVolume.Init((*vit)->GetBox(), box);
+		  //cout<<vc->GetBox()<<" "<<box<<endl;
+		  shadowVolume.Init(vc->GetBox(), box);
 		  if (shadowVolume.CntPlanes() > maxPlanes)
 			  maxPlanes = shadowVolume.CntPlanes();
@@ -1816,6 +1822,4 @@
 	  if (pvsChanged)
 	  {
-		  ViewCell *vc = *vit;
-
 		  // recompute render cost
 		  float renderCost = _HackComputeRenderCost(vc);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2721)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2723)
@@ -58,5 +58,5 @@
 static int sNextSamplesThreshold[] = {10000000, 50000000, 100000000, 250000000};
 //static int sNextSamplesThreshold[] = {100000000, 200000000};
-static int sNumReplays = 4;
+static int sNumReplays = 0;//4;
 static int sCurrentSamplesThreshold = 0;
 
@@ -353,5 +353,4 @@
 			//glReadBuffer(GL_FRONT);
 
-			cout << "here34" << endl;
 			//////////////
 			//-- output error visualization
@@ -387,6 +386,7 @@
 
 				// render pvs once
-				//RenderPvs(pvs);
-				RenderTrianglePvs();
+				RenderPvs(pvs);
+				// hack for gvs vis
+				//RenderTrianglePvs();
 
 				glFlush();
@@ -1348,7 +1348,11 @@
 	AxisAlignedBox3 sceneBox = mViewCellsManager->GetViewSpaceBox();
 	
-	float x = 1.0f;
+	//float x = 1.0f;
+	//float y = 20.0f;
+	//float z = 80.0f;
+
+	float x = 20.0f;
 	float y = 20.0f;
-	float z = 80.0f;
+	float z = 20.0f;
 
 	AxisAlignedBox3 box(Vector3(0.5f * x, 0, -0.5f * z), Vector3(-0.5f * x, y, 0.5f * z));
@@ -1741,10 +1745,8 @@
 
 	ComputeMaxValues(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost);
-	
-	// matt: temp hack
-	//maxRcCost = 5000.0f;
 	//cout << "maxRcCost: " << maxRcCost << endl;
 
-	int i;
+	// set the max render cost to fixed value
+	//maxRcCost = 1000.0f;
 
 	// transparency	
@@ -1762,5 +1764,5 @@
 		//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
 
-		for (i = 0; i < viewcells.size(); ++ i) 
+		for (int i = 0; i < viewcells.size(); ++ i) 
 		{
 			ViewCell *vc = viewcells[i];
@@ -1779,5 +1781,5 @@
 	if (mUseStandardColors)
 	{
-		for (i = 0; i < viewcells.size(); ++ i) 
+		for (int i = 0; i < viewcells.size(); ++ i) 
 		{
 			ViewCell *vc = viewcells[i];
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2720)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2723)
@@ -375,6 +375,6 @@
 	if (index >= mPreprocessor->mObjects.size())
 	{
-		// Do nothing
-		return NULL;
+		// do nothing
+		//return NULL;
 		for (size_t i = 0; i < mPreprocessor->mDynamicObjects.size(); ++ i)
 		{
@@ -383,6 +383,7 @@
 				return obj;
 		}
-			
-		return ray.mTerminationObject;
+		
+		// no dynamic object found
+		return NULL;//ray.mTerminationObject;
 	}
 
@@ -2426,10 +2427,6 @@
 												   bool addSamplesToPvs)
 {
-	// check if we are outside of view space
-	// $$JB tmp commented to speedup up computations
-#if 0
-	if (!obj || !viewCell->GetValid())
+	if (!obj)
 		return false;
-#endif
 
 	// if ray not outside of view space
@@ -2527,11 +2524,7 @@
 			vssRay->mTerminationObject = GetIntersectable(*vssRay, true);
 			
-			if (vssRay->mTerminationObject->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE)	
-				cout << "r";
-
-#if 0
-		  if (vssRay->mTerminationObject == NULL)
-			  cerr<<"Error in DeterminePvsObjects - termination object maps to NULL!"<<endl;
-#endif
+			if (0 && (vssRay->mTerminationObject == NULL))
+				cerr<<"Error in DeterminePvsObjects - termination object maps to NULL!"<<endl;
+
 		}
 	}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2709)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp	(revision 2723)
@@ -133,5 +133,7 @@
 	if (mCurrentSamples - lastEvaluation >= mSamplesPerEvaluation) {
 	  Real time = TimeDiff(startTime, GetTime());
+#if 0 // matt: remove temporarily
 	  mViewCellsManager->PrintPvsStatistics(mStats);
+#endif
 	  mStats <<
 		"#Pass\n" <<mPass<<endl<<
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2709)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2723)
@@ -70,5 +70,5 @@
 	{ 
 		mViewCell = NULL; 
-		mPvs.Clear(); 
+		mPvs.Clear(false); 
 		filteredBoxes.clear(); 
 		mUnfilteredPvsSize = 0;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp	(revision 2720)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp	(revision 2723)
@@ -2162,79 +2162,87 @@
 	Triangle3 tri;
 
-	tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z);
+	tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z);
 	tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z);
-	tri.mVertices[2] = Vector3(mMin.x, mMax.y ,mMin.z);
+	tri.mVertices[0] = Vector3(mMin.x, mMax.y ,mMin.z);
 
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-	tri.mVertices[0] = Vector3(mMin.x, mMax.y ,mMin.z);
+	tri.mVertices[2] = Vector3(mMin.x, mMax.y ,mMin.z);
 	tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z);
-    tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z);
+    tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z);
 
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-	tri.mVertices[0] = Vector3(mMax.x, mMin.y, mMin.z);
+	//////////////////////////////////////
+
+	tri.mVertices[2] = Vector3(mMax.x, mMin.y, mMin.z);
     tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z);
-    tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z);
+    tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z);
 
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-    tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z);
+    tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z);
 	tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z);
-	tri.mVertices[2] = Vector3(mMax.x, mMin.y, mMin.z);
+	tri.mVertices[0] = Vector3(mMax.x, mMin.y, mMin.z);
 
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-    tri.mVertices[0] = Vector3(mMax.x, mMin.y ,mMin.z);
+	//////////////////////////////////////
+
+    tri.mVertices[2] = Vector3(mMax.x, mMin.y ,mMin.z);
 	tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z);
-	tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z);
+	tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z);
 
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-	tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z);	
+	tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z);	
 	tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z);
-    tri.mVertices[2] = Vector3(mMax.x, mMin.y ,mMin.z);
-
+    tri.mVertices[0] = Vector3(mMax.x, mMin.y ,mMin.z);
 
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-	tri.mVertices[0] = Vector3(mMin.x, mMax.y, mMin.z);
+	//////////////////////////////////////
+
+	tri.mVertices[2] = Vector3(mMin.x, mMax.y, mMin.z);
 	tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z);
-	tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z);
+	tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z);
 
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-	tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z);
+	tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z);
 	tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z);
-	tri.mVertices[2] = Vector3(mMin.x, mMax.y, mMin.z);
+	tri.mVertices[0] = Vector3(mMin.x, mMax.y, mMin.z);
     
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-	tri.mVertices[0] = Vector3(mMin.x, mMax.y, mMin.z);
+	//////////////////////////////////////
+
+	tri.mVertices[2] = Vector3(mMin.x, mMax.y, mMin.z);
 	tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z);
-    tri.mVertices[2] = Vector3(mMax.x, mMin.y, mMin.z);
-
+    tri.mVertices[0] = Vector3(mMax.x, mMin.y, mMin.z);
 	   
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-    tri.mVertices[0] = Vector3(mMax.x, mMin.y, mMin.z);
+    tri.mVertices[2] = Vector3(mMax.x, mMin.y, mMin.z);
 	tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z);
-	tri.mVertices[2] = Vector3(mMin.x, mMax.y, mMin.z);
+	tri.mVertices[0] = Vector3(mMin.x, mMax.y, mMin.z);
 	   
 	triObj = new TriangleIntersectable(tri);
 	triangles.push_back(triObj);
 
-    tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z);
+	//////////////////////////////////////
+
+    tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z);
 	tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z);
-    tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z);
+    tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z);
 
 	   
@@ -2242,7 +2250,7 @@
 	triangles.push_back(triObj);
 
-    tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z);
+    tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z);
     tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z);
-    tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z);
+    tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z);
 	   
 	triObj = new TriangleIntersectable(tri);
