Index: /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h	(revision 2076)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h	(revision 2105)
@@ -59,4 +59,11 @@
 							const bool pruneInvalidRays = true);
 
+  
+  void
+  CastSimpleForwardRays(
+						SimpleRayContainer &rays,
+						const AxisAlignedBox3 &sbox
+						);
+
     virtual void CastRays(
 						  SimpleRayContainer &rays,
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2076)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp	(revision 2105)
@@ -625,5 +625,8 @@
 	sray = SimpleRay(mRays[index].mutatedOrigin,
 					 Normalize(mRays[index].mutatedTermination - mRays[index].mutatedOrigin),
-					 MUTATION_BASED_DISTRIBUTION, 1.0f);
+					 MUTATION_BASED_DISTRIBUTION,
+					 1.0f);
+	
+	
 	sray.mGeneratorId = index;
 	mRays[index].ResetReverseMutation();
@@ -676,6 +679,8 @@
   // use probabilitistic approach to decide for the type of mutation
   float a = RandomValue(0.0f,1.0f);
-
+  bool bidirectional = true;
+  
   if (mUseSilhouetteSamples && a < mSilhouetteProb) {
+	
 	termination += ComputeSilhouetteTerminationMutation(*ray,
 														origin,
@@ -683,4 +688,5 @@
 														U, V,
 														2.0f*objectRadius);
+	bidirectional = false;
   } else {
 	mRays[index].mHalton.GetNext(4, rr);
@@ -711,5 +717,6 @@
   sray = SimpleRay(origin, direction, MUTATION_BASED_DISTRIBUTION, pdf);
   sray.mGeneratorId = index;
-
+  sray.SetBidirectional(bidirectional);
+  
   return true;
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/run_test_pompeii
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/run_test_pompeii	(revision 2051)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/run_test_pompeii	(revision 2105)
@@ -2,5 +2,7 @@
 
 #COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+"
-COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -preprocessor_detect_empty_viewspace- -total_samples=500000000"
+#COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -preprocessor_detect_empty_viewspace- -total_samples=500000000"
+
+COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -preprocessor_detect_empty_viewspace+ -samples_per_evaluation=5000000 -samples_per_pass=1000000 -total_samples=250000000 -view_cells_use_kd_pvs+"
 
 
@@ -8,50 +10,307 @@
 VIEWCELLS=../data/Pompeii/pompeii_big-seq-viewcells.xml.gz
 
-PREFIX=../work/plots/osp-pompeiiTEST-1e5
-
-
-# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-#  -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \
-#  -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4n.xml \
-#  -preprocessor_stats=$PREFIX-i-mixed-b1-n4n.log \
-#  -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4n.hlog
-
-# # n - no origin mutation, q=2, reverse samples
-
-# $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-# -preprocessor_visibility_file=$PREFIX-r-reference.xml \
-# -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \
-# -preprocessor_histogram_file=$PREFIX-r-reference.hlog
-
-# $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-#  -rss_distributions=direction -view_cells_filter_max_size=1 \
-#  -preprocessor_visibility_file=$PREFIX-r-reference-global.xml \
-#  -preprocessor_stats=$PREFIX-r-reference-global.log \
-#  -preprocessor_histogram_file=$PREFIX-r-reference-global.hlog
-
-
-##### BVH measurements
-
-# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
-#  -rss_distributions=mutation+object_direction+spatial \
-#  -view_cells_use_kd_pvs- -af_use_kd_pvs- \
-#  -preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4n.xml \
-#  -preprocessor_stats=$PREFIX-i-mixed-bvh-n4n.log \
-#  -preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4n.hlog
-
+PREFIX=../work/plots/osp-pompeii3
+
+
+######################
+######################
 
 $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
--view_cells_use_kd_pvs- -af_use_kd_pvs- \
--preprocessor_visibility_file=$PREFIX-r-bvh-reference.xml \
--view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-bvh-reference.log \
--preprocessor_histogram_file=$PREFIX-r-bvh-reference.hlog
+-preprocessor_visibility_file=$PREFIX-reference.xml \
+-view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \
+-preprocessor_histogram_file=$PREFIX-r-reference.hlog
 
 $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
- -view_cells_use_kd_pvs- -af_use_kd_pvs- \
  -rss_distributions=direction -view_cells_filter_max_size=1 \
- -preprocessor_visibility_file=$PREFIX-r-bvh-reference-global.xml \
- -preprocessor_stats=$PREFIX-r-bvh-reference-global.log \
- -preprocessor_histogram_file=$PREFIX-r-bvh-reference-global.hlog
-
-
-#mutation+object_direction+
+ -preprocessor_visibility_file=$PREFIX-r-reference-global.xml \
+ -preprocessor_stats=$PREFIX-reference-global.log \
+ -preprocessor_histogram_file=$PREFIX-r-reference-global.hlog
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_buffer_size=100000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m1-1.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_buffer_size=200000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m1-2.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m1-3.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_buffer_size=1000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m1-4.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_buffer_size=2000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m1-5.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_buffer_size=4000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m1-6.log 
+
+
+# ############################
+# #### AND now the same with pass importance off
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=100000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m2-1.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=200000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m2-2.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m2-3.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=1000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m2-4.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=2000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m2-5.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=4000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m2-6.log 
+
+# ################################################
+# # silhouetee probability test
+# ################################################
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=0.0 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m3-1.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=0.2 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m3-2.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=0.5 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m3-3.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=0.8 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m3-4.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=1.0 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m3-5.log 
+
+
+################################################
+# reverse test
+################################################
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_reverse_samples_distance=1.0 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m4-1.log 
+
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_reverse_samples_distance=100000.0 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m4-2.log 
+
+
+### unsucc count test
+
+
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_use_unsucc_count_importance+ \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=2000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m5-1.log 
+
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_use_unsucc_count_importance+ \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m5-2.log 
+
+
+###########################################
+# search steps test
+###########################################
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_search_steps=1 \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m6-1.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_search_steps=2 \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m6-2.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_search_steps=4 \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m6-3.log 
+
+
+###########################################
+# radius test
+###########################################
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_radius_origin=0.2 \
+-mutation_radius_termination=0.2 \
+-mutation_silhouette_prob=0.5 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m7-1.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_radius_origin=1.0 \
+-mutation_radius_termination=1.0 \
+-mutation_silhouette_prob=0.5 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m7-2.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_radius_origin=0.5 \
+-mutation_radius_termination=0.2 \
+-mutation_silhouette_prob=0.5 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m7-3.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_radius_origin=0.5 \
+-mutation_radius_termination=1.0 \
+-mutation_silhouette_prob=0.5 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m7-4.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_radius_origin=0.2 \
+-mutation_radius_termination=0.5 \
+-mutation_silhouette_prob=0.5 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m7-5.log 
+
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_radius_origin=1.0 \
+-mutation_radius_termination=0.5 \
+-mutation_silhouette_prob=0.5 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m7-6.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_radius_origin=2.0 \
+-mutation_radius_termination=0.5 \
+-mutation_silhouette_prob=0.5 \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=500000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m7-7.log 
+
+
+### selected tests
+
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=0.5 \
+-mutation_reverse_samples_distance=1.0 \
+-mutation_radius_origin=0.5 \
+-mutation_radius_termination=0.2 \
+-mutation_use_unsucc_count_importance+ \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=2000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m8-1.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=0.5 \
+-mutation_reverse_samples_distance=1.0 \
+-mutation_radius_origin=1.0 \
+-mutation_radius_termination=0.2 \
+-mutation_use_unsucc_count_importance+ \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=2000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m8-2.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=0.5 \
+-mutation_reverse_samples_distance=1.0 \
+-mutation_radius_origin=2.0 \
+-mutation_radius_termination=0.2 \
+-mutation_use_unsucc_count_importance+ \
+-mutation_use_pass_importance- \
+-mutation_buffer_size=2000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m8-3.log 
+
+$COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
+-mutation_silhouette_prob=0.5 \
+-mutation_reverse_samples_distance=1.0 \
+-mutation_radius_origin=0.5 \
+-mutation_radius_termination=0.2 \
+-mutation_use_unsucc_count_importance- \
+-mutation_use_pass_importance+ \
+-mutation_buffer_size=2000000 \
+-rss_distributions=mutation+object_direction+spatial \
+-preprocessor_stats=$PREFIX-combined-m8-4.log 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h	(revision 2076)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h	(revision 2105)
@@ -130,4 +130,12 @@
 public:
   int index;
+
+  static int sPregeneratedDim;
+  static int sPregeneratedNumber;
+  static float *sPregeneratedValues;
+  
+  // special construtor for pregenerating static halton sequences
+  HaltonSequence(const int dim,
+				 const int number);
 
   HaltonSequence():index(1) {}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2048)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h	(revision 2105)
