Index: /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2712)
+++ /GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna	(revision 2715)
@@ -10,6 +10,6 @@
 #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/city_full_hp.obj
+SCENE=../data/vienna/vienna_rep.obj
 
 VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz
@@ -31,28 +31,28 @@
 #DISTRIBUTIONS=spatial
 
-# $COMMAND -preprocessor=combined \
-# -scene_filename=$SCENE \
-# -view_cells_filename=$VIEWCELLS \
-# -rss_distributions=$DISTRIBUTIONS \
-# -view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
-# -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \
-# -preprocessor_stats=$PREFIX-i-mixed-b1-n4a.log \
-# -preprocessor_detect_empty_viewspace+ \
-# -preprocessor_use_vbos- \
-# -preprocessor_ray_cast_method=1 \
-# -view_cells_random_viewpoint_list=$VIEWPOINTS \
-# demo1.env
+ $COMMAND -preprocessor=combined \
+ -scene_filename=$SCENE \
+ -view_cells_filename=$VIEWCELLS \
+ -rss_distributions=$DISTRIBUTIONS \
+ -view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
+ -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \
+ -preprocessor_stats=$PREFIX-i-mixed-b1-n4a.log \
+ -preprocessor_detect_empty_viewspace+ \
+ -preprocessor_use_vbos- \
+ -preprocessor_ray_cast_method=3 \
+ -view_cells_random_viewpoint_list=$VIEWPOINTS \
+ demo1.env
 
-$COMMAND -preprocessor=sampling \
--scene_filename=$SCENE \
--view_cells_filename=$VIEWCELLS \
--view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
--preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \
--preprocessor_stats=$PREFIX-i-mixed-b1-n4a.log \
--preprocessor_detect_empty_viewspace+ \
--preprocessor_use_vbos- \
--preprocessor_ray_cast_method=1 \
--view_cells_random_viewpoint_list=$VIEWPOINTS \
-demo1.env
+#$COMMAND -preprocessor=sampling \
+#-scene_filename=$SCENE \
+#-view_cells_filename=$VIEWCELLS \
+#-view_cells_use_kd_pvs+ -af_use_kd_pvs+ \
+#-preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4a.xml \
+#-preprocessor_stats=$PREFIX-i-mixed-b1-n4a.log \
+#-preprocessor_detect_empty_viewspace+ \
+#-preprocessor_use_vbos- \
+#-preprocessor_ray_cast_method=1 \
+#-view_cells_random_viewpoint_list=$VIEWPOINTS \
+#demo1.env
 
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h	(revision 2709)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h	(revision 2715)
@@ -96,4 +96,6 @@
 
 	Matrix4x4 mTrafo;
+
+	bool mDeleteGeometry;
 };
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp	(revision 2710)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp	(revision 2715)
@@ -39,5 +39,6 @@
 SceneGraphLeaf::~SceneGraphLeaf()
 {
-    CLEAR_CONTAINER(mGeometry);
+	if (mDeleteGeometry)
+		CLEAR_CONTAINER(mGeometry);
 }
 
@@ -278,5 +279,6 @@
 
 
-SceneGraphLeaf::SceneGraphLeaf(): mIsDynamic(false), mHasChanged(true)
+SceneGraphLeaf::SceneGraphLeaf(): 
+mIsDynamic(false), mHasChanged(true), mDeleteGeometry(true)
 {
 	mTrafo = IdentityMatrix();
@@ -285,5 +287,6 @@
 
 
-SceneGraphLeaf::SceneGraphLeaf(bool isDynamic): mIsDynamic(isDynamic), mHasChanged(true)
+SceneGraphLeaf::SceneGraphLeaf(bool isDynamic): 
+mIsDynamic(isDynamic), mHasChanged(true), mDeleteGeometry(true)
 {
     mTrafo = IdentityMatrix();
@@ -327,9 +330,6 @@
 {
 	// hack: should just pass a IntersectableGroup as a whole
-	// instead we duplicate the object container and create a new
-	// leaf
+	// instead we duplicate the geometry vector
 	mGeometry = copy.mGeometry;
-	//for (size_t i = 0; i < copy.mGeometry->size(); ++ i)
-	//	mGeometry.push_back(copy.mGeometry[i]);
 
 	mBox = copy.mBox;
@@ -339,5 +339,9 @@
 	mIntersectable = new SceneGraphLeafIntersectable(this, mBox);
 	mHasChanged = true;
-}
-
-}
+
+	// hack: the geometry should not be deleted here because this
+	// is just a copy
+	mDeleteGeometry = false;
+}
+
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2714)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 2715)
@@ -1599,5 +1599,5 @@
 	}
 
