Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2699)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh	(revision 2702)
@@ -14,7 +14,7 @@
 #VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz
 #SCENE=../data/vienna/vienna_cropped.obj
-#SCENE=../data/roofs2.obj
+SCENE=../data/roofs_new.obj
 #SCENE=../data/vienna/city_full_hp.obj
-SCENE=../data/vienna/vienna_rep.obj
+#SCENE=../data/vienna/vienna_rep.obj
 
 #SCENE=../data/vienna/vienna_cropped.obj
Index: GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2696)
+++ GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2702)
@@ -8,8 +8,8 @@
 
 
-#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/vienna_rep.obj
+#SCENE=../data/vienna/vienna_rep.obj
 
 VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h	(revision 2694)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h	(revision 2702)
@@ -55,5 +55,7 @@
 {
 public:
-
+	/** Copy constructor.
+	*/
+	SceneGraphLeaf(SceneGraphLeaf const&);
 	SceneGraphLeaf();
 	SceneGraphLeaf(bool isDynamic);
@@ -74,19 +76,17 @@
 	virtual void UpdateBox();
 
-#if DYNAMIC_OBJECTS_HACK
 	SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; }
-#endif
 
-	/// used as actual pvs entry
+	const Matrix4x4 &GetTransformation() const { return mTrafo; }
+
+	//void SetGeometry(ObjectContainer *geometry);
+
+	/// used as actual pvs entry: note should be pointer to geometry!!
 	ObjectContainer mGeometry;
-  const Matrix4x4 &GetTransformation() const { return mTrafo; }
+
+
 protected:
 
-#if DYNAMIC_OBJECTS_HACK
-	
 	SceneGraphLeafIntersectable *mIntersectable;
-	CKTB *mKtbTree;
-
-#endif
 
 	bool mIsDynamic;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp	(revision 2694)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp	(revision 2702)
@@ -282,7 +282,5 @@
 	mTrafo = IdentityMatrix();
 
-#if DYNAMIC_OBJECTS_HACK
 	mIntersectable = new SceneGraphLeafIntersectable(this, mBox);
-#endif
 }
 
@@ -323,3 +321,18 @@
 }
 
