Index: GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 1563)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp	(revision 1564)
@@ -374,9 +374,10 @@
 	RayInfoContainer *rays = new RayInfoContainer();
 
-	//-- extract polygons from rays if there are polygon candidates
+	////////////
+	//-- extract polygons from rays if polygon candidate planes are required
+
 	if (mMaxPolyCandidates) 
 	{
 		int numObj = 0;
-
 		Intersectable::NewMail();
 
@@ -398,19 +399,31 @@
 				obj->Mail();
 
-				// transformed mesh instance and mesh instance handle mesh differently
-				if (obj->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE)
+				// handle intersectable
+				switch (obj->Type())
 				{
-					Mesh mesh;
+					case Intersectable::TRANSFORMED_MESH_INSTANCE:
+						{
+							Mesh mesh;
 				
-					TransformedMeshInstance *tmobj = 
-						dynamic_cast<TransformedMeshInstance *>(obj);
+							TransformedMeshInstance *tmobj = 
+								dynamic_cast<TransformedMeshInstance *>(obj);
 				
-					tmobj->GetTransformedMesh(mesh);
-					AddMeshToPolygons(&mesh, polys, tmobj);
-				}
-				else // MeshInstance
-				{
-					MeshInstance *mobj = dynamic_cast<MeshInstance *>(obj);
-					AddMeshToPolygons(mobj->GetMesh(), polys, mobj);
+							tmobj->GetTransformedMesh(mesh);
+							AddMeshToPolygons(&mesh, polys, tmobj);
+						}
+						break;
+					case Intersectable::MESH_INSTANCE:
+						{
+							MeshInstance *mobj = dynamic_cast<MeshInstance *>(obj);
+							AddMeshToPolygons(mobj->GetMesh(), polys, mobj);
+						}
+						break;
+					case Intersectable::TRIANGLE_INTERSECTABLE:
+						{
+							// TODO
+							cout << "here5" << endl;
+						}
+					default:
+						break;
 				}
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp	(revision 1563)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp	(revision 1564)
@@ -702,5 +702,5 @@
 
 	mStat.nodes = 1;
-	mBbox.Initialize(); 	// initialise bsp tree bounding box
+	mBbox.Initialize(); // initialise bsp tree bounding box
 	
 	PolygonContainer *polys = new PolygonContainer();
@@ -843,5 +843,6 @@
 		}
 	}
-	
+	// clear helper structure
+	// note: memory will not be released using clear!
 	facePolyMap.clear();
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1563)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp	(revision 1564)
@@ -489,5 +489,4 @@
 	mViewCellsManager->SetRenderer(mRenderSimulator);
 
-
 	if (mUseGlRenderer || mUseGlDebugger)
 	{
@@ -922,6 +921,6 @@
 	rayBundle.push_back(mainRay);
 
-	const float pertubOrigin = 10.0f;
-	const float pertubDir = 0.0f;
+	const float pertubOrigin = 0.0f;
+	const float pertubDir = 0.2f;
 
 	for (int i = 0; i < number - 1; ++ i)
Index: GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 1563)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 1564)
@@ -47,5 +47,5 @@
 	friend class IntelRayCaster;
 	friend class InternalRayCaster;