@@ -3,4 +3,5 @@
 
 #include "Ray.h"
+#include "SimpleRay.h"
 #include "VssRay.h"
 #include "Containers.h"
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h	(revision 1989)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h	(revision 2105)
@@ -47,5 +47,5 @@
 	  Intersectable *mObject;
 
-		/// the face of the intersectable
+	/// the face of the intersectable
 	  int mFace;
 
@@ -315,71 +315,4 @@
 };
 
-struct SimpleRay
-{
-  Vector3 mOrigin;
-  Vector3 mDirection;
-  short mType;
-  short mDistribution;
-  // generator Id -> relative to the generating distribution!
-  int mGeneratorId;
-  float mPdf;
-  
-  SimpleRay(): mType(Ray::LOCAL_RAY) {
-  }
-  
-  SimpleRay(const Vector3 &o,
-			const Vector3 &d,
-			const short distribution,
-			const float weight
-			):
-	mOrigin(o),
-	mDirection(d),
-	mType(Ray::LOCAL_RAY),
-	mDistribution(distribution),
-	mPdf(weight)
-  {	
-	//	mId = sSimpleRayId++;
-  }
-
-  float GetParam(const int axis) const {
-	if (axis < 3)
-	  return mOrigin[axis];
-	else
-	  return mDirection[axis-3];
-  }
-  
-  Vector3 Extrap(const float t) const {
-	  return mOrigin + mDirection * t;
-  }
-
-  friend ostream &operator<<(ostream &s, const SimpleRay &r)
-  {
-	  return s << "origin=" << r.mOrigin << " dir=" << r.mDirection;
-  };
-};
-
-class SimpleRayContainer : public vector<SimpleRay>
-{
-public:
-    
-  SimpleRayContainer():vector<SimpleRay>() {}
-  
-  void NormalizePdf(float scale = 1.0f) {
-	iterator it = begin();
-	float sumPdf = 0.0f;
-	for (; it != end(); it++)
-	  sumPdf += (*it).mPdf;
-
-	float c = scale/sumPdf;
-	
-	for (it = begin(); it != end(); it++) {
-	  (*it).mPdf*=c;
-	}
-  }
-  
-  void AddRay(const SimpleRay &ray) {
-	push_back(ray);
-  }
-};
 
 }
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp	(revision 2002)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp	(revision 2105)
@@ -647,6 +647,7 @@
 					 rays);
 		