-}
+
+SceneGraphLeaf::SceneGraphLeaf(SceneGraphLeaf const& copy)
+{
+	// hack: should just pass a IntersectableGroup as a whole
+	// instead we duplicate the object container and create a new
+	// leaf
+	mGeometry = copy.mGeometry;
+	//for (size_t i = 0; i < copy.mGeometry->size(); ++ i)
+	//	mGeometry.push_back(copy.mGeometry[i]);
+
+	mBox = copy.mBox;
+	mTrafo = copy.mTrafo;
+	mIsDynamic = copy.mIsDynamic;
+}
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2701)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2702)
@@ -1591,6 +1591,11 @@
 
 
-SceneGraphLeaf *Preprocessor::RegisterDynamicGeometryWithRayCaster(SceneGraphLeaf *leaf)
-{
+void Preprocessor::RegisterDynamicObject(SceneGraphLeaf *leaf)
+{	
+	mDynamicObjects.push_back(leaf);
+
+	// add to scene graph
+	mSceneGraph->GetRoot()->mChildren.push_back(leaf);
+
   if (mRayCaster)
 	mRayCaster->AddDynamicObjecs(leaf->mGeometry, leaf->GetTransformation());
@@ -1602,6 +1607,4 @@
 SceneGraphLeaf *Preprocessor::LoadDynamicGeometry(const string &filename)
 {
-#if DYNAMIC_OBJECTS_HACK
-
 	const bool dynamic = true;
 	SceneGraphLeaf *leaf = new SceneGraphLeaf(dynamic);
@@ -1623,6 +1626,4 @@
 	if (parsed)
 	{
-		const float scale = 0.01f;
-
 		ObjectContainer::const_iterator it, it_end = leaf->mGeometry.end();
 
@@ -1633,5 +1634,7 @@
 			Triangle3 t = tri->GetItem();
 
-			// scale object appropriately
+			// hack: scale object appropriately
+			float scale = 0.01f;
+
 			t.mVertices[0] *= scale;
 			t.mVertices[1] *= scale;
@@ -1641,11 +1644,5 @@
 		}
 
-		//leaf->ApplyTransform(ScaleMatrix(s, s, s));
-		//leaf->ApplyTransform(TranslationMatrix(Vector3(0, 10, 0)));
-
 		leaf->UpdateBox();
-		mSceneGraph->GetRoot()->mChildren.push_back(leaf);
-		//mDynamicObjects.push_back(leaf);
-
 		cout<<"Dynamic object loaded successfully: " << leaf->GetBox() << endl;
 
@@ -1654,5 +1651,4 @@
 		
 
-#endif
 	cout<<"Dynamic object loading failed."<<endl;
 	return NULL;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2697)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2702)
@@ -63,5 +63,5 @@
    GLuint names, *ptr;
 
-   cout << "hits = %d" << endl;;
+   cout << "hits: " << hits << endl;;
    ptr = (GLuint *) buffer;
 
@@ -71,12 +71,13 @@
 	   names = *ptr;
 
-	   printf (" number of names for hit = %d\n", names); ptr++;
-	   printf("  z1 is %g;", (float) *ptr/0x7fffffff); ptr++;
-	   printf(" z2 is %g\n", (float) *ptr/0x7fffffff); ptr++;
-	   printf ("   the name is ");
-
-	   for (j = 0; j < names; j++) {     /*  for each name */
+	   printf ("number of names for hit: %d\n", names); ptr ++;
+	   printf("z1: %g;", (float) *ptr / 0x7fffffff); ptr ++;
+	   printf("z2: %g\n", (float) *ptr / 0x7fffffff); ptr ++;
+	   printf ("the name is ");
+
+	   // for each name 
+	   for (j = 0; j < names; j++) 
 		   printf ("%d ", *ptr); ptr++;
-	   }
+
 	   printf ("\n");
    }
@@ -555,9 +556,8 @@
 	glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices);
 
-#if DYNAMIC_OBJECTS_HACK
 	// handle dynamic objects
-	DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end();
-
-	for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit)
+	DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicPvsObjects.end();
+
+	for (dit = mDynamicPvsObjects.begin(); dit != dit_end; ++ dit)
 	{
 		_RenderDynamicObject(*dit);
@@ -565,7 +565,8 @@
 
 	// handle dynamic objects
-	dit, dit_end = mPendingDynamicObjects.end();
-
-	for (dit = mPendingDynamicObjects.begin(); dit != dit_end; ++ dit)
+	Preprocessor *p = mViewCellsManager->GetPreprocessor();
+	dit, dit_end = p->mDynamicObjects.end();
+
+	for (dit = p->mDynamicObjects.begin(); dit != dit_end; ++ dit)
 	{
 		_RenderDynamicObject(*dit);
@@ -573,5 +574,4 @@
 
 	//_RenderDynamicObject(mPendingDynamicObject);
-#endif
 }
 
@@ -586,7 +586,5 @@
 	mPvsSize = pvs.GetSize();
 
-#if DYNAMIC_OBJECTS_HACK
-	mDynamicObjects.clear();
-#endif
+	mDynamicPvsObjects.clear();
 
 	ObjectPvsIterator it = pvs.GetIterator();
@@ -604,10 +602,8 @@
 			}
 			break;
-#if DYNAMIC_OBJECTS_HACK
 
 		case Intersectable::SCENEGRAPHLEAF_INTERSECTABLE:
-			mDynamicObjects.push_back(static_cast<SceneGraphLeafIntersectable *>(obj)->GetItem());
+			mDynamicPvsObjects.push_back(static_cast<SceneGraphLeafIntersectable *>(obj)->GetItem());
 			break;