-	
+
 public:
 	/** Default constructor initialising e.g., KD tree and BSP tree.
@@ -55,154 +55,151 @@
 	virtual ~Preprocessor();
 
-  /** Load the input scene. 
-      @param filename file to load
-	  @return true on success
-  */
-  virtual bool LoadScene(const string filename);
-  
-  /** Export all preprocessed data in a XML format understandable by the
-      PreprocessingInterface of the GtpVisibilityPreprocessor Module. 
-	  The file can be compressed depending on the environement settings.
-      @return true on successful export
-  */
-  virtual bool ExportPreprocessedData(const string filename);
-  
-  /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
-      is driven by the environment settings, which also sais which of the three types of
-      entities should be used to drive the heuristical construction (only occluders by default)
-  */
-  virtual bool BuildKdTree();
-
-  /** Compute visibility method. This method has to be reimplemented by the actual
-      Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
-      GlobalSamplingpreprocessor)
-    */
-  virtual bool ComputeVisibility() = 0;
-
-  /** Post Process the computed visibility. By default applys the visibility filter
-	  (if specified in the environment and export the preprocessed data */
-  virtual bool PostProcessVisibility();
-
-  /** View cells are either loaded or prepared for generation, according to the chosen environment
-      object. Important evironment options are, e.g, the view cell type.
-      Should be done after scene loading (i.e., some options are based on scene type).
-  */
-  bool PrepareViewCells();
-
-  /** Construct viewcells from the scratch 
-  */
-  bool ConstructViewCells();
-
-  /** Returns the specified sample strategy, NULL if no valid strategy.
-  */
-  SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const;
-
-  /** Export preprocessor data.
-  */
-  bool Export(
+	/** Load the input scene. 
+	@param filename file to load
+	@return true on success
+	*/
+	virtual bool LoadScene(const string filename);
+
+	/** Export all preprocessed data in a XML format understandable by the
+	PreprocessingInterface of the GtpVisibilityPreprocessor Module. 
+	The file can be compressed depending on the environement settings.
+	@return true on successful export
+	*/
+	virtual bool ExportPreprocessedData(const string filename);
+
+	/** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
+	is driven by the environment settings, which also sais which of the three types of
+	entities should be used to drive the heuristical construction (only occluders by default)
+	*/
+	virtual bool BuildKdTree();
+
+	/** Compute visibility method. This method has to be reimplemented by the actual
+	Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
+	GlobalSamplingpreprocessor)
+	*/
+	virtual bool ComputeVisibility() = 0;
+
+	/** Post Process the computed visibility. By default applys the visibility filter
+	(if specified in the environment and export the preprocessed data */
+	virtual bool PostProcessVisibility();
+
+	/** View cells are either loaded or prepared for generation, according to the chosen environment
+	object. Important evironment options are, e.g, the view cell type.
+	Should be done after scene loading (i.e., some options are based on scene type).
+	*/
+	bool PrepareViewCells();
+
+	/** Construct viewcells from the scratch 
+	*/
+	bool ConstructViewCells();
+
+	/** Returns the specified sample strategy, NULL if no valid strategy.
+	*/
+	SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const;
+
+	/** Export preprocessor data.
+	*/
+	bool Export(
 		const string filename, 
 		const bool scene, 
 		const bool kdtree);  
-  
-  virtual void KdTreeStatistics(ostream &s);
-  virtual void BspTreeStatistics(ostream &s);
-
-  /** Loads samples from file.
-	  @param samples returns the stored sample rays
-	  @param objects needed to associate the objects ids
-	  @returns true if samples were loaded successfully
-  */
-  bool LoadSamples(VssRayContainer &samples,
-				   ObjectContainer &objects) const;
-
-  /** Exports samples to file.
-	  @returns true if samples were written successfully
-  */
-  bool ExportSamples(const VssRayContainer &samples) const;
-
-  bool LoadKdTree(const string filename);
-  bool ExportKdTree(const string filename);
-
-  virtual bool
-  GenerateRays(
-			   const int number,
-			   const int raysType,
-			   SimpleRayContainer &rays
-			   );
-  
-  bool GenerateRayBundle(
-	  SimpleRayContainer &rayBundle,
-	  const SimpleRay &mainRay,
-	  const int number,
-	  const int shuffleType) const;
-
-  virtual void CastRays(SimpleRayContainer &rays,
-						VssRayContainer &vssRays,
-						const bool castDoubleRays,
-						const bool pruneInvalidRays = true);
-
-  /** Returns a view cells manager of the given name.
-  */
-  ViewCellsManager *CreateViewCellsManager(const char *name);
-  /** Returns a hierarchy manager of the given name.
-  */
-  HierarchyManager *CreateHierarchyManager(const char *name);
-   
-  GlRendererBuffer *GetRenderer();
-
-  bool InitRayCast(const string externKdTree, const string internKdTree);
-
-   
-  ////////////////////////////////////////////////
-
-  /// scene graph loaded from file
-  SceneGraph *mSceneGraph;
-
-  /// raw array of objects
-  ObjectContainer mObjects;
-  
-  /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
-  KdTree *mKdTree;
-  /// View space partition bsp tree
-  VspBspTree *mVspBspTree;
-  /// Hierarchy manager handling view space and object space partition
-  HierarchyManager *mHierarchyManager;
-  /// BSP tree representing the viewcells
-  BspTree *mBspTree;
-  
-  /// list of all loaded occluders
-  ObjectContainer mOccluders;
-  /// list of all loaded occludees
-  ObjectContainer mOccludees;
-   
-  
-  ViewCellsManager *mViewCellsManager;
-
-  /// greedy optimized hierarchy for both objects and view cells
-  VspOspTree *mVspOspTree;
-
-  bool mUseGlRenderer;
-  bool mUseGlDebugger;
-
-  bool mLoadViewCells;
-  
-  bool mDetectEmptyViewSpace;
-
-  bool mQuitOnFinish;
-  bool mLoadMeshes;
-  bool mComputeVisibility;
-
-  bool mExportVisibility;
-  string mVisibilityFileName;
-  
-  bool mApplyVisibilityFilter;
-  bool mApplyVisibilitySpatialFilter;
-
-  float mVisibilityFilterWidth;
- 
-  //int GetRayCastMethod() { return mRayCastMethod; }
-  //void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; }
-
-  int mPass;
+
+	virtual void KdTreeStatistics(ostream &s);
+	virtual void BspTreeStatistics(ostream &s);
+
+	/** Loads samples from file.
+	@param samples returns the stored sample rays
+	@param objects needed to associate the objects ids
+	@returns true if samples were loaded successfully
+	*/
+	bool LoadSamples(VssRayContainer &samples,
+		ObjectContainer &objects) const;
+
+	/** Exports samples to file.
+	@returns true if samples were written successfully
+	*/
+	bool ExportSamples(const VssRayContainer &samples) const;
+
+	bool LoadKdTree(const string filename);
+	bool ExportKdTree(const string filename);
+
+	virtual bool
+		GenerateRays(
+		const int number,
+		const int raysType,
+		SimpleRayContainer &rays
+		);
+
+	bool GenerateRayBundle(
+		SimpleRayContainer &rayBundle,
+		const SimpleRay &mainRay,
+		const int number,
+		const int shuffleType) const;
+
+	virtual void CastRays(SimpleRayContainer &rays,
+		VssRayContainer &vssRays,
+		const bool castDoubleRays,
+		const bool pruneInvalidRays = true);
+
+	/** Returns a view cells manager of the given name.
+	*/
+	ViewCellsManager *CreateViewCellsManager(const char *name);
+	/** Returns a hierarchy manager of the given name.
+	*/
+	HierarchyManager *CreateHierarchyManager(const char *name);
+
+	GlRendererBuffer *GetRenderer();
+
+	bool InitRayCast(const string externKdTree, const string internKdTree);
+
+
+	////////////////////////////////////////////////
+
+	/// scene graph loaded from file
+	SceneGraph *mSceneGraph;
+
+	/// raw array of objects
+	ObjectContainer mObjects;
+
+	/// kD-tree organizing the scene graph (occluders + occludees) + viewcells
+	KdTree *mKdTree;
+	/// View space partition bsp tree
+	VspBspTree *mVspBspTree;
+	/// Hierarchy manager handling view space and object space partition
+	HierarchyManager *mHierarchyManager;
+	/// BSP tree representing the viewcells
+	BspTree *mBspTree;
+
+	/// list of all loaded occluders
+	ObjectContainer mOccluders;
+	/// list of all loaded occludees
+	ObjectContainer mOccludees;
+
+
+	ViewCellsManager *mViewCellsManager;
+
+	/// greedy optimized hierarchy for both objects and view cells
+	VspOspTree *mVspOspTree;
+
+	bool mUseGlRenderer;
+	bool mUseGlDebugger;
+
+	bool mLoadViewCells;
+
+	bool mDetectEmptyViewSpace;
+
+	bool mQuitOnFinish;
+	bool mLoadMeshes;
+	bool mComputeVisibility;
+
+	bool mExportVisibility;
+	string mVisibilityFileName;
+
+	bool mApplyVisibilityFilter;
+	bool mApplyVisibilitySpatialFilter;
+
+	float mVisibilityFilterWidth;
+
+	int mPass;
 
 protected:
@@ -215,18 +212,18 @@
 	/////////////////////////
 
-  RayCaster *mRayCaster;
-  /// samples used for construction of the BSP view cells tree.
-  int mBspConstructionSamples;
-  /// samples used for construction of the VSP OSP tree.
-  int mVspOspConstructionSamples;
-  /** Simulates rendering of the scene.
-  */
-  RenderSimulator *mRenderSimulator;
-  
-  vector<FaceParentInfo> mFaceParents;
-
-  GlRendererBuffer *renderer;
-
-  
+	RayCaster *mRayCaster;
+	/// samples used for construction of the BSP view cells tree.
+	int mBspConstructionSamples;
+	/// samples used for construction of the VSP OSP tree.
+	int mVspOspConstructionSamples;
+	/** Simulates rendering of the scene.
+	*/
+	RenderSimulator *mRenderSimulator;
+
+	vector<FaceParentInfo> mFaceParents;
+
+	GlRendererBuffer *renderer;
+
+
 };
 
Index: GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1563)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp	(revision 1564)
@@ -107,5 +107,5 @@
 
 	Environment::GetSingleton()->GetBoolValue(
-		"Hierarchy.Construction.useMultiLevelConstruction", mUseMultiLevelConstruction);
+		"Hierarchy.Construction.useMultiLevel", mUseMultiLevelConstruction);
 
 	 mUseMultiLevelConstruction;