+#if 0
 		rays.NormalizePdf((float)rays.size());
-		
+#endif
 		CastRays(rays, tmpVssRays, true, pruneInvalidRays);
 		castRays += (int)rays.size();
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2076)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h	(revision 2105)
@@ -7,5 +7,5 @@
 #include "Mesh.h"
 #include "KdTree.h"
-
+#include "SimpleRay.h"
 
 namespace GtpVisibilityPreprocessor {
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2100)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp	(revision 2105)
@@ -27,5 +27,5 @@
 #include "PerfTimer.h"
 
-#include "HashPvs.h"
+//#include "HashPvs.h"
 
 
@@ -1545,5 +1545,5 @@
 		
 		castSamples += samplesPerPass;
-HashPvs<int> dummy;
+		//HashPvs<int> dummy;
 
 		Real timeDiff = TimeDiff(startTime, GetTime());
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/SimpleRay.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/SimpleRay.h	(revision 2105)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/SimpleRay.h	(revision 2105)
@@ -0,0 +1,113 @@
+#ifndef __SIMPLERAY_H__
+#define __SIMPLERAY_H__
+
+#include <vector>
+using namespace std;
+#include "Vector3.h"
+
+namespace GtpVisibilityPreprocessor {
+
+struct SimpleRay
+{
+  
+  Vector3 mOrigin;
+  Vector3 mDirection;
+  // 6*4 = 24B
+
+  Intersectable *mOriginObject;
+  Intersectable *mTerminationObject;
+  // 2*4 = 8B
+
+  enum {F_BIDIRECTIONAL = 1};
+  unsigned short mFlags;
+  unsigned char mType;
+  unsigned char mDistribution;
+  // 4B
+
+  // generator Id -> relative to the generating distribution!
+  int mGeneratorId;
+  // 4B
+
+  // TOTAL = 40B
+
+
+  //float mWeight;
+  
+  SimpleRay(): mType(Ray::LOCAL_RAY)
+  {
+  }
+  
+  SimpleRay(const Vector3 &o,
+			const Vector3 &d,
+			const short distribution,
+			const float weight,
+			const unsigned char flags = F_BIDIRECTIONAL
+			):
+	mOrigin(o),
+	mDirection(d),
+	mFlags(flags),
+	mType(Ray::LOCAL_RAY),
+	mDistribution(distribution)
+	//	, mWeight(weight)
+  {	
+	//	mId = sSimpleRayId++;
+  }
+
+  bool IsBidirectional() const { return mFlags & F_BIDIRECTIONAL; }
+
+  void SetBidirectional(const bool b) {
+	if (b)
+	  mFlags |= F_BIDIRECTIONAL;
+	else
+	  mFlags &= ~F_BIDIRECTIONAL;
+  }
+  
+  float GetParam(const int axis) const {
+	if (axis < 3)
+	  return mOrigin[axis];
+	else
+	  return mDirection[axis-3];
+  }
+  
+  Vector3 Extrap(const float t) const {
+	  return mOrigin + mDirection * t;
+  }
+
+  friend ostream &operator<<(ostream &s, const SimpleRay &r)
+  {
+	  return s << "origin=" << r.mOrigin << " dir=" << r.mDirection;
+  };
+};
+
+class SimpleRayContainer : public vector<SimpleRay>
+{
+public:
+    
+  SimpleRayContainer():vector<SimpleRay>() {}
+  
+#if 0
+  void NormalizePdf(float scale = 1.0f) {
+	iterator it = begin();
+	float sumPdf = 0.0f;
+	for (; it != end(); it++)
+	  sumPdf += (*it).mPdf;
+	
+	float c = scale/sumPdf;
+	
+	for (it = begin(); it != end(); it++) {
+	  (*it).mPdf*=c;
+  }
+  }
+#endif
+  
+  void AddRay(const SimpleRay &ray) {
+	push_back(ray);
+  }
+};
+
+
+
+}
+
+#endif
+
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp	(revision 1990)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp	(revision 2105)
@@ -2,4 +2,5 @@
 #include "Matrix4x4.h"
 #include "Ray.h"
