Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2784)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2786)
@@ -46,5 +46,6 @@
 mUseRenderQueue(false),
 mAssumedVisibleFrames(10),
-mMaxBatchSize(50)
+mMaxBatchSize(50),
+mUseTightBounds(false)
 {
 }
@@ -127,11 +128,7 @@
 void RenderTraverser::RenderScene()
 {
+	//glFinish();
 	PerfTimer timer;
-
 	timer.Start();
-
-	//InitTiming();
-	//long t1, t2;
-	//t1 = GetTime();
 
 	glEnableClientState(GL_VERTEX_ARRAY);
@@ -158,6 +155,5 @@
 	glDisableClientState(GL_NORMAL_ARRAY);
 
-	//t2 = GetTime();
-	//mStats.mRenderTime = TimeDiff(t1, t2);
+	//glFinish();
 	mStats.mRenderTime = timer.Elapsedms();
 }
@@ -198,7 +194,13 @@
 {
 	mUseMultiQueries = useMultiQueries;
-	std::cout << "using multiqueries: " << mUseMultiQueries << std::endl;
-}
-
+	//cout << "using multiqueries: " << mUseMultiQueries << endl;
+}
+
+
+void RenderTraverser::SetUseTightBounds(bool useTightBounds)
+{
+	mUseTightBounds = useTightBounds;
+	cout << "using tight bounds: " << useTightBounds << endl;
+}
 
 
@@ -243,5 +245,5 @@
 			++ mStats.mNumStateChanges;
 