-#endif
 		default:
 			cerr << "PreparePvs: type " << Intersectable::GetTypeName(obj) << " not handled yet" << endl;
@@ -807,5 +803,13 @@
 
 			mPlacer->PlaceObject(pt);
-			//mPendingDynamicObjects.push_back( mPlacer->GetCurrentObject());
+			SceneGraphLeaf *leaf = mPlacer->GetCurrentObject();
+
+			// hack: should just pass a IntersectableGroup as a whole
+			// instead we duplicate the object container and create a new
+			// leaf
+			SceneGraphLeaf *newObj = new SceneGraphLeaf(*leaf);
+
+			mViewCellsManager->GetPreprocessor()->RegisterDynamicObject(newObj);
+			//mPendingDynamicObjects.push_back();
 		}
 	}
@@ -825,8 +829,10 @@
 		const Vector3 pt = Unproject(x, y);
 
-		int num = FindDynamicObject(pt);
-		cout << "\n*****************\n" << "here4" << num << endl;
-		//processHits(buf);
-
+		int idx = FindDynamicObject(x, y);
+		
+		Preprocessor *p = GetPreprocessor();
+
+		swap(p->mDynamicObjects[idx], p->mDynamicObjects.back());
+		p->mDynamicObjects.pop_back();
 		/*if (mCurrentDynamicObjectIdx >= 0) {
 		preprocessor->ScheduleUpdateDynamicObjects();
@@ -933,27 +939,21 @@
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-	if (1) 
-	{
-		SetupCameraProjection(width(), height());
-		SetupCamera();
-
-		if (mRenderErrors) 
-		{
-			RenderErrors();
-		} 
-		else 
-		{
-			glColor3f(0.6f, 0.6f, 0.6f);
-			VisualizePvs();
-		}
-
-		if (mShowRays) 
-		{
-			RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod, mShowDistribution, 1);
-		}
-	}
-
+	SetupCameraProjection(width(), height());
+	SetupCamera();
+
+	if (mRenderErrors) 
+		RenderErrors();
+	else 
+	{
+		glColor3f(0.6f, 0.6f, 0.6f);
+		VisualizePvs();
+	}
+
+	if (mShowRays) 
+		RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod, mShowDistribution, 1);
+	
 	RenderInfo();
-	mFrame ++;
+
+	++ mFrame;
 	//	cout<<"vp="<<mViewPoint<<" vd="<<mViewDirection<<endl;
 }
@@ -2367,7 +2367,7 @@
 	vbox->layout()->addWidget(button);
 	connect(button, SIGNAL(clicked()), SIGNAL(ComputeGVS()));
-
-#else
-	
+#endif
+
+#if 1	
 	button = new QPushButton("Replay view points", vbox);
 	vbox->layout()->addWidget(button);
@@ -2376,10 +2376,7 @@
 #endif
 
-#if DYNAMIC_OBJECTS_HACK
-
 	button = new QPushButton("Load object", vbox);
 	vbox->layout()->addWidget(button);
 	connect(button, SIGNAL(clicked()), SIGNAL(LoadObject()));
-#endif
 
 	/*cb = new QCheckBox("Stats", vbox);
@@ -2650,6 +2647,7 @@
 
 
-int QtGlRendererWidget::FindDynamicObject(const Vector3 &pos) 
+int QtGlRendererWidget::FindDynamicObject(float x, float y) 
 { 
+	makeCurrent();
 	// we need to lock the rendering context 
 	//glw.lockGLContext(); 
@@ -2660,7 +2658,4 @@
 	// see below for an explanation on the buffer content 
 	GLuint buffer[maxSize]; 
-	GLint viewport[4];
-
-	glGetIntegerv(GL_VIEWPORT, viewport); 
 	glSelectBuffer(maxSize, buffer); 
 	
@@ -2673,22 +2668,52 @@
 	glPushMatrix(); 
 	glLoadIdentity(); 
-	gluPickMatrix((GLdouble)pos.x, (GLdouble)(viewport[3] - pos.y), 5.0f, 5.0f, viewport); 
-	
-	GLfloat x = (GLfloat)width() / height(); 
-	glFrustum(-x, x, -1.0, 1.0, 4.0, 15.0); 
-	
-	 glLoadName(1);
-
-	_RenderDynamicObject(mPendingDynamicObjects[0]);
+
+	glViewport(0, 0, width(), height());
+
+	GLint viewport[4];
+	glGetIntegerv(GL_VIEWPORT, viewport); 
+
+	const float w = 1.0f;
+
+	//gluPickMatrix(x, y, 1000.0, 1000.0, viewport);
+	gluPickMatrix((GLdouble)x, (GLdouble)(viewport[3] - y), w, w, viewport); 
+
+	GLfloat aspect = (GLfloat) width() / height(); 
+	gluPerspective(70.0f, aspect, 0.1f, 2.0f * Magnitude(mSceneGraph->GetBox().Diagonal()));
+	
+	glMatrixMode(GL_MODELVIEW);
+	glPushMatrix(); 
+	glLoadIdentity();
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+	
+	
+	SetupCamera();
+
+	for (size_t i = 0; i < GetPreprocessor()->mDynamicObjects.size(); ++ i)
+	{
+		glLoadName(i);
+		_RenderDynamicObject(GetPreprocessor()->mDynamicObjects[i]);
+	}
+
+	glFlush();
+	glPopMatrix();
 
 	glMatrixMode(GL_PROJECTION); 
 	glPopMatrix();
 
+	//updateGL();
+
+	int hits;
 	// finally release the rendering context again 
-	if (!glRenderMode(GL_RENDER)) 
+	if ((hits = glRenderMode(GL_RENDER)) < 0) 
 	{ 
+		cout << "no object picked" << endl;
 		//glw.unlockGLContext(); 
 		return -1; 
 	} 
+
+
+	//processHits(hits, buffer);
+
 	
 	//glw.unlockGLContext(); 
@@ -2703,5 +2728,4 @@
 	// (number of the surface). 
 	// return the name of the clicked surface 
-	
 	return buffer[3]; 
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.h	(revision 2694)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.h	(revision 2702)
@@ -1,3 +1,3 @@
- #ifndef OBJECTPLACER_H
+#ifndef OBJECTPLACER_H
 #define OBJECTPLACER_H
 
@@ -15,13 +15,13 @@
 {
 public:
-	/** Default constructor taking a pointer to the currently used preprocessor.
+	/** Default constructor.
 	*/
