Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1843)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h	(revision 1844)
@@ -292,4 +292,5 @@
 	void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
 
+	void CompressObjectSpace();
 	void CreateUniqueObjectIds();
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 1779)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h	(revision 1844)
@@ -1028,4 +1028,8 @@
 					AxisAlignedBox3 *forcedBoundingBox);
 
+	void CompressObjects();
+
+	void CompressObjects(VspLeaf *leaf);
+
 protected:
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1843)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp	(revision 1844)
@@ -2692,3 +2692,8 @@
 
 
-}
+void BvHierarchy::Compress()
+{
+}
+
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1843)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h	(revision 1844)
@@ -627,4 +627,5 @@
 	float GetRenderCostIncrementially(BvhNode *node) const;
 
+	void Compress();
 	void CreateUniqueObjectIds();
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 1842)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 1844)
@@ -212,10 +212,4 @@
 	bool GetSampleContribution(T sample, const float pdf, float &contribution);
 
-	/** Adds sample to PVS. 
-		@contribution contribution of sample (0 or 1)
-		@returns true if sample was not already in PVS.
-	*/
-	//bool AddSample(T sample, const float pdf, float &contribution);
-
 	/** Adds sample to PVS.
 		@returns contribution of sample (0 or 1)
@@ -241,5 +235,5 @@
 		@returns contribution of sample (0 or 1)
 	*/
-	float AddSamples(const vector<PvsEntry<T, S> > &samples);
+	//float AddSamples(const vector<PvsEntry<T, S> > &samples);
 
 	/** Adds sample to PVS.
Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1779)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp	(revision 1844)
@@ -3388,3 +3388,86 @@
 }
 
-}
+
+void VspTree::CompressObjects(VspLeaf *leaf)
+{
+	bool compressed = true;
+
+	Intersectable::NewMail(2);
+
+	while (compressed)
+	{
+		ObjectPvsIterator oit = leaf->GetViewCell()->GetPvs().GetIterator();
+		vector<BvhNode *> parents;
+		ObjectPvs newPvs;
+
+		compressed = false;
+
+		while (oit.HasMoreEntries())
+		{
+			const ObjectPvsEntry &entry = oit.Next();
+			BvhNode *obj = dynamic_cast<BvhNode *>(entry.mObject);
+
+			if (!obj->IsRoot())
+			{
+				BvhNode *parent = obj->GetParent();
+
+				if (!parent->Mailed())
+				{
+					parent->Mail();
+				}
+				else
+				{
+					// sibling was already found => 
+					// this entry can be exchanged by the parent
+					parents.push_back(parent);
+					parent->Mail(1);
+					compressed = true;
+				}
+			}
+		}
+		
+		oit = leaf->GetViewCell()->GetPvs().GetIterator();
+
+		while (oit.HasMoreEntries())
+		{
+			const ObjectPvsEntry &entry = oit.Next();
+			BvhNode *obj = dynamic_cast<BvhNode *>(entry.mObject);
+
+			if (!obj->IsRoot())
+			{
+				BvhNode *parent = obj->GetParent();
+
+				// add only entries that cannot be exchaned with the parent
+				if (parent->Mailed(1))
+				{
+					newPvs.AddSampleDirty(obj, entry.mData.mSumPdf);
+				}
+			}
+		}
+
+		// add parents
+		vector<BvhNode *>::const_iterator bit, bit_end = parents.end();
+		for (bit = parents.begin(); bit != bit_end; ++ bit)
+		{
+			newPvs.AddSampleDirty(*bit, 1);
+		}
+
+		leaf->GetViewCell()->SetPvs(newPvs);
+	}
+}
+
+
+void VspTree::CompressObjects()
+{
+	vector<VspLeaf *> leaves;
+	CollectLeaves(leaves);
+
+	vector<VspLeaf *>::const_iterator lit, lit_end = leaves.end();
+
+	for (lit = leaves.begin(); lit != lit_end; ++ lit)
+	{
+		CompressObjects(*lit);
+	}
+}
+
+}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1843)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1844)
@@ -657,4 +657,5 @@
 }
 
+
 void HierarchyManager::InitialiseObjectSpaceSubdivision(const ObjectContainer &objects)
 {
@@ -2353,4 +2354,9 @@
 
 
+void HierarchyManager::CompressObjectSpace()
+{
+	//mBvHierarchy->Compress();
+	mVspTree->CompressObjects();
+
 void HierarchyManager::CreateUniqueObjectIds()
 {
@@ -2359,4 +2365,3 @@
 
 
-
-}
+}
