Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h	(revision 3071)
@@ -36,5 +36,5 @@
 	/** Copy constructur.
 	*/
-	//SceneEntity(const SceneEntity &trafo);
+	//SceneEntity(const SceneEntity &e);
 	/** Destructor.
 	*/
@@ -112,5 +112,5 @@
 	/// the bounding box
 	AxisAlignedBox3 mBox;
-	/// transform matrix 
+	/// describes a 3D transform
 	Transform3 *mTransform;
 	/// Stores information about the LOD levels
@@ -120,9 +120,9 @@
 	/// when this entity was last rendered
 	int mLastRendered;
-
+	/// the LOD level currently used for rendering
 	int mCurrentLODLevel;
-	/// which frame the lod info was last updated
+	/// frame number in which the LODs were last updated
 	int mLODLastUpdated;
-	/// the center of gravity of this scene entity
+	/// the center of gravity of this entity
 	Vector3 mCenter;
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 3071)
@@ -158,5 +158,6 @@
 	EnqueueNode(mBvh->GetRoot());
 	// add dynamic root
-	EnqueueNode(mBvh->GetDynamicRoot());
+	if (mBvh->GetDynamicRoot())
+		EnqueueNode(mBvh->GetDynamicRoot());
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp	(revision 3071)
@@ -10,8 +10,7 @@
 {
 
-Shape::Shape(Geometry *geometry, Material *mat, SceneEntity *parent):
+Shape::Shape(Geometry *geometry, Material *mat):
 mGeometry(geometry), 
-mMaterial(mat), 
-mParent(parent)
+mMaterial(mat)
 {
 	mCenter = GetBoundingBox().Center();
@@ -28,7 +27,5 @@
 		mMaterial->Render(state);
 
-	mParent->GetTransform()->Load(state);
 	mGeometry->Render(state);
-	mParent->GetTransform()->Unload(state);
 }
 
@@ -53,23 +50,7 @@
 
 
-AxisAlignedBox3 Shape::GetWorldBoundingBox() const
+Vector3 Shape::GetCenter() const
 {
-	if (mParent->GetTransform()->IsIdentity())
-		return mGeometry->GetBoundingBox();
-
-	Matrix4x4 mat = mParent->GetTransform()->GetMatrix();
-
-	return Transform(mGeometry->GetBoundingBox(), mat);
-}
-
-
-Vector3 Shape::GetWorldCenter() const
-{
-	if (mParent->GetTransform()->IsIdentity())
-		return mCenter;
-
-	Matrix4x4 mat = mParent->GetTransform()->GetMatrix();
-
-	return mat * mCenter;
+	return mCenter;
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/EntityMerger.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/EntityMerger.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/EntityMerger.cpp	(revision 3071)
@@ -48,5 +48,5 @@
 	Geometry *geom = MergeGeometry(geom1, geom2);
 
-	Shape *shape = new Shape(geom, mat, parent);
+	Shape *shape = new Shape(geom, mat);
 
 	return shape;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 3071)
@@ -115,5 +115,5 @@
 
 			// create shape
-			Shape *shape = new Shape(geom, mat, sceneGeom);
+			Shape *shape = new Shape(geom, mat);
 
 			mShapes.push_back(shape);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp	(revision 3071)
@@ -43,5 +43,5 @@
 	Geometry *geom = new Geometry(vertices, normals, NULL, 36, false);
 
-	Shape *shape = new Shape(geom, mat, ent);
+	Shape *shape = new Shape(geom, mat);
 	ent->AddShape(shape);
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp	(revision 3061)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp	(revision 3071)
@@ -7,4 +7,6 @@
 #include "Shape.h"
 #include "RenderState.h"
+#include "Transform3.h"
+
 
 using namespace std;
@@ -78,10 +80,10 @@
 	for (; sit != sit_end; ++ sit)
 	{
-		Enqueue(*sit);
-	}
-}
-
-
-void RenderQueue::Enqueue(Shape *shape)
+		Enqueue(*sit, entity->GetTransform());
+	}
+}
+
+
+void RenderQueue::Enqueue(Shape *shape, Transform3 *trafo)
 {
 	Technique *tech = shape->GetMaterial()->GetTechnique(mState->GetRenderTechnique());
@@ -157,5 +159,5 @@
 	}
 
-	bucket->mShapes.push_back(shape);
+	bucket->mShapes.push_back(ShapePair(shape, trafo));
 }
 
@@ -184,10 +186,16 @@
 	for (size_t i = 0; i < mActiveBuckets.size(); ++ i)
 	{
-		ShapeContainer::const_iterator sit, sit_end = mActiveBuckets[i]->mShapes.end();
+		ShapePairArray::const_iterator sit, sit_end = mActiveBuckets[i]->mShapes.end();
 
 		for (sit = mActiveBuckets[i]->mShapes.begin(); sit != sit_end; ++ sit)
 		{
-			Shape *shape = *sit;
+			ShapePair s = *sit;
+
+			Shape *shape = s.first;
+			Transform3 *t = s.second;
+
+			t->Load(mState);
 			shape->Render(mState);
+			t->Unload(mState);
 		}
 	}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h	(revision 3071)
@@ -32,5 +32,5 @@
 	/** Creates a scene entity.
 	*/
-	Shape(Geometry *geometry, Material *mat, SceneEntity *parent);
+	Shape(Geometry *geometry, Material *mat);
 
 	~Shape();
@@ -43,5 +43,5 @@
 	/** See set
 	*/
-	Geometry *GetGeometry() const { return mGeometry; }
+	inline Geometry *GetGeometry() const { return mGeometry; }
 	/** Set pointer to the material
 	*/
@@ -50,13 +50,10 @@
 	*/
 	AxisAlignedBox3 GetBoundingBox() const;
