Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp	(revision 3266)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp	(revision 3267)
@@ -142,4 +142,5 @@
 	Bvh *bvh = new Bvh(staticEntities, dynamicEntities, maxDepthForTestingChildren);
 
+	cout << "here8 " << (int)bvh->mStaticGeometrySize - 1 << endl;
 	BvhConstructor bvhConstructor(bvh->mGeometry, 
 		                          0,
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 3266)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 3267)
@@ -590,5 +590,5 @@
 	void CreateDynamicBranch();
 
-	void UpdateDynamicBranch(BvhNode *node);
+	void UpdateBoundingBoxes(BvhNode *node);
 
 	inline bool TerminationCriteriaMet(BvhLeaf *leaf) const;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 3266)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 3267)
@@ -504,5 +504,5 @@
 	if (mDynamicGeometrySize)
 	{
-		UpdateDynamicBranch(mDynamicRoot);
+		UpdateBoundingBoxes(mDynamicRoot);
 		UpdateDynamicBounds(state);
 	}
@@ -874,5 +874,5 @@
 	cout << "created tighter bounds for " << p << " percent of the nodes" << endl;
 
-	// recreate indices used for indirect mode rendering
+	// recreate indices used for indirect rendering mode
 	if (mIndices) CreateIndices();
 }
@@ -956,5 +956,5 @@
 	int numVirtualLeaves = 0;
 	int numGeometry = 0;
-cout<<"here3 computing stats"<<endl;
+
 	while (!nodeStack.empty()) 
 	{
@@ -962,8 +962,4 @@
 		nodeStack.pop();
 
-		cout << "x";
-		if (node->IsLeaf() && !node->IsVirtualLeaf())
-			cerr << "here34"<<endl;
-
 		if (node->IsVirtualLeaf()) 
 		{
@@ -971,5 +967,4 @@
 			numGeometry += node->CountPrimitives();
 
-			cout << " l " << numGeometry;
 			BvhLeaf *leaf = static_cast<BvhLeaf *>(node);
 
@@ -980,6 +975,4 @@
 		else 
 		{
-			cout << "i";
-
 			bvhStats.mInteriorSA += node->mBox.SurfaceArea();
 			bvhStats.mInteriorVol += node->mBox.GetVolume();
@@ -1090,10 +1083,9 @@
 	// assign new virtual leaves based on specified #triangles per leaf
 	std::stack<BvhNode *> nodeStack;
-	nodeStack.push(mRoot);
-
-	cout << "here9" << endl;
+	nodeStack.push(mStaticRoot);
+	nodeStack.push(mDynamicRoot);
+
 	while (!nodeStack.empty()) 
 	{
-		cout <<"u"<< endl;
 		BvhNode *node = nodeStack.top();
 		nodeStack.pop();
@@ -1116,5 +1108,5 @@
 				(CountTriangles(node) <= numTriangles))
 			{
-				cout << " l " << CountTriangles(node) << " " << node->mIsMaxDepthForVirtualLeaf << endl;
+				//cout << " l " << CountTriangles(node) << " " << node->mIsMaxDepthForVirtualLeaf << endl;
 				node->mIsVirtualLeaf = true;
 			}
@@ -1145,12 +1137,13 @@
 
 	std::stack<BvhNode *> nodeStack;
-	nodeStack.push(mRoot);
-
-	cout << "here7 computing depth" << endl;
+
+	nodeStack.push(mStaticRoot);
+	nodeStack.push(mDynamicRoot);
+
 	while (!nodeStack.empty()) 
 	{
 		BvhNode *node = nodeStack.top();
 		nodeStack.pop();
-cout << "z";
+
 		if (node->IsLeaf()) 
 		{
@@ -1166,5 +1159,4 @@
 			if ((f->mFirst == b->mFirst) && (f->mLast == b->mLast))
 			{
-				cout << "f: " << f->mFirst << " " << f->mLast << endl;
 				// point reached where beyond there would be no further reduction 
 				// as both subtrees contain the same objects => stop here
@@ -1180,5 +1172,4 @@
 		}
 	}
-	cout << "here7" << endl;
 }
 
@@ -1205,5 +1196,5 @@
 
 	BvhStats staticBvhStats;
-	ComputeBvhStats(mRoot, staticBvhStats);
+	ComputeBvhStats(mStaticRoot, staticBvhStats);
 	cout << "\n============ Static BVH statistics =============" << endl;
 
@@ -1404,5 +1395,5 @@
 
 
-void Bvh::UpdateDynamicBranch(BvhNode *node)
+void Bvh::UpdateBoundingBoxes(BvhNode *node)
 {
 	if (node->IsLeaf())
@@ -1419,6 +1410,6 @@
 		BvhNode *b = static_cast<BvhInterior *>(node)->GetBack();
 
-		UpdateDynamicBranch(f);
-		UpdateDynamicBranch(b);
+		UpdateBoundingBoxes(f);
+		UpdateBoundingBoxes(b);
 
 		node->mBox = f->mBox;
@@ -1452,3 +1443,6 @@
 }
 
-}
+
+
+
+}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.h	(revision 3264)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.h	(revision 3267)
@@ -32,4 +32,6 @@
 	inline bool TerminationCriteriaMet(BvhLeaf *leaf) const;
 
+	void UpdateBoundingBoxes(BvhNode *node);
+
 
 	/////////////////
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3266)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3267)
@@ -77,5 +77,5 @@
 FrameBufferObject *fbo = NULL;
 /// the renderable scene geometry