-//	ObjectPlacer(Preprocessor *prep);
 	ObjectPlacer();
 
-	/** Sets library objects.
+	virtual ~ObjectPlacer() {}
+
+	/** Adds a library objects.
 	*/
-	void AddObject(SceneGraphLeaf *object);
-
+	void AddObject(SceneGraphLeaf *obj);
 	/** Selects the next library object.
 	*/
@@ -33,18 +33,15 @@
 	*/
 	void PlaceObject(const Vector3 &p);
-
+	/** Returns the currently active object.
+	*/
 	SceneGraphLeaf *GetCurrentObject();
-
-	virtual ~ObjectPlacer() {}
-
-	DynamicObjectsContainer &GetDynamicObjects() { return mDynamicObjects; }
+	/** Returns a ref to the object container.
+	*/
+	DynamicObjectsContainer &GetDynamicObjects() { return mLibraryObjects; }
 
 
 protected:
 
-	//Preprocessor *mPreprocessor;
-
-	DynamicObjectsContainer mDynamicObjects;
-		
+	DynamicObjectsContainer mLibraryObjects;
 	int mCurrentObject;
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2697)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2702)
@@ -248,10 +248,6 @@
 	ObjectPlacer *mPlacer;
 
-#if DYNAMIC_OBJECTS_HACK
-
-	DynamicObjectsContainer mPendingDynamicObjects;
-	DynamicObjectsContainer mDynamicObjects;
-
-#endif
+	//DynamicObjectsContainer mPendingDynamicObjects;
+	DynamicObjectsContainer mDynamicPvsObjects;
 
 	QtGlRendererWidget(SceneGraph *sceneGraph,
@@ -329,5 +325,5 @@
 	Vector3 Unproject(int x, int y);
 	
-	int FindDynamicObject(const Vector3 &pos);
+	int FindDynamicObject(float x, float y);
 
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp	(revision 2694)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp	(revision 2702)
@@ -20,5 +20,5 @@
 void ObjectPlacer::AddObject(SceneGraphLeaf *obj)
 {
-	mDynamicObjects.push_back(obj);
+	mLibraryObjects.push_back(obj);
 }
 
@@ -26,5 +26,5 @@
 void ObjectPlacer::NextObject()
 {
-	mCurrentObject = (mCurrentObject + 1) % (int)mDynamicObjects.size();
+	mCurrentObject = (mCurrentObject + 1) % (int)mLibraryObjects.size();
 }
 
@@ -32,5 +32,5 @@
 void ObjectPlacer::PreviousObject()
 {
-	mCurrentObject = (mCurrentObject - 1) % (int)mDynamicObjects.size();
+	mCurrentObject = (mCurrentObject - 1) % (int)mLibraryObjects.size();
 }
 
@@ -38,8 +38,8 @@
 SceneGraphLeaf *ObjectPlacer::GetCurrentObject() 
 { 
-	if (mCurrentObject >= mDynamicObjects.size())
+	if (mCurrentObject >= mLibraryObjects.size())
 		return NULL;
 
-	return mDynamicObjects[mCurrentObject];
+	return mLibraryObjects[mCurrentObject];
 }
 
@@ -49,5 +49,5 @@
 	Vector3 p = pt;
 
-	SceneGraphLeaf *obj = mDynamicObjects[mCurrentObject];
+	SceneGraphLeaf *obj = mLibraryObjects[mCurrentObject];
 
 	// set pivot to ground of object
@@ -58,88 +58,3 @@
 }
 