-		mBvh->RenderBoundingBoxes(query.GetNodes(), mRenderState);
+		mBvh->RenderBounds(query.GetNodes(), mRenderState, mUseTightBounds);
 	}
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp	(revision 2786)
@@ -366,18 +366,46 @@
 
 
-void Bvh::RenderBoundingBox(BvhNode *node, RenderState *state)
-{
-	//RenderBoundingBoxImmediate(node->GetBox());
-	static BvhNodeContainer dummy(1);
-	dummy[0] = node;
-	RenderBoundingBoxes(dummy, state);
-}
-
-
-
-int Bvh::RenderBoundingBoxes(const BvhNodeContainer &nodes, RenderState *state)
-{
-	int renderedBoxes = PrepareBoundingBoxesWithDrawArrays(nodes);
-	RenderBoundingBoxesWithDrawArrays(renderedBoxes, state);
+void Bvh::RenderBounds(BvhNode *node, RenderState *state, bool useTightBounds)
+{
+	// if not using tight bounds, rendering boxes in immediate mode
+	// is preferable to vertex arrays (less setup time)
+	if (!useTightBounds)
+	{
+		RenderBoundingBoxImmediate(node->GetBox());
+	}
+	else
+	{
+		static BvhNodeContainer dummy(1);
+		dummy[0] = node;
+		RenderBounds(dummy, state, useTightBounds);
+	}
+}
+
+
+int Bvh::RenderBounds(const BvhNodeContainer &nodes, 
+					  RenderState *state, 
+					  bool useTightBounds)
+{
+	// if not using tight bounds, rendering boxes in immediate mode
+	// is preferable to vertex arrays (less setup time)
+
+	int renderedBoxes;
+
+	if (!useTightBounds)
+	{
+		BvhNodeContainer::const_iterator nit, nit_end = nodes.end();
+			
+		for (nit = nodes.begin(); nit != nit_end; ++ nit)
+		{
+			RenderBoundingBoxImmediate((*nit)->GetBox());
+		}
+
+		renderedBoxes = (int)nodes.size();
+	}
+	else
+	{
+		renderedBoxes = PrepareBoundsWithDrawArrays(nodes);
+		RenderBoundsWithDrawArrays(renderedBoxes, state);
+	}
 
 	return renderedBoxes;
@@ -385,5 +413,5 @@
 
 
-int Bvh::PrepareBoundingBoxesWithDrawArrays(const BvhNodeContainer &nodes)
+int Bvh::PrepareBoundsWithDrawArrays(const BvhNodeContainer &nodes)
 {
 	//////
@@ -428,5 +456,5 @@
 
 
-void Bvh::RenderBoundingBoxesWithDrawArrays(int numNodes, RenderState *state)
+void Bvh::RenderBoundsWithDrawArrays(int numNodes, RenderState *state)
 {
 	//////
@@ -706,4 +734,6 @@
 	nodeStack.push(mRoot);
 
+	int numVirtualLeaves = 0;
+
 	while (!nodeStack.empty()) 
 	{
@@ -713,4 +743,6 @@
 		if (node->IsVirtualLeaf()) 
 		{
+			++ numVirtualLeaves;
+
 			BvhLeaf *leaf = static_cast<BvhLeaf *>(node);
 
@@ -731,6 +763,6 @@
 	}
 
-	mBvhStats.mGeometryRatio = mGeometrySize / (float)GetNumLeaves();
-	mBvhStats.mTriangleRatio = mBvhStats.mTriangles / (float)GetNumLeaves();
+	mBvhStats.mGeometryRatio = mGeometrySize / (float)numVirtualLeaves;
+	mBvhStats.mTriangleRatio = mBvhStats.mTriangles / (float)numVirtualLeaves;
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/OcclusionQuery.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/OcclusionQuery.cpp	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/OcclusionQuery.cpp	(revision 2786)
@@ -13,5 +13,5 @@
 	glGenQueriesARB(1, &mQueryId);
 
-	// reverse for multiequeries with 32 nodes
+	// reverse for multiqueries with 20 nodes
 	mNodes.reserve(32);
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp	(revision 2786)
@@ -25,13 +25,14 @@
 		delete [] mVertices; mVertices = NULL;
 		delete [] mNormals;  mNormals = NULL;
-		if (!mTexCoords) delete [] mTexCoords; mTexCoords = NULL;
+		//if (mTexCoords) delete [] mTexCoords; mTexCoords = NULL;
 	}
 }
 
+
 Geometry::~Geometry()
 {
-	if (!mVertices) delete [] mVertices;	
-	if (!mNormals) delete [] mNormals;
-	if (!mTexCoords) delete [] mTexCoords;
+	if (mVertices) delete [] mVertices;	
+	if (mNormals) delete [] mNormals;
+	if (mTexCoords) delete [] mTexCoords;
 
 	// delete vbo
@@ -74,4 +75,5 @@
 		glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + 2 * mNumVertices * sizeof(Vector3));
 	}
+
 	glBufferDataARB(GL_ARRAY_BUFFER_ARB, 
 		            dataSize * sizeof(float), 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2784)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2786)
@@ -49,10 +49,7 @@
 int assumedVisibleFrames = 10;
 int maxBatchSize = 50;
-bool useMultiQueries = true;
 
 const float keyForwardMotion = 1.0f;
 const float keyRotation = 0.2f;
-
-bool useRenderQueue = false;
 
 int winWidth = 1024;
@@ -84,4 +81,7 @@
 
 bool useOptimization = false;
+bool useTightBounds = true;
+bool useRenderQueue = false;
+bool useMultiQueries = true;
 
 
@@ -95,9 +95,9 @@
 void DisplayStats();
 void Output(int x, int y, const char *string);
+void DrawHelpMessage();
 
 void begin2D();
 void end2D();
 void keyboard(unsigned char c, int x, int y);
-void drawHelpMessage();
 void drawStatistics();
 void display(void);
@@ -233,5 +233,5 @@
 
 
-void drawHelpMessage(void) 
+void DrawHelpMessage(void) 
 {
 	const char *message[] = 
@@ -257,5 +257,5 @@
 		"'9'            - downward motion",
 		"",
-		"'G'            - enables/disables optimization to take geometry as occluder",
+		"'R'            - use render queue",
 		"",
 		"'S'            - shows/hides statistics",
@@ -269,5 +269,5 @@
 	
 	
-	int x = 40, y = 42;
+	int x = 40, y = 60;
 
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -286,10 +286,10 @@
 		if(message[i][0] == '\0') 
 		{
-			y += 7;
+			y += 15;
 		} 
 		else 
 		{
 			Output(x, y, message[i]);
-			y += 14;
+			y += 20;
 		}
 	}
@@ -332,4 +332,5 @@
 	traverser->SetMaxBatchSize(maxBatchSize);
 	traverser->SetUseMultiQueries(useMultiQueries);
+	traverser->SetUseTightBounds(useTightBounds);
 }
 
@@ -546,4 +547,10 @@
 			traverser->SetUseRenderQueue(useRenderQueue);
 		}
+	case 'b':
+	case 'B':
+		{
+			useTightBounds = !useTightBounds;
+			traverser->SetUseTightBounds(useTightBounds);
+		}
 	default:
 		return;
