Index: trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h
===================================================================
--- trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h	(revision 74)
+++ trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h	(revision 85)
@@ -36,8 +36,4 @@
 
 	AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node);
-
-protected:
-	
-	
 };
 
Index: trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
===================================================================
--- trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h	(revision 71)
+++ trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h	(revision 85)
@@ -77,12 +77,11 @@
 	*/
 	void RenderBoundingBox(AxisAlignedBox *box);
-	/** Returns one half of the bounding box.
-		@param half the half index of the bouding box (0 or 1)
+	/** Returns pointer to current renderable half bounding box geometry
 	*/
-	SolidHalfBoundingBox *GetSolidHalfBoundingBox(int half);
+	SolidHalfBoundingBox *GetSolidHalfBoundingBox();
 
-	/** two halfes of an aabb. 
+	/** one renderable half of an aabb. 
 	*/
-	SolidHalfBoundingBox *mHalfBoundingBox[2];	
+	SolidHalfBoundingBox *mSolidHalfBoundingBox;
 
 	SceneManager *mSceneManager;
@@ -91,5 +90,5 @@
 	Camera *mCamera;
 	AxisAlignedBox mBox;
-
+	
 	std::vector<PlatformOcclusionQuery *> mOcclusionQueries;
 };
Index: trunk/VUT/Ogre/include/OgreSolidHalfBoundingBox.h
===================================================================
--- trunk/VUT/Ogre/include/OgreSolidHalfBoundingBox.h	(revision 59)
+++ trunk/VUT/Ogre/include/OgreSolidHalfBoundingBox.h	(revision 85)
@@ -15,17 +15,17 @@
 public:
 
-	SolidHalfBoundingBox(bool isFirstHalf);
-	void setupBoundingBox(const AxisAlignedBox& aabb);
-	/** Override this method to prevent parent transforms (rotation,translation,scale)
-		and to make it public.
+	SolidHalfBoundingBox();
+	/** Sets up the first or second half of a solid bounding box.
+		@param aab the axis aligned bounding box
+		@param isFirstHalf if it is the first or the second half
+	*/
+	void SetupBoundingBox(const AxisAlignedBox& aabb, const bool isFirstHalf);
+	
+protected:
+    /** Builds the wireframe line list.
+		@param aab the axis aligned bounding box for setting up the vertices
+		@param first or second half of the box
     */
-	void getWorldTransforms(Matrix4* xform) const;
-
-protected:
-    
-    /** Builds the wireframe line list.
-		@param aab the axis aligned bounding box for setting up the list.
-    */
-	void setupBoundingBoxVertices(const AxisAlignedBox& aab);
+	void SetupBoundingBoxVertices(const AxisAlignedBox& aab, const bool isFirstHalf);
 	/** 
 		Sets the material used for occlusion queries. 
@@ -33,5 +33,5 @@
 		uses no lighting, no depth write, and no colours
 	*/
-	void setOcclusionQueryMaterial();
+	void SetOcclusionQueryMaterial();
 	/** Whether this half box is the first or the second half of the bounding box. 
 	*/
Index: trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp	(revision 74)
+++ trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp	(revision 85)
@@ -140,5 +140,9 @@
 AxisAlignedBox *OctreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node)
 {
-	static_cast<Octree *>(node)->_getCullBounds(&mBox);
+	if(node != mPreviousNode)
+	{
+		mPreviousNode = node;
+		static_cast<Octree *>(node)->_getCullBounds(&mBox);
+	}
 
 	return &mBox;
Index: trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp	(revision 74)
+++ trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp	(revision 85)
@@ -123,5 +123,11 @@
 AxisAlignedBox *SceneNodeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node)
 {
-	SceneNode *sceneNode = static_cast<SceneNode *>(node);
+	if(node != mPreviousNode)
+	{
+		mPreviousNode = node;
+
+		mBox = static_cast<SceneNode *>(node)->_getWorldAABB();
+	}
+
 	return &mBox;
 }
Index: trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp	(revision 74)
+++ trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp	(revision 85)
@@ -11,7 +11,6 @@
 //-----------------------------------------------------------------------
 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys):
-mSceneManager(sm), mRenderSystem(rsys)
-{		
-	mHalfBoundingBox[0] = mHalfBoundingBox[1] = NULL;
+mSceneManager(sm), mRenderSystem(rsys), mSolidHalfBoundingBox(NULL)
+{
 }
 //-----------------------------------------------------------------------
@@ -19,10 +18,7 @@
 {
 	DeleteQueries();
-	
-	if (mHalfBoundingBox[0]) 
-		delete mHalfBoundingBox[0];
 
-	if (mHalfBoundingBox[1]) 
-		delete mHalfBoundingBox[1];
+	if(mSolidHalfBoundingBox)
+		delete mSolidHalfBoundingBox;
 }
 //-----------------------------------------------------------------------
@@ -38,11 +34,10 @@
 {
 	// Render two halfes of the bounding box (using triangle fans)
-	for(int half = 0; half < 2; half ++)
+	for(int halfIdx = 0; halfIdx < 2; ++halfIdx)
 	{
-		static Matrix4 xform[256];
-		//TODO: this should be full bounding box
-		SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(half);
-		halfbox->setupBoundingBox(*box);
-		
+		//TODO: this should be the full bounding box
+		SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox();
+		halfbox->SetupBoundingBox(*box, halfIdx == 1);
+				
 		mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
 		
@@ -50,21 +45,9 @@
 
         mSceneManager->useRenderableViewProjMode(halfbox);
-		mSceneManager->setPass(halfbox->getTechnique()->getPass(0));
+		mSceneManager->setPass(GetSolidHalfBoundingBox()->getTechnique()->getPass(0));
 		halfbox->getRenderOperation(ro);
-		ro.srcRenderable = halfbox; 
+		ro.srcRenderable = halfbox;
 		mRenderSystem->_render(ro);
-		
-		// matt: change this
-//		mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half), 
-//			getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), true);
 	}
-}
-//-----------------------------------------------------------------------
-SolidHalfBoundingBox *PlatformHierarchyInterface::GetSolidHalfBoundingBox(int half)
-{
-	if(!mHalfBoundingBox[half])
-		mHalfBoundingBox[half] = new Ogre::SolidHalfBoundingBox(half == 1);
-
-	return mHalfBoundingBox[half];	
 }
 //-----------------------------------------------------------------------
@@ -100,5 +83,6 @@
 }
 //-----------------------------------------------------------------------