-
-/*void TestApp::Placer(const String &parm)
-{
-	if (parm.Empty())
-	{
-		OUT1("Object placement: place/load <libaryfile>/removelast/next/previous/save <objectfile>");
-		return;
-	}
-
-	ASM_RET(viewer->GetRoot(), "No scene");
-	
-	if (!placer)
-		placer = new ObjectPlacer;
-
-	//-- make sure the placer visualization (which shows the already placed objects) is in the viewer
-	SearchNodeByNameVisitor search("placervis");
-	search.Apply(viewer->GetRoot(), SearchNodeByNameVisitor::FIRST);
-	BranchGroup *placervis = search.GetNode();
-	if (!placervis)
-	{
-		placervis = placer->GetPlacedNodeVisualization();
-		viewer->GetRoot()->addChild(placervis);
-		placervis->setName("placervis");
-	}
-
-	if (parm == "place")
-	{
-		int x, y;
-		input_module->GetMousePos(x, y);
-
-		Point3f pos = viewer->UnProject(x, y);
-		if (viewer && viewer->GetRoot() && viewer->GetRoot()->getBoundingBox()->intersects(pos))
-		{
-			placer->AddObject(pos);
-			OUT1(x << " " << y << " " << pos);
-		}
-		else
-		{
-			OUT1("Point out of bounds");
-		}
-	} else if (parm == "removelast") {
-		placer->RemoveLastObject();
-	} else if (parm == "next") {
-		placer->NextObject();
-	} else if (parm == "previous") {
-		placer->PreviousObject();
-	} else if (parm.Left(5) == "save ") {
-		String filename = parm.Right(parm.size()-5);
-		if (!filename.Empty())
-			placer->SaveObjects(filename);
-	} else if (parm.Left(5) == "clear") {
-		placer->Clear();
-	} else if (parm.Left(5) == "load ") {
-		String fn = sysutils::FindFile(parm.Right(parm.size()-5), settings->get_ObjectPath());
-
-		ASM_ELSE(!fn.empty(), "Couldn't find file " << fn)
-		{
-			OUT1("Loading library " << fn << "...");
-			SceneBasePtr<BranchGroup> root = ReadSceneGraph(fn, 0, 0, 1);
-
-			BranchGroup *library = new BranchGroup;
-			ASM_ELSE((root != NULL), "No scene found in file...")
-			{
-				SearchNodeByNameVisitor search("start");
-				search.Apply(root, SearchNodeByNameVisitor::FIRST);
-				BranchGroup *local_root = search.GetNode();
-
-				if (local_root == NULL)
-				{
-					OUT1("Note: BranchGroup named \"start\" not found - using root node");
-					local_root = root;
-				}
-
-				placer->SetLibrary(local_root);
-				BranchGroup *viz = placer->GetLibraryVisualization();
-				mRenderArea->SetSceneRoot(viz);
-				mRenderArea->SetCamera(new Camera);
-				mRenderArea->GetCamera()->ViewAll(viz->getBoundingSphere());
-			}
-		}
-	} else
-		OUT1("Unknown placer command");
 }
-*/
-
-}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2702)
@@ -33,4 +33,5 @@
 class SceneGraphLeaf;
 class GlRendererWidget;