+#include "SimpleRay.h"
 
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 2077)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp	(revision 2105)
@@ -252,4 +252,49 @@
 
 
+
+
+void
+IntelRayCaster::CastSimpleForwardRays(
+									  SimpleRayContainer &rays,
+									  const AxisAlignedBox3 &sbox
+									  )
+{
+  int hit_triangles[16];
+  float dist[16];
+  Vector3 normals[16];
+  Vector3 min = sbox.Min();
+  Vector3 max = sbox.Max();
+  
+  int packets = rays.size() / 16;
+  
+  int i, j, k = 0;
+  Vector3 dir;
+  
+  for (i=0; i < packets; i++) {
+	for (j=0; j < 16; j++, k++)
+	  mlrtaStoreRayAS16(&rays[k].mOrigin.x,
+						&rays[k].mDirection.x,
+						j);
+	
+	mlrtaTraverseGroupAS16(&min.x,
+						   &max.x,
+						   hit_triangles,
+						   dist);
+
+  }
+
+
+  for (; k < rays.size(); k++) {
+	double normal[3];
+	hit_triangles[0] = mlrtaIntersectAS(
+										&rays[k].mOrigin.x,
+										&rays[k].mDirection.x,
+										normal,
+										dist[0]);
+  }
+  
+}
+
+
 void
 IntelRayCaster::CastRays(
@@ -263,4 +308,10 @@
   int buckets = rays.size()/16;
   int offset = 0;
+
+#if 0
+  int time = GetTime();
+  CastSimpleForwardRays(rays, sbox);
+  cout<<1e-3*2*rays.size()/TimeDiff(time, GetTime())<<" Mrays/sec"<<endl;
+#endif
   
   for (int i=0; i < buckets; i++, offset+=16) {
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2077)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Makefile	(revision 2105)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (2.00a) (Qt 4.1.2) on: pá 2. II 14:36:11 2007
+# Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 8. II 14:44:05 2007
 # Project:  preprocessor.pro
 # Template: app
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.h	(revision 1259)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.h	(revision 2105)
@@ -30,4 +30,5 @@
 #define _RSS_TRAVERSAL_STATISTICS
 
+class SimpleRayContainer;
 
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp	(revision 2076)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp	(revision 2105)
@@ -1,4 +1,6 @@
 #include "Halton.h"
 #include "PerfTimer.h"
+
+#define PREGENERATE_HALTON 0
 
 namespace GtpVisibilityPreprocessor {
@@ -25,13 +27,50 @@
   Halton<5> dummmyHalton5(true);
   Halton<6> dummmyHalton6(true);
+
+
+  int HaltonSequence::sPregeneratedDim = 0;
+  int HaltonSequence::sPregeneratedNumber = 0;
+  float *HaltonSequence::sPregeneratedValues = NULL;
   
+#if PREGENERATE_HALTON
+  // pregenerate first 100k numbers for 6 dimensions
+  static HaltonSequence staticHalton(6, 200000);
+#endif
+  
+  // special construtor for pregenerating static halton sequences
+  HaltonSequence::HaltonSequence(const int dim,
+								 const int number) {
+
+	sPregeneratedDim = 0;
+	sPregeneratedNumber = 0;
+	sPregeneratedValues = new float[number*dim];
+
+	float *p = sPregeneratedValues;
+	int i;
+	for (i=0; i < number; i++, p+=dim) {
+	  GetNext(dim, p);
+	}
+	
+	sPregeneratedDim = dim;
+	sPregeneratedNumber = number;
+  }
+
 void
 HaltonSequence::GetNext(const int dimensions, float *p)
 {
-  haltonTimer.Entry();
-  for (int i=0; i < dimensions; i++)
-	p[i] = (float)GetNumber(i+1);
+  //  haltonTimer.Entry();
+#if PREGENERATE_HALTON
+  if (index <= sPregeneratedNumber && dimensions <= sPregeneratedDim) {
+	float *pp = sPregeneratedValues + (sPregeneratedDim*(index-1));
+	for (int i=0; i < dimensions; i++)
+	  p[i] = pp[i];
+  } else
+#endif
+	{
+	  for (int i=0; i < dimensions; i++)
+		p[i] = (float)GetNumber(i+1);
+	}
   GenerateNext();
-  haltonTimer.Exit();
+  //  haltonTimer.Exit();
 }
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp	(revision 2053)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp	(revision 2105)
@@ -2294,4 +2294,5 @@
   //  Debug<<"D"<<flush;
   
+#if 0
   float density = 1.0f;
   float p = 1.0f/density; //(box.GetVolume()*dirBox.GetVolume())/i;
@@ -2299,4 +2300,5 @@
 	rays[i].mPdf = p;
   }
+#endif
 }
 
