Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2569)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2570)
@@ -670,4 +670,7 @@
 	
 
+	void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj);
+
+
 	///////////////////////
 	//-- helper functions for view cell visualization
Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2569)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2570)
@@ -1180,5 +1180,5 @@
 }
 
-
+#if 0
 float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc)
 {
@@ -1221,5 +1221,24 @@
 	return renderCost;
 }
-
+#else
+
+float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc)
+{
+	float renderCost = 0;
+
+	if (mShowDistanceWeightedPvs)
+	{
+		return vc->GetPvs().mStats.mDistanceWeightedPvs;
+	}
+	else if (mShowDistanceWeightedTriangles)
+	{
+		return vc->GetPvs().mStats.mDistanceWeightedTriangles;
+	}
+	else //if (mShowWeightedTriangles)
+	{
+		return vc->GetPvs().mStats.mWeightedTriangles;
+	}
+}
+#endif
 
 void
@@ -1374,5 +1393,5 @@
 			else if (mShowWeightedCost)
 			{
-				const float rcCost = mTransferFunction * vc->GetTrianglesInPvs();
+				const float rcCost = mTransferFunction * ComputeRenderCost(vc);
 				importance = rcCost / maxRcCost;
 			}
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2569)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2570)
@@ -2101,5 +2101,5 @@
 		if (!ViewCellsConstructed()) 
 		{
-			// view cells not yet constructed
+			// view cells not constructed yet =>
 			// just take the lenghts of the rays as contributions
 			if ((*it)->mTerminationObject)
@@ -2669,4 +2669,36 @@
 
 
+void ViewCellsManager::UpdateStatsForViewCell(ViewCell *vc, Intersectable *obj)
+{
+		KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj);
+
+        const AxisAlignedBox3 box = kdObj->GetBox();
+		const float dist = SqrDistance(vc->GetBox().Center(), box.Center());
+
+		float f;
+
+		const float radius = mViewSpaceBox.Radius();
+		const float fullRadius = mViewSpaceBox.Radius();
+
+		const float minVal = 0.1f;
+		const float maxVal = 1.0f;
+
+		if (dist <= radius) 
+			f = maxVal;
+		else if (dist >= fullRadius)
+			f = minVal;
+		else // linear blending
+		{
+			f = minVal * (dist - radius) + maxVal * (fullRadius - radius - dist);
+		}
+
+		const int numTriangles = kdObj->ComputeNumTriangles();
+
+		vc->GetPvs().mStats.mDistanceWeightedTriangles += f * numTriangles; 
+		vc->GetPvs().mStats.mDistanceWeightedPvs += f;
+		vc->GetPvs().mStats.mWeightedTriangles += numTriangles;
+}
+
+
 void ViewCellsManager::ComputeViewCellContribution(ViewCell *viewCell,
 												   VssRay &ray, 
@@ -2692,4 +2724,8 @@
 		hasAbsContribution = viewCell->GetPvs().AddSampleDirtyCheck(obj, ray.mPdf);
 		//hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf);
+#if 1
+		UpdateStatsForViewCell(viewCell, obj);
+#endif
+
 	}
 	else 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 2548)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h	(revision 2570)
@@ -39,4 +39,15 @@
 	typename vector<PvsEntry<T, S> >::const_iterator mItCurrent;
 	typename vector<PvsEntry<T, S> >::const_iterator mItEnd;
+};
+
+
+struct VerbosePvsStats
+{
+	VerbosePvsStats(): mDistanceWeightedTriangles(0), mDistanceWeightedPvs(0), mWeightedTriangles(0)
+	{}
+
+	float mDistanceWeightedTriangles;
+	float mDistanceWeightedPvs;
+	float mWeightedTriangles;
 };
 
@@ -205,4 +216,6 @@
 
 	typename PvsIterator<T, S> GetIterator() const;
+
+	VerbosePvsStats mStats;
 
 protected:
@@ -236,9 +249,9 @@
 
 template <typename T, typename S>
-VerbosePvs<T, S>::VerbosePvs(const vector<PvsEntry<T, S> > &samples)
+VerbosePvs<T, S>::VerbosePvs(const vector<PvsEntry<T, S> > &samples): 
+mLastSorted(0)
 {
 	mEntries.reserve(samples.size());
 	mEntries = samples;
-	mLastSorted = 0;
 	mSamples = samples.size();
 }
Index: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp	(revision 2569)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp	(revision 2570)
@@ -115,6 +115,5 @@
 
 
-int TriangleIntersectable::GetRandomEdgePoint(Vector3 &point,
-											  Vector3 &normal)
+int TriangleIntersectable::GetRandomEdgePoint(Vector3 &point, Vector3 &normal)
 {
 	const int edge = Random(3);
@@ -137,6 +136,9 @@
 }
 
+
 int KdIntersectable::ComputeNumTriangles()
 {
+	Intersectable::NewMail();
+
 	std::stack<KdNode *> tStack;
 	tStack.push(mItem);