-SceneEntityContainer sceneEntities;
+SceneEntityContainer staticObjects;
 /// the dynamic objects in the scene
 SceneEntityContainer dynamicObjects;
@@ -568,5 +568,5 @@
 	//-- load the static scene geometry
 
-	LoadModel(filename + ".dem", sceneEntities);
+	LoadModel(filename + ".dem", staticObjects);
 
 
@@ -645,6 +645,6 @@
 
 	BvhFactory bvhFactory;
-	//bvh = bvhFactory.Create(bvh_filename, sceneEntities, dynamicObjects, maxDepthForTestingChildren);
-	bvh = bvhFactory.Create(sceneEntities, dynamicObjects, maxDepthForTestingChildren);
+	//bvh = bvhFactory.Create(bvh_filename, staticObjects, dynamicObjects, maxDepthForTestingChildren);
+	bvh = bvhFactory.Create(staticObjects, dynamicObjects, maxDepthForTestingChildren);
 
 	if (!bvh)
@@ -671,6 +671,6 @@
 	//-- setup the skydome model
 
-	LoadModel("sky.dem", sceneEntities);
-	skyDome = sceneEntities.back();
+	LoadModel("sky.dem", staticObjects);
+	skyDome = staticObjects.back();
 
 	/// the turbitity of the sky (from clear to hazy, use <3 for clear sky)
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp	(revision 3265)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp	(revision 3267)
@@ -40,7 +40,7 @@
 
 int BvhConstructor::SortTriangles(BvhLeaf *leaf, 
-					   int axis, 
-					   float position
-					   )
+								  int axis, 
+								  float position
+								  )
 {
 	int i = leaf->mFirst;
@@ -69,4 +69,28 @@
 
 
+void BvhConstructor::UpdateBoundingBoxes(BvhNode *node)
+{
+	if (node->IsLeaf())
+	{
+		int numEntities = node->CountPrimitives();
+		SceneEntity **entities = mEntities + node->mFirst;
+
+		node->mBox = SceneEntity::ComputeBoundingBox(entities, numEntities);
+		//cout << "box: " << node->mBox << endl;
+	}
+	else
+	{
+		BvhNode *f = static_cast<BvhInterior *>(node)->GetFront();
+		BvhNode *b = static_cast<BvhInterior *>(node)->GetBack();
+
+		UpdateBoundingBoxes(f);
+		UpdateBoundingBoxes(b);
+
+		node->mBox = f->mBox;
+		node->mBox.Include(b->mBox);
+	}
+}
+
+
 int BvhConstructor::SortTrianglesSpatialMedian(BvhLeaf *leaf, 
 											   int axis)
@@ -84,6 +108,6 @@
 	if (TerminationCriteriaMet(leaf))
 	{
-		if (leaf->CountPrimitives() <= 0)
-			cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl;
+		//if (leaf->CountPrimitives() <= 0)
+		//cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl;
 		return leaf;
 	}
@@ -157,5 +181,4 @@
 {
 	BvhNode *root;
-
 	mNumNodes = 1;
 
@@ -168,8 +191,10 @@
 	l->mArea = l->mBox.SurfaceArea();
 	
-	cout << "constructing bvh"  << endl;
+	cout << "constructing bvh from "  << l->mFirst << " to " << l->mLast << endl;
 
 	root = SubdivideLeaf(l, 0);
 
+	UpdateBoundingBoxes(root);
+
 	numNodes = mNumNodes;
 