@@ -2510,11 +2512,12 @@
   // assign pdfs to the generated rays
   // float density = generated/(box.SurfaceArea()*dirBox.GetVolume());
+#if 0
   float density = 1.0f;
-
+  
   float p = 1.0f/density; //(box.GetVolume()*dirBox.GetVolume())/i;
   for (int i=startIndex; i < rays.size(); i++) {
 	rays[i].mPdf = p;
   }
-  
+#endif
   
   if (exporter) {
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp	(revision 1883)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp	(revision 2105)
@@ -24,4 +24,5 @@
 #include "Intersectable.h"
 #include "Ray.h"
+#include "SimpleRay.h"
 #include "SamplingStrategy.h"
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2076)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp	(revision 2105)
@@ -123,5 +123,5 @@
   AxisAlignedBox3 box =
 	mPreprocessor.mViewCellsManager->GetViewSpaceBox();
-	
+  
   float b[12]={
 	box.Min().x,
@@ -139,4 +139,18 @@
   };
 
+#if 0
+  static vector<SimpleRay *> pointerArray;
+
+  if (pointerArray.size()!=rays.size()) {
+	// realloc the pointerarray
+	pointerArray.resize(rays.size());
+  }
+
+  // init pointer array
+  SimpleRay *p = &pointerArray[0];
+  for (i=0; i < rays.size(); i++, p++)
+	pointerArray[i] = p;
+#endif
+  
   _SortRays(rays,
 			0,
@@ -162,10 +176,12 @@
   int i;
 
+  //const int batchsize = 16384;
   const int batchsize = 8192;
-
-  //  if (r - l < 32*batchsize)
-  //  	offset = 3;
-	
-  //  if (depth%5==0)
+  //const int batchsize = 128;
+
+  //if (r - l < 16*batchsize)
+  //	offset = 3;
+	
+  //  if (depth%2==0)
   //	offset = 3;
   
@@ -305,5 +321,5 @@
 						 hitA.mObject,
 						 mPreprocessor.mPass,
-						 simpleRay.mPdf
+						 1.0f //simpleRay.mPdf
 						 );
 #if DEBUG_RAYCAST
