Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h	(revision 3120)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h	(revision 3243)
@@ -112,7 +112,4 @@
 	static bool GetUseLODs() { return sUseLODs; }
 
-
-	int mId;
-
 protected:
 
@@ -143,4 +140,6 @@
 	/// the center of gravity of this entity
 	Vector3 mCenter;
+	
+	int mId;
 
 	static bool sUseLODs;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.cpp	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.cpp	(revision 3243)
@@ -2,35 +2,45 @@
 #include "Timer/PerfTimer.h"
 #include <stack>
+#include <string>
 
 using namespace std;
 
 
+// MAGIC of all bin exports
+#ifndef MAGIC 
+#define MAGIC 0x827923
+#endif
+
+#define VIEWCELLS_VERSION 1.0f
+
 namespace CHCDemoEngine
 {
 
+
 ViewCell *ViewCellsTree::GetViewCell(const Vector3 &point) const
 {
-	ViewCellsTreeNode *node = root;
+	ViewCellsTreeNode *node = mRoot;
 
 	while (!node->IsLeaf()) 
 	{
-		if (point[node->axis] < node->position)
-			node = node->back;
+		if (point[node->mAxis] < node->mPosition)
+			node = node->mBack;
 		else
-			node = node->front;
+			node = node->mFront;
 	}
 
-	return node->viewCell;
+	return node->mViewCell;
 }
 
 
-bool ViewCellsTree::LoadFromFile(const string &filename)
+bool ViewCellsTree::LoadFromFile(const std::string &filename)
 {
-	cout << ("Info: Loading view cells from file '" + filename + "'" );
+	cout << "Info: Loading view cells from file '" + filename + "'";
 
 	FILE *fr = fopen(filename.c_str(), "rb");
 
-	if (fr == NULL) {
-		Message("Error: Cannot open file for reading");
+	if (!fr) 
+	{
+		cerr << "Error: Cannot open file for reading" << endl;
 		return false;
 	}
@@ -38,5 +48,5 @@
 	bool result = _LoadFromFile(fr);
 
-	Debug << "Info: done. " << endl;
+	cout << "Info: done. " << endl;
 	fclose(fr);
 
@@ -50,30 +60,36 @@
 	fread(buffer, sizeof(int), 3, fr);
 
-	if (buffer[0] != MAGIC) {
-		Message( "Error: Wrong file type");
+	if (buffer[0] != MAGIC) 
+	{
+		cerr << "Error: Wrong file type" << endl;
 		return false;
 	}
 
-	if (buffer[1] != (int)(1000*VIEWCELLS_VERSION)) {
-		Message( "Error: Wrong viewcells version" );
+	if (buffer[1] != (int)(1000 * VIEWCELLS_VERSION)) 
+	{
+		cerr << "Error: Wrong viewcells version" << endl;
 		return false;
 	}
 
 	// get the bounding box
-	fread(&box, sizeof(AxisAlignedBox3), 1, fr);
+	fread(&mBox, sizeof(AxisAlignedBox3), 1, fr);
 
 	stack<ViewCellsTreeNode **> nodeStack;
 
-	nodeStack.push(&root);
+	nodeStack.push(&mRoot);
 
-	while(!nodeStack.empty()) {
+	while (!nodeStack.empty()) 
+	{
 		ViewCellsTreeNode *&node = *nodeStack.top();
 		nodeStack.pop();
-		node = new ViewCellsTreeNode;
-		fread(&node->axis, sizeof(int), 1, fr);
-		if (!node->IsLeaf()) {
-			fread(&node->position, sizeof(float), 1, fr);
-			nodeStack.push(&node->front);
-			nodeStack.push(&node->back);
+		node = new ViewCellsTreeNode();
+
+		fread(&node->mAxis, sizeof(int), 1, fr);
+
+		if (!node->IsLeaf())
+		{
+			fread(&node->mPosition, sizeof(float), 1, fr);
+			nodeStack.push(&node->mFront);
+			nodeStack.push(&node->mBack);
 		}
 	}
@@ -83,33 +99,3 @@
 
 
-void ViewCellsTree::_ExportToFile(FILE *file)
-{
-	int buffer[256];
-	int i=0;
-	buffer[i++] = MAGIC;
-	buffer[i++] = VIEWCELLS_VERSION*1000;
-
-	fwrite(buffer, sizeof(int), i, file);
-
-	fwrite(&mMaxDepth, sizeof(float), 1, file);
-
-	fwrite(&box, sizeof(AxisAlignedBox3), 1, file);
-
-	stack<ViewCellsTreeNode *> nodeStack;
-
-	nodeStack.push(root);
-
-	while (!nodeStack.empty()) {
-		ViewCellsTreeNode *node = nodeStack.top();
-		nodeStack.pop();
-
-		fwrite(&node->axis, sizeof(int), 1, file);
-		if (!node->IsLeaf()) {
-			fwrite(&node->position, sizeof(float), 1, file);
-			nodeStack.push(node->front);
-			nodeStack.push(node->back);
-		}
-	}
 }
-
-}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h	(revision 3243)
@@ -2,5 +2,7 @@
 #define __PVS_H
 
-	
+#include "common.h"
+
+
 namespace CHCDemoEngine
 {
@@ -14,139 +16,24 @@
 public:
 
-	Pvs(): mEntries() {
+	Pvs() {};
 
-		entries.set_deleted_key(-1);
-		entries.set_empty_key(-2);
+	void Clear() { mEntries.clear(); }
 
-	};
+	bool Empty() const { return mEntries.empty(); }
 
-	int GetSize() const {
-		return (int)entries.size();
-	}
+	SceneEntity *GetEntry(int i) const { return mEntries[i]; }
+
+	int Size() { return (int)mEntries.size(); }
+
+	void AddEntry(SceneEntity *ent) { mEntries.push_back(ent); }
 
 
-	bool Empty() const {
-		return entries.empty();
-	}
+protected:
 
-	/** Adds object to PVS.
-	@returns contribution of sample (0 or 1)
-	*/
-	bool Insert(const int id, const float time = 0.0f) {
-
-		pair<PVS_ITERATOR, bool> result = entries.insert(pair<int, float>(id,time));
-
-		return result.second;
-	}
-
-	bool Find(const int id) {
-		PVS_ITERATOR it;
-		return Find(id, it);
-	}
-
-	bool Find(const int id, PVS_ITERATOR &it) {
-		it = entries.find(id);
-
-		// already in map
-		return (it != entries.end());
-	}
-
-	void Clear() {
-		entries.clear();
-	}
-
-	static void Merge(Pvs &mergedPvs,
-		const Pvs &a, 
-		const Pvs &b)
-	{
-		mergedPvs.entries.insert(a.entries.begin(), a.entries.end());
-		mergedPvs.entries.insert(b.entries.begin(), b.entries.end());
-	}
-
-	// just an estimate - could not find proper reference how to
-	// calculate memory occupied by hash_map and hash_set!
-	int GetMemoryUsage() const {
-
-		return sizeof(Pvs) + sizeof(HASH_SET::value_type)*entries.bucket_count();
-	}
-
-protected:
 	/// hash table of PVS entries
-	HASH_SET entries; 
-
+	SceneEntityContainer mEntries; 
 };
 
-
-/** Iterator over a hash pvs.
-*/
-class PvsIterator
-{
-protected:
-
-	CONST_PVS_ITERATOR itCurrent;
-	CONST_PVS_ITERATOR itEnd;
-
-public:
-
-	PvsIterator() {}
-
-	PvsIterator(Pvs &pvs):
-	itCurrent(pvs.entries.begin()), itEnd(pvs.entries.end())
-	{
-	}
-
-	bool HasMoreEntries() const 
-	{
-		return (itCurrent != itEnd);
-	}
-
-	void Next() {
-		++itCurrent;
-	}
-
-	int Current() const {
-
-		return (*itCurrent).first;
-
-	}
-	float CurrentTime() const {
-
-		return (*itCurrent).second;
-
-	}
-
-};
-
-#if 0
-// iterator of the PVS at the given time stamp
-// onnly works properly in PVS_TIME_STAMPS is defined
-// otherwise behaves the same as PvsIterator
-
-class PvsTimeIterator : public PvsIterator
-{
-protected:
-	float time;
-public:
-
-	PvsTimeIterator(Pvs &pvs, const float _time):
-	  PvsIterator(pvs), time(_time)
-	  {
-		  // find the first entry satisfying the time constraint
-		  for (;HasMoreEntries(); ++itCurrent)
-			  if ((*itCurrent).second <= time)
-				  break;
-	  }
-
-	  void Next() {
-		  for (++itCurrent; HasMoreEntries(); ++itCurrent)
-			  if ((*itCurrent).second <= time)
-				  break;
-	  }
-
-};
-
-#endif
 }
 
 #endif
-
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.h	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.h	(revision 3243)
@@ -2,9 +2,16 @@
 #define _VISIBILITYSOLUTIONLOADER_H
 
+#include "common.h"
+
+
+namespace CHCDemoEngine
+{
 
 class ViewCellsTree;
-	
-namespace CHCDemoEngine
-{
+struct ViewCell;
+class Bvh;
+
+typedef std::vector<ViewCell *> ViewCellsContainer;
+
 
 /** Loads a preprocessed visibility solution.
@@ -14,14 +21,25 @@
 public:
 
-	VisibilitySolutionLoader();
+	VisibilitySolutionLoader(): mNumNodes(0) {};
 
-	~VisibilitySolutionLoader();
+	ViewCellsTree *Load(const std::string &filename, Bvh *bvh);
 
-	bool Load(const std::string &filename
-		      ViewCellsTree *viewCells);
 
 protected:
+	/** Creates list of bvh nodes where the index
+		is equivalent to the id of this node in the bvh.
+	*/
+	bool CreateIdSortedList(Bvh *bvh, BvhNodeContainer &nodes);
+
+	bool LoadPvs(FILE *fw, Bvh *bvh);
+
+	void AllocateLeafViewCells(ViewCellsTree *viewCellsTree);
+
+
+	///////////////
 
 	int mNumNodes;
+
+	ViewCellsContainer mViewCells;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/AxisAlignedBox3.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/AxisAlignedBox3.h	(revision 3202)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/AxisAlignedBox3.h	(revision 3243)
@@ -104,8 +104,8 @@
 	/** Sets the minimum for one dimension.
 	*/
-	void SetMin(int axis, const float value);
+	void SetMin(int axis, float value);
 	/** Sets the maximum for one dimension.
 	*/
-	void SetMax(int axis, const float value);
+	void SetMax(int axis, float value);
 	/** Decrease box by given splitting plane
 	*/
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp	(revision 3243)
@@ -1,3 +1,6 @@
 #include "VisibilitySolutionLoader.h"
+#include "ViewCellsTree.h"
+#include "Bvh.h"
+#include <stack>
 
 
@@ -8,9 +11,188 @@
 {
 
-bool VisibilitySolutionLoader::Load(const std::string &filename
-									ViewCellsTree *viewCells)
+
+typedef vector<ViewCell *> ViewCellsContainer;
+
+
+ViewCellsTree *VisibilitySolutionLoader::Load(const std::string &filename,
+											  Bvh *bvh)
 {
+	FILE *fr = fopen(filename.c_str(), "rb");
+  
+	cout << "Info: Loading visibility solution from file '" + filename + "'" << endl;
+  
+	if (fr == NULL) 
+	{
+		cerr << "Error: Cannot open file for reading" << endl;
+		return NULL;
+	}
+
+	float totalSamples;
+	float totalTime;
+
+	fread(&totalSamples, sizeof(float), 1, fr);
+	fread(&totalTime, sizeof(float), 1, fr);
+
+	ViewCellsTree *viewCellsTree = new ViewCellsTree();
+
+	bool ok = viewCellsTree->_LoadFromFile(fr);
+  
+	if (ok) 
+	{
+		// skip bvh loading
+		int buffer[6]; 
+		fread(buffer, sizeof(int), 6, fr);
+
+		const size_t numNodes = buffer[5];
+		
+		for (int i = 0; i < numNodes; ++ i)
+			fread(buffer, sizeof(int), 4, fr);
+
+		AllocateLeafViewCells(viewCellsTree);
+		
+		ok = LoadPvs(fr, bvh);
+	}
+
+	fclose(fr);
+
+	if (ok) 
+		cerr << "Info: visibility solution loaded" << endl;
+	else
+		cerr << "Info: loading visibility solution failed." << endl;
+
+	return viewCellsTree;
+}
+
+
+bool VisibilitySolutionLoader::CreateIdSortedList(Bvh *bvh, BvhNodeContainer &nodes)
+{
+	std::stack<BvhNode *> tStack;
+	tStack.push(bvh->GetRoot());
+	
+	while (!tStack.empty())
+	{
+		BvhNode *node = tStack.top();
+		tStack.pop();
+
+		nodes.push_back(node);
+
+		if (!node->IsLeaf())
+		{
+			BvhInterior *interior = static_cast<BvhInterior *>(node);
+
+			BvhNode *front = interior->GetFront();
+			BvhNode *back = interior->GetBack();
+
+			tStack.push(front);
+			tStack.push(back);
+		}
+	}
+
 	return true;
 }
 
+
+bool VisibilitySolutionLoader::LoadPvs(FILE *fw, Bvh *bvh)
+{
+	int number, entries;
+
+	fread(&number, sizeof(int), 1, fw);
+
+	if (number == 0) 
+	{
+		cerr << "Info: Warning empty PVSs in visibility solution" << endl;
+		return true;
+	}
+
+	if (number != mViewCells.size()) 
+	{
+		cerr << "Info: Number of view cells does not match when loading PVSs!" << endl;
+		return false;
+	}
+
+	BvhNodeContainer nodes;
+	CreateIdSortedList(bvh, nodes);
+
+	for (int i = 0; i < number; ++ i) 
+	{
+		fread(&entries, sizeof(int), 1, fw);
+
+		for (int j=0; j < entries; ++ j) 
+		{
+			int objectId;
+			float time;
+		
+			fread(&objectId, sizeof(int), 1, fw);
+			fread(&time, sizeof(float), 1, fw);
+
+			BvhNode *node = nodes[objectId];
+
+			int geometrySize;
+			SceneEntity **entities;
+			entities = bvh->GetGeometry(node, geometrySize);
+
+			for (int k = 0; k < geometrySize; ++ k)
+			{
+				mViewCells[i]->mPvs.AddEntry(entities[k]);
+			}
+		}
+	}
+
+	return true;
 }
+
+
+void VisibilitySolutionLoader::AllocateLeafViewCells(ViewCellsTree *viewCellsTree)
+{
+	stack< pair<ViewCellsTreeNode *, AxisAlignedBox3> > nodeStack;
+
+	nodeStack.push(pair<ViewCellsTreeNode *, AxisAlignedBox3>
+		           (viewCellsTree->mRoot, viewCellsTree->mBox));
+
+	int id = 0;
+
+	mViewCells.clear();
+	
+	while (!nodeStack.empty()) 
+	{
+		ViewCellsTreeNode *node = nodeStack.top().first;
+		
+		if (node->IsLeaf()) 
+		{
+			if (node->mViewCell == NULL) 
+			{
+				node->mViewCell = new ViewCell();
+				node->mViewCell->SetId(id ++);
+				node->mViewCell->SetBox(nodeStack.top().second);
+			}
+
+			mViewCells.push_back(node->mViewCell);
+
+			nodeStack.pop();
+		} 
+		else 
+		{
+			AxisAlignedBox3 box = nodeStack.top().second;
+			nodeStack.pop();
+
+			AxisAlignedBox3 newBox = box;
+			newBox.SetMin(node->mAxis, node->mPosition);
+
+			nodeStack.push(
+				pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mFront, newBox)
+				);
+
+			newBox = box;
+			newBox.SetMax(node->mAxis, node->mPosition);
+
+			nodeStack.push(
+				pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mBack, newBox)
+				);
+		}
+	}
+
+	cout << "#of viewcells = " << id << endl;
+}
+
+
+}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 3123)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h	(revision 3243)
@@ -154,10 +154,10 @@
 	*/
 	inline int CountPrimitives() const;
-	/** This is an imporantent function once you have one or more
-		view point changes within a frame (e.g., camera view and shadow view for
+	/** This function is important in case you have more than one
+		view position within a frame (e.g., camera view and shadow view for
 		shadow mapping), because each camera needs its own state in
 		order to not break temporal coherency.
 	*/
-	inline static void SetCurrentState(int _state) { sCurrentState = _state; }
+	inline static void SetCurrentState(int _state);
 
 
@@ -180,6 +180,11 @@
 	/// stores the visibility related info 
 	VisibilityInfo mVisibility[NUM_STATES];
-	
-	// members used to speed up view frustum culling
+	/// when the node was last rendered
+	int mLastRenderedFrame[NUM_STATES];
+
+
+	///////////////
+	//-- members that help to speed up view frustum culling
+
 	/// masks out planes of the frustum that do not have to be tested against
 	int mPlaneMask[NUM_STATES];
@@ -188,6 +193,5 @@
 	*/
 	int mPreferredPlane[NUM_STATES];
-	/// when the node was last rendered
-	int mLastRenderedFrame[NUM_STATES];
+
 
 	////////////////////
@@ -406,4 +410,9 @@
 
 
+void BvhNode::SetCurrentState(int _state) 
+{
+	sCurrentState = _state; 
+}
+
 
 /** Internal node of the bv hierarchy.
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 3243)
@@ -58,4 +58,6 @@
 #include "WalkThroughRecorder.h"
 #include "StatsWriter.h"
+#include "VisibilitySolutionLoader.h"
+#include "ViewCellsTree.h"
 
 
@@ -127,4 +129,5 @@
 
 string filename("city");
+string visibilitySolution("");
 
 
@@ -430,4 +433,5 @@
 		env.GetStringParam(string("statsFilename"), statsFilename);
 		env.GetStringParam(string("filename"), filename);
+		env.GetStringParam(string("visibilitySolution"), visibilitySolution);
 
 		//env.GetStringParam(string("modelPath"), model_path);
@@ -461,4 +465,6 @@
 		cout << "stats filename: " << statsFilename << endl;
 		cout << "filename: " << filename << endl;
+		cout << "visibilitySolution: " << visibilitySolution << endl;
+		
 
 		//cout << "model path: " << model_path << endl;
@@ -604,4 +610,15 @@
 	/// set the depth of the bvh depending on the triangles per leaf node
 	bvh->SetVirtualLeaves(trianglesPerVirtualLeaf);
+
+	///////////
+	//-- load the visibility solution
+
+	const string vis_filename = 
+		string(model_path + visibilitySolution + ".vis");
+
+	VisibilitySolutionLoader visLoader;
+
+	ViewCellsTree *viewCellsTree = visLoader.Load(vis_filename, bvh);
+
 
 	// set far plane based on scene extent
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.h	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.h	(revision 3243)
@@ -5,5 +5,5 @@
 #include "Pvs.h"
 #include "AxisAlignedBox3.h"
-
+#include "common.h"
 
 	
@@ -19,4 +19,14 @@
 	ViewCell(): mPvs() {}
 
+	int GetId() const { return mId; }
+
+	void SetId(int id) { mId = id; }
+
+	void SetBox(const AxisAlignedBox3 &box) { mBox = box; }
+
+
+	// the pvs associated with the viewcell
+	Pvs mPvs;
+
 protected:
 
@@ -25,7 +35,4 @@
 	// bounding box of the viewcell
 	AxisAlignedBox3 mBox;
-	// the pvs associated with the viewcell
-	Pvs mPvs;
-
 };
 
@@ -33,27 +40,24 @@
 struct ViewCellsTreeNode
 {
-	union 
-	{
-		// split position - 4B
-		float position;
-		// the viewcell associated with this node (NULL for non terminal nodes) - 4B
-		ViewCell *viewCell; 
-	};
-
-
 	ViewCellsTreeNode(): mAxis(-1), mViewCell(NULL) {}
 
-	bool IsLeaf() { return mAxis == -1; }
-
-	bool IsVirtualLeaf() { return mViewCell != NULL; }
+	bool IsLeaf() { return mViewCell != NULL; }
 
 
 	///////////////////////
 
-	// children of the node - 8B
-	ViewCellsTreeNode *mBack, *mFront;
+	union 
+	{
+		// split position - 4B
+		float mPosition;
+		// the viewcell associated with this node (NULL for non terminal nodes)
+		ViewCell *mViewCell; 
+	};
 
-	// kd tree split params
-	// split axis - 4B
+	/// children of the node
+	ViewCellsTreeNode *mBack;
+	ViewCellsTreeNode *mFront;
+
+	/// split mAxis 
 	int mAxis;
 };
@@ -62,4 +66,6 @@
 class ViewCellsTree
 {
+	friend class VisibilitySolutionLoader;
+
 public:
 	
@@ -77,5 +83,5 @@
 	ViewCell *GetViewCell(const Vector3 &point) const;
 
-	bool LoadFromFile(const string &filename);
+	bool LoadFromFile(const std::string &filename);
 
 
@@ -87,5 +93,5 @@
 	////////////////////////
 
-	float mMaxDepth;
+	int mMaxDepth;
 	AxisAlignedBox3 mBox;
 	ViewCellsTreeNode *mRoot;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3243)
@@ -651,8 +651,4 @@
 				</File>
 				<File
-					RelativePath=".\src\Pvs.cpp"
-					>
-				</File>
-				<File
 					RelativePath=".\src\RenderQueue.cpp"
 					>
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env	(revision 3243)
@@ -16,4 +16,5 @@
 statsFilename=mystats.log
 
+visibilitySolution=vienna_full-8x3-refu
 
 ############
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h	(revision 3243)
@@ -144,4 +144,5 @@
 
 
+
 	//////////////////////////////////
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp	(revision 3242)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp	(revision 3243)
@@ -5,4 +5,5 @@
 #include <iostream>
 #include <queue>
+#include <stack>
 
 
@@ -416,7 +417,6 @@
 	{
 		// no face normals? => create normals
-		const CHCDemoEngine::Triangle3 tri(vertices[i + 0],
-			                               vertices[i + 1],
-										   vertices[i + 2]);
+		const CHCDemoEngine::Triangle3 
+			tri(vertices[i], vertices[i + 1], vertices[i + 2]);
 
 		const CHCDemoEngine::Vector3 n = tri.GetNormal();
@@ -498,8 +498,6 @@
 	ogzstream ofile(filename.c_str());
 
-	if (!ofile.is_open())
-		return false;
-	
-
+	if (!ofile.is_open()) return false;
+	
 	int textureCount = 0;
 	ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int));
@@ -541,6 +539,6 @@
 		ofile.write(reinterpret_cast<char *>(&dist), sizeof(float));
 
-		int shapesPerEnt = 1;
-		ofile.write(reinterpret_cast<char *>(&shapesPerEnt), sizeof(int));
+		int shapesPerEntity = 1;
+		ofile.write(reinterpret_cast<char *>(&shapesPerEntity), sizeof(int));
 
 		int shapeId = i;
@@ -765,5 +763,5 @@
 	bool ok = ReadDummyTree(fr);
 
-	// read bvh to optain objects (= the leaves of the bvh)
+	// read bvh to determine objects (= the leaves of the bvh)
 	if (ok) ok = ReadBvh(fr);
 