-bool PlatformHierarchyInterface::CheckFrustumVisible(GtpVisibility::HierarchyNode *node, bool &intersects)
+bool PlatformHierarchyInterface::CheckFrustumVisible(GtpVisibility::HierarchyNode *node, 
+													 bool &intersects)
 {
 #ifdef GTP_VISIBILITY_MODIFIED_OGRE
@@ -109,5 +93,6 @@
 }
 //-----------------------------------------------------------------------
-GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery(GtpVisibility::HierarchyNode *node) 
+GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery(
+	GtpVisibility::HierarchyNode *node) 
 {
 	// get next available test id
@@ -123,4 +108,12 @@
 	return query;
 }
+//-----------------------------------------------------------------------
+SolidHalfBoundingBox *PlatformHierarchyInterface::GetSolidHalfBoundingBox()
+{
+	if(!mSolidHalfBoundingBox)
+		mSolidHalfBoundingBox = new SolidHalfBoundingBox;
+
+	return mSolidHalfBoundingBox;
+}
 
 } // namespace Ogre
Index: trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp	(revision 59)
+++ trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp	(revision 85)
@@ -12,8 +12,7 @@
 #define POSITION_BINDING 0
 //-----------------------------------------------------------------------
-SolidHalfBoundingBox::SolidHalfBoundingBox(bool isFirstHalf)
-	:WireBoundingBox(), mIsFirstHalf(isFirstHalf)
+SolidHalfBoundingBox::SolidHalfBoundingBox()
 {
-	setOcclusionQueryMaterial();
+	SetOcclusionQueryMaterial();
 	
 	mRenderOp.vertexData->vertexCount = 8;
@@ -21,10 +20,10 @@
 }
 //-----------------------------------------------------------------------
-void SolidHalfBoundingBox::setupBoundingBoxVertices(const AxisAlignedBox& aab) {
-
+void SolidHalfBoundingBox::SetupBoundingBoxVertices(const AxisAlignedBox& aab, 
+													const bool isFirstHalf) 
+{
 	Vector3 vmax = aab.getMaximum();
 	Vector3 vmin = aab.getMinimum();
-	
-	
+		
 	Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength());
     mRadius = Math::Sqrt(sqLen);
@@ -38,5 +37,5 @@
 	Real minz = vmin.z;
 	
-	// fill in the Vertex buffer: 12 lines with 2 endpoints each make up a box
+	// fill the vertex buffer: 12 lines with 2 endpoints each make up a box
     HardwareVertexBufferSharedPtr vbuf =
         mRenderOp.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING);     
@@ -55,5 +54,5 @@
 
 	// fan 1
-	if(mIsFirstHalf)
+	if(isFirstHalf)
 	{
 		*pPos++ = minx; *pPos++ = maxy; *pPos++ = maxz; //011
@@ -66,5 +65,4 @@
 		*pPos++ = minx; *pPos++ = miny; *pPos++ = minz; //000
 		*pPos++ = minx; *pPos++ = miny; *pPos++ = maxz; //001
-
 	}
 	else
@@ -84,21 +82,16 @@
     vbuf->unlock();
 }
-
-void SolidHalfBoundingBox::setupBoundingBox(const AxisAlignedBox& aabb) 
+//-----------------------------------------------------------------------
+void SolidHalfBoundingBox::SetupBoundingBox(const AxisAlignedBox& aabb, 
+											const bool isFirstHalf) 
 {
 	// init the vertices to the aabb
-	SolidHalfBoundingBox::setupBoundingBoxVertices(aabb);
+	SetupBoundingBoxVertices(aabb, isFirstHalf);
 
     // setup the bounding box of this SimpleRenderable
 	setBoundingBox(aabb);
 }
-// Override this method to prevent parent transforms (rotation,translation,scale)
-void SolidHalfBoundingBox::getWorldTransforms( Matrix4* xform ) const
-{
-	// return identity matrix to prevent parent transforms
-    *xform = Matrix4::IDENTITY;
-}
-
-void SolidHalfBoundingBox::setOcclusionQueryMaterial( void )
+//-----------------------------------------------------------------------
+void SolidHalfBoundingBox::SetOcclusionQueryMaterial( void )
 {
 	m_pMaterial = MaterialManager::getSingleton().getByName("OcclusionQuery");
Index: trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 74)
+++ trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 85)
@@ -19,7 +19,7 @@
 
 	setVisibilityManager(visManager);
-	mShowBoxes = true;
+	//mShowBoxes = true;
 	//mDisplayNodes = true;
-	mShowBoundingBoxes = true;
+	//mShowBoundingBoxes = true;
 	mMaxDepth = 20;
 }