-	cout << "\**************\n******* new object has id " << currentId << endl;
+	cout << "new object registered with id " << currentId << endl;
 
 	++ sCurrentDynamicId;
@@ -1605,15 +1605,4 @@
 	// tell ray caster to update
 	ScheduleUpdateDynamicObjects();
-
-	if (0) 
-	{
-		// add to scene graph
-		mSceneGraph->GetRoot()->mChildren.push_back(leaf);
-		// add to ray caster
-		if (mRayCaster)
-			mRayCaster->AddDynamicObjecs(leaf->mGeometry, leaf->GetTransformation());
-	}
-	// $$ JB in order to compile
-	//return leaf;
 }
 
@@ -1769,17 +1758,10 @@
 	  preprocessor->mRayCaster->DeleteDynamicObjects();
 	  
-#define MULTIPLE_OBJECTS 0
-#define CREATE_TRANSF_COPIES_OF_DYN_OBJECTS	 1
+#define MULTIPLE_OBJECTS 1
 
 #if MULTIPLE_OBJECTS 
-#if CREATE_TRANSF_COPIES_OF_DYN_OBJECTS	
 	  static ObjectContainer objects;
 	  
-	  if (objects.size()) {
-		for (size_t i = 0; i < objects.size(); ++ i) {
-		  delete objects[i];
-		}
-		objects.clear();
-	  }
+	  CLEAR_CONTAINER(objects);
 	  
 	  for (size_t i = 0; i < mDynamicObjects.size(); ++ i) {
@@ -1789,12 +1771,12 @@
 			Triangle3 t(((TriangleIntersectable *)l->mGeometry[j])->GetItem());
 			t.ApplyTransformation(l->GetTransformation());
-			objects.push_back(new TriangleIntersectable(t));
+			TriangleIntersectable *to = new TriangleIntersectable(t);
+			to->SetId(l->GetIntersectable()->GetId());
+
+			objects.push_back(to);
 		  }
 		}
 	  }
 	  mRayCaster->AddDynamicObjecs(objects, IdentityMatrix());
-#else
-	  mRayCaster->AddDynamicObjecs(objects, IdentityMatrix());
-#endif
 #endif	  
 
@@ -1802,21 +1784,19 @@
 	  
 	  for (size_t i = 0; i < mDynamicObjects.size(); ++ i) 
-		{
+	  {
 		  SceneGraphLeaf *l = mDynamicObjects[i];
 
 #if  !MULTIPLE_OBJECTS
-		  UpdateObjectInRayCaster(l);
+		  PrepareObjectsForRayCaster(l);
 #endif
 
 		  if (l->HasChanged())
-			{
-			  
+		  {
 			  cout<<"Updating affected PVSs..."<<endl;
 			  preprocessor->ObjectMoved(l);
 			  cout<<"done."<<endl;	
 			  l->SetHasChanged(false);
-			}
-		}
-
+		  }
+	  }
 
 	  mUpdateDynamicObjects = false;
@@ -1832,5 +1812,5 @@
 
 
-void Preprocessor::UpdateObjectInRayCaster(SceneGraphLeaf *l)
+void Preprocessor::PrepareObjectsForRayCaster(SceneGraphLeaf *l)
 {
 	cout<<"Updating dynamic objects in ray caster..."<<endl;
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2711)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2715)
@@ -574,12 +574,16 @@
 	DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicPvsObjects.end();
 
