Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2682)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2685)
@@ -1535,5 +1535,5 @@
 	}
 #else
-	return mObjects[id - 1];
+	return mObjects[id];
 #endif
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2683)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2685)
@@ -581,5 +581,5 @@
 	glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices);
 
-#if 0// DYNAMIC_OBJECTS_HACK
+#if DYNAMIC_OBJECTS_HACK
 	// handle dynamic objects
 	DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end();
@@ -819,5 +819,5 @@
   if (e->modifiers() & Qt::AltModifier) 
 	if (mCurrentDynamicObjectIdx >= 0) {
-	  //	  preprocessor->ScheduleUpdateDynamicObjects();
+	  // preprocessor->ScheduleUpdateDynamicObjects();
 	}
 }
@@ -829,5 +829,5 @@
 	float TURN_SENSITIVITY = 0.1f;
 	float TILT_SENSITIVITY = 32.0 ;
-	float TURN_ANGLE= M_PI  /36.0 ;
+	float TURN_ANGLE= M_PI / 36.0 ;
 
 	int x = e->pos().x();
@@ -843,5 +843,5 @@
 		mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY / 2.0;
 		mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0;
-	} 
+	}
 #if DYNAMIC_OBJECTS_HACK
 	else if (e->modifiers() & Qt::AltModifier)
@@ -883,13 +883,8 @@
 			}
 
-#if USE_TRANSFORMED_MESH_INSTANCE_HACK
-			TransformedMeshInstance *tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx];
-			tmi->ApplyWorldTransform(tm);
-#else
 			SceneGraphLeaf *l =
 			  mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx];
 			l->ApplyTransform(tm);
 			
-#endif
 			updateGL();
 		}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2680)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2685)
@@ -1509,7 +1509,5 @@
 			int pvsSize;
 
-			float error = GetPixelError(pvsSize);
-
-			mPvsErrorBuffer[i].mError = error;
+			mPvsErrorBuffer[i].mError = GetPixelError(pvsSize);
 			mPvsErrorBuffer[i].mPvsSize = pvsSize;
 
@@ -1587,5 +1585,5 @@
 		//cout << "\n\nvp: " << (*sit) << endl;
 		SimpleRay sray = *sit;
-		int pvsSize = 0;
+		int pvsSize = -1;
 
 		// set frame id for saving the error buffer
@@ -1599,14 +1597,10 @@
 		{
 			// compute the pixel error
-			const float error = GetPixelError(pvsSize);
-
-			mPvsErrorBuffer[i].mError = error;
+			mPvsErrorBuffer[i].mError = GetPixelError(pvsSize);
 			mPvsErrorBuffer[i].mPvsSize = pvsSize;
 
-			const int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight();
-
-			if (0 && (pixelError > 0) && (pvsSize > 0)) 
+			if (0 && (mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() > 0) && (pvsSize > 0)) 
 			{
-				cout << "err: " << i << "," << mViewPoint << "," << mViewDirection << " " 
+				cout << "error in frame " << i << "," << mViewPoint << "," << mViewDirection << " " 
 					 << mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() << endl;
 			}
@@ -1620,10 +1614,9 @@
 		
 		if (//(mFrame > 0) && 
-			(err >= 0.0f) && (err < (1.0f - 1e-6f)) && (pvsSize > 0)) 
+			(err >=  -1e-6f) && (err < (1.0f - 1e-6f)) && (pvsSize != 0)) 
 		{
 			if (err > mPvsStat.maxError)
 			{
 				mPvsStat.maxError = err;
-
 				cout << "new max error: " << mPvsStat.maxError * GetWidth() * GetHeight()  << endl;
 			}
@@ -1638,4 +1631,8 @@
 			// moved it back here not to count frames with negative err (backfacing triangle)
 			++ mPvsStat.frames;
+		}
+		else
+		{
+			cerr << "warning: negative error " << err << " at pvs size " << pvsSize << endl;
 		}
 
@@ -1843,4 +1840,5 @@
 }
 
+
 void GlRenderer::_UpdatePvsIndices(KdNode *node, int &indexBufferSize)
 {
@@ -1872,8 +1870,10 @@
 			{
 				obj->mRenderedFrame = mCurrentFrame;
-
-				mIndices[indexBufferSize + 0] = (obj->GetId() - 1) * 3 + 0;
-				mIndices[indexBufferSize + 1] = (obj->GetId() - 1) * 3 + 1;
-				mIndices[indexBufferSize + 2] = (obj->GetId() - 1) * 3 + 2;
+				
+				const int id = obj->GetId() * 3;
+
+				mIndices[indexBufferSize + 0] = id + 0;
+				mIndices[indexBufferSize + 1] = id + 1;
+				mIndices[indexBufferSize + 2] = id + 2;
 
 				indexBufferSize += 3;
@@ -1890,8 +1890,9 @@
 void GlRenderer::CreateVertexArrays(SceneGraphLeaf *leaf)
 {
-    mData = new Vector3[leaf->mGeometry.size() * 6];
-	mIndices = new unsigned int[leaf->mGeometry.size() * 3];
-
 	size_t offset = leaf->mGeometry.size() * 3;
+
+    mData = new Vector3[offset * 2];
+	mIndices = new unsigned int[offset];
+
 
 	for (size_t i = 0; i < leaf->mGeometry.size(); ++ i)
@@ -1909,4 +1910,8 @@
 		mData[offset + i * 3 + 1] = n;
 		mData[offset + i * 3 + 2] = n;
+
+		mIndices[i * 3 + 0] = 0;
+		mIndices[i * 3 + 1] = 0;
+		mIndices[i * 3 + 2] = 0;
 	}
 
@@ -1921,5 +1926,5 @@
 		glNormalPointer(GL_FLOAT, 0, (char *)NULL + offset * sizeof(Vector3));
 
-		glBufferDataARB(GL_ARRAY_BUFFER_ARB, leaf->mGeometry.size() * 6 * sizeof(Vector3), mData, GL_STATIC_DRAW_ARB);
+		glBufferDataARB(GL_ARRAY_BUFFER_ARB, offset * 2 * sizeof(Vector3), mData, GL_STATIC_DRAW_ARB);
 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj	(revision 2680)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj	(revision 2685)
@@ -157,5 +157,5 @@
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(QTDIR)\lib&quot;;..\src\GL;&quot;..\lib05\$(ConfigurationName)&quot;;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;&quot;..\MultiLevelRayTracing\RTScene\$(ConfigurationName)&quot;;&quot;..\MultiLevelRayTracing\RTWorld\$(ConfigurationName)&quot;;&quot;QtInterface\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\..\NonGTP\Xerces\xerces-c_2_8_0\lib&quot;;&quot;$(CG_LIB_PATH)&quot;"
-				GenerateDebugInformation="true"
+				GenerateDebugInformation="false"
 				SubSystem="1"
 				LargeAddressAware="2"