@@ -336,5 +352,5 @@
 			hitB.mObject,
 			mPreprocessor.mPass,
-			simpleRay.mPdf
+			1.0f //simpleRay.mPdf
 			);
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp	(revision 2072)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp	(revision 2105)
@@ -119,5 +119,5 @@
 						  hit.mObject,
 						  mPreprocessor.mPass,
-						  simpleRay.mPdf
+						  1.0f //simpleRay.mPdf
 						  );
 
@@ -139,5 +139,5 @@
 						  hit.mObject,
 						  mPreprocessor.mPass,
-						  simpleRay.mPdf
+						  1.0f //simpleRay.mPdf
 						  );
 	  vssRay->mFlags |= VssRay::Valid;
@@ -162,5 +162,5 @@
 							hitB.mObject,
 							  mPreprocessor.mPass,
-							  simpleRay.mPdf
+							  1.0f //simpleRay.mPdf
 							  );
 		  vssRay->mFlags |= VssRay::Valid;
@@ -175,5 +175,5 @@
 							  hitA.mObject,
 							  mPreprocessor.mPass,
-							  simpleRay.mPdf
+							  1.0f //simpleRay.mPdf
 							  );
 		  
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro	(revision 2076)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro	(revision 2105)
@@ -116,5 +116,5 @@
 RenderTexture.cpp Mutation.cpp Timer/RDTSCTimer.cpp \
 Timer/BenchTimer.cpp Timer/merror.cpp \
-Intersectable.cpp
+Intersectable.cpp TraversalTree.cpp
 
 SOURCES += BoostPreprocessorThread.cpp 