+class IntersectableGroup;
 
 
@@ -197,6 +198,5 @@
 		computation.
 	*/
-	SceneGraphLeaf *RegisterDynamicGeometryWithRayCaster(SceneGraphLeaf *leaf);
-
+	void RegisterDynamicObject(SceneGraphLeaf *leaf);
 	
 
@@ -226,7 +226,6 @@
 	ViewCellsManager *mViewCellsManager;
 
-#if DYNAMIC_OBJECTS_HACK
 	DynamicObjectsContainer mDynamicObjects;
-#endif
+
 	/// greedy optimized hierarchy for both objects and view cells
 	VspOspTree *mVspOspTree;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h	(revision 2678)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h	(revision 2702)
@@ -22,4 +22,5 @@
 class KdLeaf;
 class Vector3;
+class IntersectableGroup;
 
 struct IndexedBoundingBox;
@@ -75,7 +76,8 @@
 
 /// a container for dynamic objects
-
 typedef vector<SceneGraphLeaf *> DynamicObjectsContainer;
 
+// a container for intersectable groups (e.g., triangle soups)
+typedef vector<IntersectableGroup *> GroupContainer;
 
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2696)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2702)
@@ -369,8 +369,6 @@
 {
 	// dynamic objects are scene graph leaves
-#if DYNAMIC_OBJECTS_HACK
 	if (ray.mTerminationObject->Type() == Intersectable::SCENEGRAPHLEAF_INTERSECTABLE)
 		return ray.mTerminationObject;
-#endif
 
 	if (mUseKdPvs)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2697)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 2702)
@@ -551,7 +551,7 @@
 	glPopMatrix();
 