-	/** Returns bounding box transformed with the parent transform.
-	*/
-	AxisAlignedBox3 GetWorldBoundingBox() const;
 	/** Returns material of this shape.
 	*/
 	inline Material *GetMaterial() const  { return mMaterial; }
-	/** Returns transformed center point of this shape.
+	/** Returns center point of this shape.
 	*/
-	Vector3 GetWorldCenter() const;
+	Vector3 GetCenter() const;
 
 
@@ -67,5 +64,4 @@
 	Geometry *mGeometry;
 	Material *mMaterial;
-	SceneEntity *mParent;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 3071)
@@ -1184,15 +1184,6 @@
     while (1)
 	{
-		while (mGeometry[i]->GetWorldCenter()[axis] < position) 
-		{
-			//cout<<" i " << i << " " << mGeometry[i]->GetWorldCenter()[axis];
-			++ i;
-		}
-
-		while (position < mGeometry[j]->GetWorldCenter()[axis])
-		{
-			//cout<< axis << " j " << j << " " << mGeometry[j]->GetWorldCenter()[axis] << " " << position<< " ";
-			-- j;
-		}
+		while (mGeometry[i]->GetWorldCenter()[axis] < position) ++ i;
+		while (position < mGeometry[j]->GetWorldCenter()[axis]) -- j;
 
 		// sorting finished
@@ -1216,5 +1207,4 @@
 	// spatial median
 	float m = leaf->mBox.Center()[axis];
-	//cout << "here3 " << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl;
 	return SortTriangles(leaf, axis, m);
 }
@@ -1229,4 +1219,5 @@
 		leaf->mIsVirtualLeaf = true;
 		leaf->mIsMaxDepthForVirtualLeaf = true;
+		cout << "leaf contructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl;
 		return leaf;
 	}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h	(revision 3061)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h	(revision 3071)
@@ -3,5 +3,4 @@
 
 #include "common.h"
-#include "Timer/PerfTimer.h"
 
 
@@ -12,4 +11,6 @@
 class Camera;
 
+typedef std::pair<Shape *, Transform3 *> ShapePair;
+typedef std::vector<ShapePair> ShapePairArray;
 
 /** Defines a bucket for scene entities that have the same properties.
@@ -45,5 +46,5 @@
 
 	/// the shapes that belong to a bucket
-	ShapeContainer mShapes;
+	ShapePairArray mShapes;
 };
 
@@ -73,5 +74,5 @@
 	/** Enqueues a single shape.
 	*/
-	void Enqueue(Shape *shape);
+	void Enqueue(Shape *shape, Transform3 *trafo);
 	/** Sets the current render state
 	*/
@@ -86,4 +87,5 @@
 	*/
 	void Clear();
+
 
 protected:
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp	(revision 3071)
@@ -102,8 +102,12 @@
 	}
 
+	mTransform->Load(state);
+
 	for (; sit != sit_end; ++ sit)
 	{
 		(*sit)->Render(state);
 	}
+
+	mTransform->Unload(state);
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp	(revision 3071)
@@ -32,5 +32,4 @@
 {
 	if (mIsIdentity) return;
-
 	glPopMatrix();
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3070)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3071)
@@ -497,11 +497,9 @@
 	LoadModel("hbuddha.dem", dynamicObjects);
 	buddha = dynamicObjects.back();
-	dynamicObjects.clear();
-	Vector3 sceneCenter(470.398f, 240.364f, 182.5f);
+	
+	const Vector3 sceneCenter(470.398f, 240.364f, 182.5f);
 	Matrix4x4 transl = TranslationMatrix(sceneCenter);
 	buddha->GetTransform()->SetMatrix(transl);
 
-	Vector3 offs = Vector3::ZERO();
-
 	for (int i = 0; i < 10; ++ i)
 	{
@@ -509,6 +507,8 @@
 		resourceManager->AddSceneEntity(ent);
 
-		offs.x = RandomValue(.0f, 50.0f);
-		offs.y = RandomValue(.0f, 50.0f);
+		Vector3 offs = Vector3::ZERO();
+
+		offs.x = RandomValue(.0f, 150.0f);
+		offs.y = RandomValue(.0f, 150.0f);
 
 		transl = TranslationMatrix(sceneCenter + offs);
@@ -1873,6 +1873,4 @@
 void RenderSky()
 {
-	//buddha->Render(&state);
-
 	if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED))
 		state.SetRenderTechnique(DEFERRED);
@@ -2008,5 +2006,6 @@
 		for (sit = (*resourceManager->GetShapes()).begin(); sit != sit_end; ++ sit)
 		{
-			renderQueue->Enqueue(*sit);
+			static Transform3 dummy(IdentityMatrix());
+			renderQueue->Enqueue(*sit, &dummy);
 		}
 	
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.cpp	(revision 2802)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.cpp	(revision 3071)
@@ -24,5 +24,5 @@
 		else
 		{
-			mStats.mNumFrustumCulledNodes ++;
+			++ mStats.mNumFrustumCulledNodes;
 		}
 	}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3055)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3071)
@@ -228,4 +228,26 @@
 			</File>
 			<File
+				RelativePath=".\src\RenderTraverser.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\$(InputName)1.obj"
+						XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\$(InputName)1.obj"
+						XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath=".\src\SampleGenerator.cpp"
 				>
@@ -368,26 +390,4 @@
 				<File
 					RelativePath=".\src\FrustumCullingTraverser.cpp"
-					>
-					<FileConfiguration
-						Name="Debug|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32"
-						>
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)\$(InputName)1.obj"
-							XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
-						/>
-					</FileConfiguration>
-				</File>
-				<File
-					RelativePath=".\src\RenderTraverser.cpp"
 					>
 					<FileConfiguration
