Index: GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h	(revision 1695)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.h	(revision 1758)
@@ -280,17 +280,5 @@
 		float GetPriority() const
 		{
-			HierarchyManager *hm = sOspTree->mHierarchyManager;
-			if (hm->ConsiderMemory())
-			{
-				const float rc = hm->GetHierarchyStats().mTotalCost - mRenderCostDecrease;
-				const float mc = hm->GetHierarchyStats().mMemory +
-								 (float)mPvsEntriesIncr * ObjectPvs::GetEntrySizeByte();
-
-				return - (rc * mc);
-			}
-			else
-			{
-				return mPriority;
-			}
+			return mPriority;
 		}
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1757)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1758)
@@ -46,8 +46,4 @@
 BvhNode::BvhNode(): 
 mParent(NULL), 
-mMailbox(0),
-//mRenderCostDecr(0), 
-//mMemoryIncr(0),
-//mPvsEntriesIncr(0),
 mTimeStamp(0)
 {
@@ -58,8 +54,4 @@
 mParent(NULL), 
 mBoundingBox(bbox), 
-mMailbox(0),
-//mMemoryIncr(0),
-//mRenderCostDecr(0), 
-//mPvsEntriesIncr(0),
 mTimeStamp(0)
 {
@@ -70,8 +62,4 @@
 mBoundingBox(bbox), 
 mParent(parent), 
-mMailbox(0),
-//mMemoryIncr(0),
-//mRenderCostDecr(0), 
-//mPvsEntriesIncr(0),
 mTimeStamp(0)
 {
@@ -219,12 +207,4 @@
 BvHierarchy::~BvHierarchy()
 {
-	// delete bvh intersectables
-	BvhIntersectableMap::iterator it, it_end = mBvhIntersectables.end();
-
-	for (it = mBvhIntersectables.begin(); it != mBvhIntersectables.end(); ++ it)
-	{
-		DEL_PTR((*it).second);
-	}
-
 	// delete the local subdivision candidates
 	DEL_PTR(mSubdivisionCandidates);
@@ -1402,5 +1382,5 @@
 	const bool useMailboxing = false;
 
-	CollectViewCells(obj, viewCells, useMailboxing, true, true);
+	CollectViewCells(obj, viewCells, useMailboxing, false, true);
 
 	// classify view cells and compute volume contri accordingly
@@ -1836,5 +1816,5 @@
 	ViewCellContainer viewCells;
 	ViewCell::NewMail();
-	int numRays = CollectViewCells(node->mObjects, viewCells, true, false);
+	int numRays = CollectViewCells(node->mObjects, viewCells, false, false);
 
 	//cout << "here6 " << numRays << endl;
@@ -1943,23 +1923,4 @@
 
 
-BvhIntersectable *BvHierarchy::GetOrCreateBvhIntersectable(BvhLeaf *node)
-{
-	// search nodes
-	std::map<BvhLeaf *, BvhIntersectable *>::const_iterator 
-		it = mBvhIntersectables.find(node);
-
-	if (it != mBvhIntersectables.end()) 
-	{
-		return (*it).second;
-	}
-
-	// not in map => create new entry
-	BvhIntersectable *bvhObj = new BvhIntersectable(node);
-	mBvhIntersectables[node] = bvhObj;
-
-	return bvhObj;
-}
-
-
 bool BvHierarchy::Export(OUT_STREAM &stream)
 {
@@ -2424,6 +2385,5 @@
 
 
-void BvHierarchy::CollectObjects(const AxisAlignedBox3 &box,
-								 ObjectContainer &objects)
+void BvHierarchy::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects)
 {
   stack<BvhNode *> nodeStack;
@@ -2431,13 +2391,15 @@
   nodeStack.push(mRoot);
 
-  while (!nodeStack.empty()) {
+  while (!nodeStack.empty()) 
+	{
 	BvhNode *node = nodeStack.top();
 	
 	nodeStack.pop();
 	
-	if (node->IsLeaf()) {
+	  if (node->IsLeaf()) 
+		{
 	  BvhLeaf *leaf = (BvhLeaf *)node;
 	  if (Overlap(box, leaf->GetBoundingBox())) {
-		Intersectable *object = GetOrCreateBvhIntersectable(leaf);
+			Intersectable *object = leaf;
 		if (!object->Mailed()) {
 		  object->Mail();
@@ -2446,5 +2408,6 @@
 	  }
 	} 
-	else  {
+	  else 
+		{
 	  BvhInterior *interior = (BvhInterior *)node;
 	  
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1757)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 1758)
@@ -6029,5 +6029,6 @@
 		Debug << "finished in " << timeDiff * 1e-3 << " secs" << endl;
 
-		if ((castSamples >= samplesForStats + oldSamples) || (castSamples >= numSamples))
+		if ((castSamples >= samplesForStats + oldSamples) || 
+			(castSamples >= numSamples))
 		{
 			oldSamples += samplesForStats;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1737)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp	(revision 1758)
@@ -133,6 +133,5 @@
   case Intersectable::BVH_INTERSECTABLE: {
 
-	
-	BvhNode *node = (dynamic_cast<BvhIntersectable *>(object))->GetItem();
+	  BvhNode *node = dynamic_cast<BvhNode *>(object);
 
 	if (mRenderBoxes)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1723)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp	(revision 1758)
@@ -184,5 +184,5 @@
 	case Intersectable::BVH_INTERSECTABLE:
 		{
-			BvhNode *node = dynamic_cast<BvhIntersectable *>(object)->GetItem();
+			BvhNode *node = dynamic_cast<BvhNode *>(object);
 			if (node->IsLeaf())
 				ExportGeometry(dynamic_cast<BvhLeaf *>(node)->mObjects, true);
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1750)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp	(revision 1758)
@@ -2371,5 +2371,5 @@
 		{
 			ObjectContainer objects; 
-			BvhNode *node = dynamic_cast<BvhIntersectable *>(obj)->GetItem();
+			BvhNode *node = dynamic_cast<BvhNode *>(obj);
 			node->CollectObjects(objects);
 		
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1744)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1758)
@@ -32,5 +32,4 @@
 class BvhLeaf;
 class BvhNode;
-class BvhIntersectable;
 class BvhTree;
 class VspTree;
@@ -151,5 +150,5 @@
     VspNode abstract class serving for interior and leaf node implementation
 */
-class BvhNode
+class BvhNode: public Intersectable
 {
 public:
@@ -204,8 +203,4 @@
 	int mTimeStamp;
 
-	//int mPvsEntriesIncr;
-	//float mMemoryIncr;
-	//float mRenderCostDecr;
-
 	/////////////////////////////////////
 	//-- mailing options
@@ -225,6 +220,44 @@
 
 	static int sMailId;
-	int mMailbox;
+	//int mMailbox;
 	static int sReservedMailboxes;
+
+
+
+	/////////////////////////////////////////////
+	//-- inherited functions from Intersectable
+
+	AxisAlignedBox3 GetBox() const { return mBoundingBox; }
+	
+	int CastRay(Ray &ray) { return 0; }
+	
+	bool IsConvex() const { return true; }
+	bool IsWatertight() const { return true; }
+	float IntersectionComplexity() { return 1; }
+  
+	int NumberOfFaces() const { return 6; };
+	
+	int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point, 
+							  GtpVisibilityPreprocessor::Vector3 &normal)
+	{
+		// TODO
+		return 0;
+	}
+
+	int GetRandomVisibleSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
+									 GtpVisibilityPreprocessor::Vector3 &normal,
+									 const GtpVisibilityPreprocessor::Vector3 &viewpoint,
+									 const int maxTries)
+	{
+		// TODO
+		return 0;
+	}
+  
+	int Type() const
+	{
+		return Intersectable::BVH_INTERSECTABLE;
+	}
+
+	ostream &Describe(ostream &s) { return s; }
 
 	///////////////////////////////////
@@ -341,7 +374,4 @@
 	BvhNode *mActiveNode;
 };
-
-
-typedef map<BvhLeaf *, BvhIntersectable *> BvhIntersectableMap;
 
 
@@ -568,9 +598,4 @@
 	bool Export(OUT_STREAM &stream);
 
-	/** Returns or creates a new intersectable for use in a bv based pvs.
-		The hierarchy is responsible for destruction of the intersectable.
-	*/
-	BvhIntersectable *GetOrCreateBvhIntersectable(BvhLeaf *node);
-
 	/** Collects rays associated with the objects.
 	*/
@@ -943,6 +968,5 @@
 	/// weight between render cost decrease and node render cost
 	float mRenderCostDecreaseWeight;
-	/// stores the kd node intersectables used for pvs
-	BvhIntersectableMap mBvhIntersectables;
+
 	/// if the objects should be sorted in one global step
 	bool mUseGlobalSorting;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp	(revision 1737)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp	(revision 1758)
@@ -97,9 +97,3 @@
   mBox = box;
 }
-
-AxisAlignedBox3 BvhIntersectable::GetBox() const
-{
-  return mItem->GetBoundingBox();
 }
-
-}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp	(revision 1740)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp	(revision 1758)
@@ -79,12 +79,18 @@
 	We eliminate already accounted bvh nodes and objects using mailboxing. 
 */
-static float EvalBvhNodeContribution(BvhIntersectable *bvhobj)
+static float EvalBvhNodeContribution(BvhNode *bvhObj)
 {
-	BvhLeaf *leaf = bvhobj->GetItem();
-	BvhNode *node = leaf->GetActiveNode();
+	BvhNode *node;
+
+	// hack for choosing which node to account for
+	if (bvhObj->IsLeaf())
+		node = dynamic_cast<BvhLeaf *>(bvhObj)->GetActiveNode();
+	else
+		node = bvhObj;
 
 	// early exit
-	if (node == leaf)	
-	{
+	if (node->IsLeaf())	
+	{	
+		BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(node);
 		// objects already accounted for
 		if (leaf->Mailed())
@@ -112,5 +118,5 @@
 			if (node->IsLeaf())
 			{
-				leaf = dynamic_cast<BvhLeaf *>(node);
+				BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(node);
 
 				// add #objects exclusivly in this node
@@ -156,5 +162,5 @@
 			case Intersectable::BVH_INTERSECTABLE:
 				{
-					BvhIntersectable *bvhObj = dynamic_cast<BvhIntersectable *>(obj);
+					BvhNode *bvhObj = dynamic_cast<BvhNode *>(obj);
 					pvs += EvalBvhNodeContribution(bvhObj);
 					break;
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1750)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1758)
@@ -1451,7 +1451,6 @@
 		{
 			BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj);
-			BvhIntersectable *bvhObj = mBvHierarchy->GetOrCreateBvhIntersectable(leaf);
 			
-			return vc->AddPvsSample(bvhObj, pdf, contribution);
+			return vc->AddPvsSample(leaf, pdf, contribution);
 		}
 	default:
@@ -1522,22 +1521,22 @@
 												  const Vector3 &point) const
 {
-  
-  if (!obj)
-	return NULL;
-  
-  switch (mObjectSpaceSubdivisionType)
+
+	if (!obj)
+		return NULL;
+
+	switch (mObjectSpaceSubdivisionType)
 	{
 	case HierarchyManager::KD_BASED_OBJ_SUBDIV:
-	  {
-		KdLeaf *leaf = mOspTree->GetLeaf(point, NULL);
-		return mOspTree->GetOrCreateKdIntersectable(leaf);
-	  }
+		{
+			KdLeaf *leaf = mOspTree->GetLeaf(point, NULL);
+			return mOspTree->GetOrCreateKdIntersectable(leaf);
+		}
 	case HierarchyManager::BV_BASED_OBJ_SUBDIV:
-	  {
-		BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj);
-		return mBvHierarchy->GetOrCreateBvhIntersectable(leaf);
-	  }
+		{
+			BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj);
+			return leaf;
+		}
 	default:
-	  return obj;
+		return obj;
 	}
 }
@@ -1546,12 +1545,12 @@
 												  const bool isTermination) const
 {
-  Intersectable *obj = NULL;
+	Intersectable *obj = NULL;
 	Vector3 pt;
 	KdNode *node;
 
 	ray.GetSampleData(isTermination, pt, &obj, &node);
-	
+
 	if (!obj)
-	  return NULL;
+		return NULL;
 
 	switch (mObjectSpaceSubdivisionType)
@@ -1559,5 +1558,5 @@
 	case HierarchyManager::KD_BASED_OBJ_SUBDIV:
 		{
-		  KdLeaf *leaf = mOspTree->GetLeaf(pt, node);
+			KdLeaf *leaf = mOspTree->GetLeaf(pt, node);
 			return mOspTree->GetOrCreateKdIntersectable(leaf);
 		}
@@ -1565,8 +1564,8 @@
 		{
 			BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj);
-			return mBvHierarchy->GetOrCreateBvhIntersectable(leaf);
+			return leaf;
 		}
 	default:
-	  break;
+		break;
 	}
 	return obj;
@@ -1839,8 +1838,12 @@
 		ObjectPvsEntry entry = pit.Next();
 
-		BvhIntersectable *intersect = dynamic_cast<BvhIntersectable *>(entry.mObject);
-
-		BvhLeaf *leaf = intersect->GetItem();
-		BvhNode *activeNode = leaf->GetActiveNode();
+		BvhNode *activeNode;
+		BvhNode *intersect = dynamic_cast<BvhNode *>(entry.mObject);
+
+		// hack for choosing which node to account for
+		if (intersect->IsLeaf())
+			activeNode = dynamic_cast<BvhLeaf *>(intersect)->GetActiveNode();
+		else
+			activeNode = intersect;
 
 		if (!activeNode->Mailed())
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h	(revision 1737)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h	(revision 1758)
@@ -169,19 +169,4 @@
 typedef map<KdNode *, KdIntersectable *> KdIntersectableMap;
 
-class BvhIntersectable: public IntersectableWrapper<BvhLeaf *>
-{
-public:
-	BvhIntersectable(BvhLeaf *item):
-	IntersectableWrapper<BvhLeaf *>(item) {}
-
-	int Type() const
-	{
-		return Intersectable::BVH_INTERSECTABLE;
-	}
-
-	AxisAlignedBox3 GetBox() const;
-
-};
-
 
 class TriangleIntersectable: public IntersectableWrapper<Triangle3>
