Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2668)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2671)
@@ -27,8 +27,8 @@
 -preprocessor=gvs \
 -gvs_epsilon=0.0001 \
--gvs_total_samples=500000 \
--gvs_samples_per_pass=50000 \
+-gvs_total_samples=1000000 \
+-gvs_samples_per_pass=1000000 \
 -gvs_initial_samples=16 \
--gvs_max_viewcells=2  \
+-gvs_max_viewcells=200  \
 -gvs_min_contribution=50 \
 -gvs_per_viewcell=true \
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2670)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2671)
@@ -113,5 +113,9 @@
 void QtGlRendererBuffer::RenderPvs(const ObjectPvs &pvs)
 {
+	EnableDrawArrays();
 	PreparePvs(pvs);
+
+	if (mUseVbos)
+		glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId);
 
 	int offset = (int)mObjects.size() * 3;
@@ -128,5 +132,5 @@
 {
 	MakeCurrent();
-	
+
 	if (0)
 	{
@@ -213,11 +217,8 @@
 	Intersectable::NewMail();
 
-KdNode::NewMail2();
-	Intersectable::NewMail();
-	KdNode::NewMail2();
-	Intersectable::NewMail();
-
 	// render pvs once
 	RenderPvs(pvs);
+
+	//cout << "rendered nodes: " << mRenderedNodes << endl;
 
 	//glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
@@ -226,5 +227,5 @@
 
 	glEnable(GL_STENCIL_TEST); 
-	glColor3f(1,0,0);
+	glColor3f(1, 0, 0);
 
 
@@ -250,5 +251,5 @@
 	if (pixelCount > 0) 
 	{
-		cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl;
+		cout << "frame " << mFrame << " vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl;
 	
 		if (mSnapErrorFrames) 
@@ -256,4 +257,5 @@
 			glReadBuffer(GL_BACK);
 			//glReadBuffer(GL_FRONT);
+
 
 			//////////////
@@ -284,4 +286,5 @@
 
 			++ mCurrentFrame;
+
 			// render pvs once
 			RenderPvs(pvs);
@@ -290,5 +293,5 @@
 
 			im = toImage();
-			sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels);
+			sprintf(filename, "error-frame-%04d-%04d-%0.5f-pvs.png", mFrame, viewcell->GetId(), pErrorPixels);
 			str = mSnapPrefix + filename;
 			qstr = str.c_str();
@@ -331,5 +334,4 @@
 			ObjectContainer::iterator oit =
 				lower_bound(objects.begin(), objects.end(), &dummy, ilt);
-
 
 			if (//(oit != oit.end()) && 
@@ -464,4 +466,8 @@
 void QtGlRendererWidget::_RenderPvs()
 {
+	EnableDrawArrays();
+	if (mUseVbos)
+		glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId);
+
 	mUseFalseColors = false;
 
@@ -583,5 +589,5 @@
 			
 			// update the indices for rendering
-			PreparePvs2(mPvsCache.mPvs);
+			PreparePvs(mPvsCache.mPvs);
 			emit PvsUpdated();
 			mCurrentPvsCost = mPvsCache.mPvs.EvalPvsCost();
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2670)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2671)
@@ -74,4 +74,5 @@
 
 	int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
+
 
 public:
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2670)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2671)
@@ -466,13 +466,12 @@
 
 
-
-void
-GlRenderer::_RenderScene()
-{
-  
-  ObjectContainer::const_iterator oi = mObjects.begin();
-  for (; oi != mObjects.end(); oi++)
-	RenderIntersectable(*oi);
-}
+void GlRenderer::_RenderScene()
+{
+	ObjectContainer::const_iterator oi = mObjects.begin();
+
+	for (; oi != mObjects.end(); oi++)
+		RenderIntersectable(*oi);
+}
+
 
 void GlRenderer::_RenderSceneTrianglesWithDrawArrays()
@@ -483,5 +482,5 @@
 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId);
 
-	int offset = (int)mObjects.size() * 3;
+	const int offset = (int)mObjects.size() * 3;
 	char *arrayPtr = mUseVbos ? NULL : (char *)mData;
 	
@@ -489,6 +488,5 @@
 	glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3));
 	
-	glDrawArrays(GL_TRIANGLES, 0, (int)mObjects.size() * 3);
-	//DisableDrawArrays();
+	glDrawArrays(GL_TRIANGLES, 0, offset);
 }
 
@@ -556,10 +554,10 @@
 
 
-bool
-GlRenderer::RenderScene()
-{
-  mCurrentFrame++;
-  
-  Intersectable::NewMail();
+bool GlRenderer::RenderScene()
+{
+	++ mCurrentFrame;
+
+	Intersectable::NewMail();
+
 #if DYNAMIC_OBJECTS_HACK
 	Preprocessor *p = mViewCellsManager->GetPreprocessor();
@@ -570,5 +568,5 @@
 	{
 #if USE_TRANSFORMED_MESH_INSTANCE_HACK
-        RenderIntersectable(*dit);
+		RenderIntersectable(*dit);
 #else
 		_RenderDynamicObject(*dit);
@@ -576,4 +574,5 @@
 	}
 #endif
+
 #if 1
 	_RenderSceneTrianglesWithDrawArrays();
@@ -603,12 +602,12 @@
 	// read back the texture
 	glReadPixels(0, 0,
-				GetWidth(), GetHeight(),
-				GL_RGBA,
-				GL_UNSIGNED_BYTE,
-				mPixelBuffer);
-		
-			
+		GetWidth(), GetHeight(),
+		GL_RGBA,
+		GL_UNSIGNED_BYTE,
+		mPixelBuffer);
+
+
 	unsigned int *p = mPixelBuffer;
-			
+
 	for (int y = 0; y < GetHeight(); y++)
 	{
@@ -1837,5 +1836,6 @@
 {
 	int indexBufferSize = 0;
-	
+	mRenderedNodes = 0;
+
 	KdNode::NewMail2();
 		
@@ -1898,7 +1898,10 @@
 		}
 
+		++ mRenderedNodes;
+
 		leaf->mIndexBufferSize = indexBufferSize - leaf->mIndexBufferStart;
 	}
 }
+
 
 void GlRenderer::CreateVertexArrays(SceneGraphLeaf *leaf)
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2670)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2671)
@@ -233,4 +233,5 @@
 
 	vector<PvsErrorEntry> mPvsErrorBuffer;
+
 	bool mComputeGVS;
 
@@ -281,4 +282,6 @@
 
 	bool mUseVbos;
+
+	int mRenderedNodes;
 };
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2670)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp	(revision 2671)
@@ -1168,8 +1168,4 @@
 	{
 		ComputeRenderError();
-		// and second time
-		ComputeRenderError();
-		// and third time
-		ComputeRenderError();
 	}
 