@@ -718,13 +725,10 @@
 	// the 90 degree rotated view vector 
 	// y zero so we don't move in the vertical
-	//Vector3 rVec(viewDir[0], 0, viewDir[2]);
 	Vector3 rVec(viewDir[0], viewDir[1], 0);
 	
-	//Matrix4x4 rot = RotationYMatrix(M_PI * 0.5f);
 	Matrix4x4 rot = RotationZMatrix(M_PI * 0.5f);
 	rVec = rot * rVec;
 	
 	pos -= rVec * (x - horizontalMotionBegin) * 0.1f;
-	//pos[1] += (verticalMotionBegin - y) * 0.1f;
 	pos[2] += (verticalMotionBegin - y) * 0.1f;
 
@@ -914,5 +918,6 @@
 	}
 
-	sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d, using multiqueries: %d, using render queue: %d", assumedVisibleFrames, maxBatchSize, useMultiQueries, useRenderQueue);
+	sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d, using render queue: %d", 
+		      assumedVisibleFrames, maxBatchSize, useRenderQueue);
 
 	string str;
@@ -935,5 +940,5 @@
 	if(showHelp)
 	{	
-		drawHelpMessage();
+		DrawHelpMessage();
 	}
 	else
@@ -942,5 +947,5 @@
 		Output(850, 30, msg[renderMode]);
 
-		if(showStatistics)
+		if (showStatistics)
 		{
 			Output(20, 30, msg2);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp	(revision 2786)
@@ -98,6 +98,7 @@
 
 	bvh->PostProcess();
-	// set virtual leaves for 500 triangles
-	bvh->SetVirtualLeaves(0);
+	const int n = 1000;
+	// set virtual leaves for n triangles
+	bvh->SetVirtualLeaves(n);
 
 	bvh->UpdateNumLeaves(bvh->mRoot);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BinaryLoader.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BinaryLoader.cpp	(revision 2784)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BinaryLoader.cpp	(revision 2786)
@@ -193,5 +193,5 @@
 		texcoords = NULL;
 
-	return new Geometry(vertices, normals, texcoords, vertexCount, false);
+	return new Geometry(vertices, normals, texcoords, vertexCount, true);
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h	(revision 2786)
@@ -109,4 +109,7 @@
 	*/
 	void SetUseMultiQueries(bool useMultiQueries);
+	/** If thight bounds should be used or the bounding boxes should be tested.
+	*/
+	void SetUseTightBounds(bool useTightBounds);
 
 protected:
@@ -171,4 +174,6 @@
 
 	bool mUseMultiQueries;
+
+	bool mUseTightBounds;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 2786)
@@ -460,12 +460,12 @@
 	//-- Rendering related options
 
-	/** Renders the bounding box of this node (Or the tigher bounding boxes of some subnodes).
-	*/
-	void RenderBoundingBox(BvhNode *node, RenderState *state);
+	/** Renders the bounds of this node 
+	    (the box of the node or the tigher bounds of some subnodes).
+	*/
+	void RenderBounds(BvhNode *node, RenderState *state, bool useTightBounds);
 	/** Renders bounding boxes of the collection of nodes.
 		@returns #rendered boxes
 	*/
-	int RenderBoundingBoxes(const BvhNodeContainer &nodes, RenderState *state);
-
+	int RenderBounds(const BvhNodeContainer &nodes, RenderState *state, bool useTightBounds);
 	/** Returns the bounding box of this bvh.
 	*/
@@ -516,4 +516,5 @@
 	void SetVirtualLeaves(int numTriangles);
 
+
 	////////
 	//-- functions influencing tighter bounds
@@ -562,6 +563,6 @@
 	void PrepareVertices();
 
-	int PrepareBoundingBoxesWithDrawArrays(const BvhNodeContainer &nodes);
-	void RenderBoundingBoxesWithDrawArrays(int numNodes, RenderState *state);
+	int PrepareBoundsWithDrawArrays(const BvhNodeContainer &nodes);
+	void RenderBoundsWithDrawArrays(int numNodes, RenderState *state);
 
 	/** Create the indices that each node needs to use vbo rendering.
@@ -590,5 +591,6 @@
 	*/
 	inline bool TestPlane(BvhNode *node, int i, bool &bIntersect);
-
+	/** Renders a bounding box in immediate mode.
+	*/
 	void RenderBoundingBoxImmediate(const AxisAlignedBox3 &box);
 