-	if (1)
-	{
-		// test the box of the object
+	if (0)
+	{
+		// render the box of the object
 		AxisAlignedBox3 box = leaf->GetBox();
 		RenderBox(box);
@@ -590,5 +590,4 @@
 	Intersectable::NewMail();
 
-#if DYNAMIC_OBJECTS_HACK
 	Preprocessor *p = mViewCellsManager->GetPreprocessor();
 	// handle dynamic objects
@@ -599,5 +598,5 @@
 		_RenderDynamicObject(*dit);
 	}
-#endif
+
 	_RenderSceneTrianglesWithDrawArrays();
 
@@ -606,31 +605,9 @@
 
 
-void
-GlRendererBuffer::EvalQueryWithItemBuffer()
-{
-	// read back the texture
-	glReadPixels(0, 0,
-		GetWidth(), GetHeight(),
-		GL_RGBA,
-		GL_UNSIGNED_BYTE,
-		mPixelBuffer);
-
-
-	unsigned int *p = mPixelBuffer;
-
-	for (int y = 0; y < GetHeight(); y++)
-	{
-		for (int x = 0; x < GetWidth(); x++, p++) 
-		{
-			unsigned int id = (*p) & 0xFFFFFF;
-
-			if (id != 0xFFFFFF)
-			{
-				++ mObjects[id]->mCounter;
-			}
-		}
-	}
-}
-
+
+Preprocessor *GlRenderer::GetPreprocessor()
+{
+	return mViewCellsManager->GetPreprocessor();
+}
 
 
@@ -648,4 +625,32 @@
 	mPixelBuffer = NULL; 
 	// implement width and height in subclasses
+}
+
+
+void
+GlRendererBuffer::EvalQueryWithItemBuffer()
+{
+	// read back the texture
+	glReadPixels(0, 0,
+		GetWidth(), GetHeight(),
+		GL_RGBA,
+		GL_UNSIGNED_BYTE,
+		mPixelBuffer);
+
+
+	unsigned int *p = mPixelBuffer;
+
+	for (int y = 0; y < GetHeight(); y++)
+	{
+		for (int x = 0; x < GetWidth(); x++, p++) 
+		{
+			unsigned int id = (*p) & 0xFFFFFF;
+
+			if (id != 0xFFFFFF)
+			{
+				++ mObjects[id]->mCounter;
+			}
+		}
+	}
 }
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/common.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/common.h	(revision 2699)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/common.h	(revision 2702)
@@ -23,5 +23,4 @@
 #include <vector>
 
-#define DYNAMIC_OBJECTS_HACK 1
 #define USE_HAVRAN_RAYCASTER 1
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2686)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h	(revision 2702)
@@ -29,4 +29,5 @@
 class SimpleRayContainer;
 class SceneGraphLeaf;
+class Preprocessor;
 
 struct VssRayContainer;
@@ -234,4 +235,7 @@
 	};
 
+	Preprocessor *GetPreprocessor();
+
+
 	vector<PvsErrorEntry> mPvsErrorBuffer;
 
@@ -297,6 +301,6 @@
 
 	GlRendererBuffer(SceneGraph *sceneGraph,
-		ViewCellsManager *viewcells,
-		KdTree *tree);
+					 ViewCellsManager *viewcells,
+					 KdTree *tree);
 
 	virtual ~GlRendererBuffer();
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h	(revision 2694)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h	(revision 2702)
@@ -249,12 +249,12 @@
 /** Intersectable wrapping is a group of objects.
 */
-class ContainerIntersectable: public GtpVisibilityPreprocessor::IntersectableWrapper<ObjectContainer *>
-{
-public:
-	ContainerIntersectable(ObjectContainer *item):
+class IntersectableGroup: public GtpVisibilityPreprocessor::IntersectableWrapper<ObjectContainer *>
+{
+public:
+	IntersectableGroup(ObjectContainer *item):
 	  IntersectableWrapper<ObjectContainer *>(item) {}
 
 	// hack
-	~ContainerIntersectable() 
+	~IntersectableGroup() 
 	{
 		delete mItem;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectionBoundingBoxConverter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntersectionBoundingBoxConverter.cpp	(revision 2544)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntersectionBoundingBoxConverter.cpp	(revision 2702)
@@ -55,6 +55,6 @@
 		FindIntersectingObjects(box, *entryObjects);
 
-		ContainerIntersectable *entry = 
-			new ContainerIntersectable(entryObjects);
+		IntersectableGroup *entry = 
+			new IntersectableGroup(entryObjects);
 
 		entry->SetId((*iit).first);