+	//cout << "dynamic objects in pvs " << mDynamicPvsObjects.size() << endl;;
+
 	for (dit = mDynamicPvsObjects.begin(); dit != dit_end; ++ dit)
 	{
 		_RenderDynamicObject(*dit);
 	}
+
+	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 
 	// show placed dynamic objects as wireframe
 	Preprocessor *p = mViewCellsManager->GetPreprocessor();
-	dit, dit_end = p->mDynamicObjects.end();
+	dit_end = p->mDynamicObjects.end();
 
 	int i = 0;
@@ -591,8 +595,8 @@
 			glColor3f(0, 1, 0);
 
-		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 		_RenderDynamicObject(*dit);
-		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-	}
+	}
+	
+	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 }
 
@@ -2002,5 +2006,5 @@
     
 	QVBoxLayout *vbox2 = new QVBoxLayout;
-	QGroupBox *groupBox = new QGroupBox("Trafo types");
+	QGroupBox *groupBox = new QGroupBox("Dynamic Obojects");
 
 	vbox2->addWidget(rb1);
@@ -2021,4 +2025,8 @@
 	connect(button, SIGNAL(clicked()), SIGNAL(DeleteDynamicObject()));
 	
+	button = new QPushButton("Next object", groupBox);
+	vbox2->layout()->addWidget(button);
+	connect(button, SIGNAL(clicked()), SIGNAL(NextObject()));
+
 	groupBox->setLayout(vbox2);
 	
@@ -2398,7 +2406,4 @@
 #endif
 
-
-	
-
 #if REMOVE_TEMPORARY
 	
@@ -2438,16 +2443,9 @@
 	connect(button, SIGNAL(clicked()), SIGNAL(ComputeGVS()));
 #endif
-
-#if 1	
+	
 	button = new QPushButton("Replay view points", vbox);
 	vbox->layout()->addWidget(button);
 	connect(button, SIGNAL(clicked()), SIGNAL(ReplayViewPoints()));
 
-#endif
-
-	button = new QPushButton("Next object", vbox);
-	vbox->layout()->addWidget(button);
-	connect(button, SIGNAL(clicked()), SIGNAL(NextObject()));
-	//connect(button, SIGNAL(clicked()), SIGNAL(LoadObject()));
 
 	/*cb = new QCheckBox("Stats", vbox);
@@ -2631,12 +2629,15 @@
 		if (mUseRandomColorPerPvsObject)
 		{
-			KdIntersectable *kdint = static_cast<KdIntersectable *>(obj);
-
-			if (kdint->mGenericIdx == -1)
+			if (obj->Type() == Intersectable::KD_INTERSECTABLE)
 			{
-				kdint->mGenericIdx = (int)mColors.size();
-				mColors.push_back(RandomColor(0, 1));
+				KdIntersectable *kdint = static_cast<KdIntersectable *>(obj);
+
+				if (kdint->mGenericIdx == -1)
+				{
+					kdint->mGenericIdx = (int)mColors.size();
+					mColors.push_back(RandomColor(0, 1));
+				}
+				color = mColors[kdint->mGenericIdx];
 			}
-			color = mColors[kdint->mGenericIdx];
 		} 
 		else
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2709)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2715)
@@ -200,5 +200,5 @@
 	void RegisterDynamicObject(SceneGraphLeaf *leaf);
 	
-	void UpdateObjectInRayCaster(SceneGraphLeaf *l);
+	void PrepareObjectsForRayCaster(SceneGraphLeaf *l);
 	
 	void ScheduleUpdateDynamicObjects();
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj	(revision 2712)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj	(revision 2715)
@@ -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="false"
+				GenerateDebugInformation="true"
 				SubSystem="1"
 				LargeAddressAware="2"
