Index: trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h	(revision 366)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h	(revision 369)
@@ -31,5 +31,6 @@
 {
 public:
-    Pvs(): mSamples(0), mEntries() {}
+	Pvs(): mSamples(0), mEntries() {}
+
 	int mSamples;
 
Index: trunk/VUT/GtpVisibilityPreprocessor/src/Makefile
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/Makefile	(revision 364)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/Makefile	(revision 369)
@@ -1,5 +1,5 @@
 #############################################################################
 # Makefile for building: preprocessor
-# Generated by qmake (1.07a) (Qt 3.3.3) on: Tue Nov  1 09:17:00 2005
+# Generated by qmake (1.07a) (Qt 3.3.2) on: Wed Nov 02 15:58:09 2005
 # Project:  preprocessor.pro
 # Template: app
@@ -9,43 +9,36 @@
 ####### Compiler, tools and options
 
-CC       = gcc
-CXX      = g++
-LEX      = flex
-YACC     = yacc
-CFLAGS   = -pipe -O2 -fmessage-length=0 -Wall -w -O2 -fmessage-length=0 -Wall -D_REENTRANT  -DQT_NO_DEBUG -DQT_THREAD_SUPPORT
-CXXFLAGS = -pipe -O2 -fmessage-length=0 -Wall -w -O2 -fmessage-length=0 -Wall -D_REENTRANT  -DQT_NO_DEBUG -DQT_THREAD_SUPPORT
-LEXFLAGS = 
-YACCFLAGS= -d
-INCPATH  = -I/usr/lib/qt3/mkspecs/default -I. -I../support/src/xerces-c-src_2_7_0/include -I../src -I../support/xerces/include -I../support/zlib/include -I../support/boost -I../support/devil/include -I/usr/include -I$(QTDIR)/include
-LINK     = g++
-LFLAGS   = 
-LIBS     = $(SUBLIBS) -L/usr/lib64/ -L../support/src/xerces-c-src_2_7_0/lib -L../support/devil/lib -L/usr/lib/qt3/lib64 -L$(QTDIR)/lib64/ -L/usr/X11R6/lib64/ -lxerces-c -lIL -lILU -lILUT -lqt-mt -lXext -lX11 -lm -lpthread
-AR       = ar cqs
-RANLIB   = 
-MOC      = $(QTDIR)/bin/moc
-UIC      = $(QTDIR)/bin/uic
-QMAKE    = qmake
-TAR      = tar -cf
-GZIP     = gzip -9f
-COPY     = cp -f
-COPY_FILE= $(COPY)
-COPY_DIR = $(COPY) -r
+CC		=	cl
+CXX		=	cl
+LEX		= flex
+YACC		= byacc
+CFLAGS	=	-nologo -Zm200 -W0 -MD -O2 -G7 -GX  -DUNICODE -DWIN32 -DQT_DLL -DQT_THREAD_SUPPORT -DQT_NO_DEBUG
+CXXFLAGS	=	-nologo -Zm200 -W0 -MD -O2 -G7 -GX  -DUNICODE -DWIN32 -DQT_DLL -DQT_THREAD_SUPPORT -DQT_NO_DEBUG
+LEXFLAGS	=
+YACCFLAGS	=-d
+INCPATH	=	 -I"..\src" -I"..\support\xerces\include" -I"..\support\zlib\include" -I"..\support\boost" -I"..\support\devil\include" -I"$(QTDIR)\include" -I"d:\gametools\svn\trunk\VUT\GtpVisibilityPreprocessor\src" -I"C:\Qt\3.3.2\mkspecs\win32-msvc.net"
+LINK	=	"c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe"
+LFLAGS	=	/NOLOGO /DELAYLOAD:comdlg32.dll /DELAYLOAD:oleaut32.dll /DELAYLOAD:winmm.dll /DELAYLOAD:wsock32.dll /DELAYLOAD:winspool.dll /SUBSYSTEM:CONSOLE /LIBPATH:"../support/xerces/lib" /LIBPATH:"../support/devil/lib" /LIBPATH:"$(QTDIR)\lib"
+LIBS	=	 "qt-mt332.lib" "qtmain.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "imm32.lib" "winmm.lib" "wsock32.lib" "winspool.lib" "delayimp.lib" "xerces-c_2.lib" "devil.lib" "ilu.lib" "ilut.lib" "opengl32.lib" "glu32.lib"
+MOC		=	$(QTDIR)\bin\moc.exe
+UIC		=	$(QTDIR)\bin\uic.exe
+QMAKE		=	qmake
+IDC		=	$(QTDIR)\bin\idc.exe
+IDL		=	midl
+ZIP		=	zip -r -9
+COPY_FILE	=       copy
+COPY_DIR	=       copy
+DEL_FILE	=       del
+DEL_DIR	=       rmdir
+MOVE		=       move
+CHK_DIR_EXISTS =	if not exist
+MKDIR		=	mkdir
 INSTALL_FILE= $(COPY_FILE)
 INSTALL_DIR = $(COPY_DIR)
-DEL_FILE = rm -f
-SYMLINK  = ln -sf
-DEL_DIR  = rmdir
-MOVE     = mv -f
-CHK_DIR_EXISTS= test -d
-MKDIR    = mkdir -p
-
-####### Output directory
-
-OBJECTS_DIR = ./
 
 ####### Files
 
-HEADERS = Halton.h
-SOURCES = Preprocessor.cpp \
+HEADERS =	Halton.h
+SOURCES =	Preprocessor.cpp \
 		SamplingPreprocessor.cpp \
 		ExactPreprocessor.cpp \
@@ -77,63 +70,70 @@
 		ViewCellBsp.cpp \
 		Halton.cpp
-OBJECTS = Preprocessor.o \
-		SamplingPreprocessor.o \
-		ExactPreprocessor.o \
-		KdTree.o \
-		Environment.o \
-		gzstream.o \
-		common.o \
-		UnigraphicsParser.o \
-		X3dExporter.o \
-		SceneGraph.o \
-		Material.o \
-		Matrix4x4.o \
-		Vector3.o \
-		AxisAlignedBox3.o \
-		Ray.o \
-		main.o \
-		Mesh.o \
-		Exporter.o \
-		Camera.o \
-		X3dParser.o \
-		MeshKdTree.o \
-		Pvs.o \
-		MutualVisibility.o \
-		Triangle3.o \
-		Rectangle3.o \
-		Plane3.o \
-		Polygon3.o \
-		ViewCell.o \
-		ViewCellBsp.o \
-		Halton.o
-FORMS = 
-UICDECLS = 
-UICIMPLS = 
-SRCMOC   = 
-OBJMOC = 
-DIST	   = preprocessor.pro
-QMAKE_TARGET = preprocessor
-DESTDIR  = 
-TARGET   = preprocessor
-
-first: all
+OBJECTS =	Preprocessor.obj \
+		SamplingPreprocessor.obj \
+		ExactPreprocessor.obj \
+		KdTree.obj \
+		Environment.obj \
+		gzstream.obj \
+		common.obj \
+		UnigraphicsParser.obj \
+		X3dExporter.obj \
+		SceneGraph.obj \
+		Material.obj \
+		Matrix4x4.obj \
+		Vector3.obj \
+		AxisAlignedBox3.obj \
+		Ray.obj \
+		main.obj \
+		Mesh.obj \
+		Exporter.obj \
+		Camera.obj \
+		X3dParser.obj \
+		MeshKdTree.obj \
+		Pvs.obj \
+		MutualVisibility.obj \
+		Triangle3.obj \
+		Rectangle3.obj \
+		Plane3.obj \
+		Polygon3.obj \
+		ViewCell.obj \
+		ViewCellBsp.obj \
+		Halton.obj
+FORMS =	
+UICDECLS =	
+UICIMPLS =	
+SRCMOC	=	
+OBJMOC	=	
+DIST	=	
+TARGET	=	preprocessor.exe
+
 ####### Implicit rules
 
-.SUFFIXES: .c .o .cpp .cc .cxx .C
-
-.cpp.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
-
-.cc.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
-
-.cxx.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
-
-.C.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
-
-.c.o:
-	$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+.SUFFIXES: .c .cpp .cc .cxx .C
+
+{.}.cpp{}.obj::
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo @<<
+	$<
+<<
+
+{.}.cc{}.obj::
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo @<<
+	$<
+<<
+
+{.}.cxx{}.obj::
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo @<<
+	$<
+<<
+
+{.}.C{}.obj::
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo @<<
+	$<
+<<
+
+{.}.c{}.obj::
+	$(CC) -c $(CFLAGS) $(INCPATH) -Fo @<<
+	$<
+<<
 
 ####### Build rules
@@ -141,43 +141,66 @@
 all: Makefile $(TARGET)
 
-$(TARGET):  $(UICDECLS) $(OBJECTS) $(OBJMOC)  
-	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(OBJCOMP) $(LIBS)
+$(TARGET):  $(UICDECLS) $(OBJECTS) $(OBJMOC) 
+	$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< 
+	  $(OBJECTS) $(OBJMOC) $(LIBS)
+<<
+
 
 mocables: $(SRCMOC)
-uicables: $(UICDECLS) $(UICIMPLS)
-
-$(MOC): 
-	( cd $(QTDIR)/src/moc && $(MAKE) )
-
-Makefile: preprocessor.pro  /usr/lib/qt3/mkspecs/default/qmake.conf 
+uicables: $(UICIMPLS) $(UICDECLS)
+
+Makefile: preprocessor.pro  C:\Qt\3.3.2\mkspecs\win32-msvc.net\qmake.conf C:\Qt\3.3.2\lib\qtmain.prl
 	$(QMAKE) -o Makefile preprocessor.pro
 qmake: 
 	@$(QMAKE) -o Makefile preprocessor.pro
 
-dist: 
-	@mkdir -p .tmp/preprocessor && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/preprocessor/ && ( cd `dirname .tmp/preprocessor` && $(TAR) preprocessor.tar preprocessor && $(GZIP) preprocessor.tar ) && $(MOVE) `dirname .tmp/preprocessor`/preprocessor.tar.gz . && $(DEL_FILE) -r .tmp/preprocessor
-
+dist:
+	$(ZIP) preprocessor.zip $(SOURCES) $(HEADERS) $(DIST) $(FORMS) d:/gametools/svn/trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro C:\Qt\3.3.2\lib\qtmain.prl  
+
+uiclean:
 mocclean:
-
-uiclean:
-
-yaccclean:
-lexclean:
-clean:
-	-$(DEL_FILE) $(OBJECTS)
-	-$(DEL_FILE) *~ core *.core
-
-
-####### Sub-libraries
+clean: uiclean mocclean
+	-$(DEL_FILE) Preprocessor.obj
+	-$(DEL_FILE) SamplingPreprocessor.obj
+	-$(DEL_FILE) ExactPreprocessor.obj
+	-$(DEL_FILE) KdTree.obj
+	-$(DEL_FILE) Environment.obj
+	-$(DEL_FILE) gzstream.obj
+	-$(DEL_FILE) common.obj
+	-$(DEL_FILE) UnigraphicsParser.obj
+	-$(DEL_FILE) X3dExporter.obj
+	-$(DEL_FILE) SceneGraph.obj
+	-$(DEL_FILE) Material.obj
+	-$(DEL_FILE) Matrix4x4.obj
+	-$(DEL_FILE) Vector3.obj
+	-$(DEL_FILE) AxisAlignedBox3.obj
+	-$(DEL_FILE) Ray.obj
+	-$(DEL_FILE) main.obj
+	-$(DEL_FILE) Mesh.obj
+	-$(DEL_FILE) Exporter.obj
+	-$(DEL_FILE) Camera.obj
+	-$(DEL_FILE) X3dParser.obj
+	-$(DEL_FILE) MeshKdTree.obj
+	-$(DEL_FILE) Pvs.obj
+	-$(DEL_FILE) MutualVisibility.obj
+	-$(DEL_FILE) Triangle3.obj
+	-$(DEL_FILE) Rectangle3.obj
+	-$(DEL_FILE) Plane3.obj
+	-$(DEL_FILE) Polygon3.obj
+	-$(DEL_FILE) ViewCell.obj
+	-$(DEL_FILE) ViewCellBsp.obj
+	-$(DEL_FILE) Halton.obj
+
+
+
+FORCE:
 
 distclean: clean
-	-$(DEL_FILE) $(TARGET) $(TARGET)
-
-
-FORCE:
+	-$(DEL_FILE) $(TARGET)
 
 ####### Compile
 
-Preprocessor.o: Preprocessor.cpp SceneGraph.h \
+Preprocessor.obj: Preprocessor.cpp  \
+		SceneGraph.h \
 		Exporter.h \
 		UnigraphicsParser.h \
@@ -200,7 +223,9 @@
 		Intersectable.h \
 		Pvs.h \
-		Ray.h
-
-SamplingPreprocessor.o: SamplingPreprocessor.cpp SceneGraph.h \
+		Ray.h \
+		
+
+SamplingPreprocessor.obj: SamplingPreprocessor.cpp  \
+		SceneGraph.h \
 		KdTree.h \
 		SamplingPreprocessor.h \
@@ -224,7 +249,9 @@
 		Intersectable.h \
 		Material.h \
-		Exporter.h
-
-ExactPreprocessor.o: ExactPreprocessor.cpp ExactPreprocessor.h \
+		Exporter.h \
+		
+
+ExactPreprocessor.obj: ExactPreprocessor.cpp  \
+		ExactPreprocessor.h \
 		Preprocessor.h \
 		Containers.h \
@@ -242,31 +269,41 @@
 		Vector3.h \
 		common.h \
-		Ray.h
-
-KdTree.o: KdTree.cpp Environment.h \
-		Mesh.h \
-		KdTree.h \
-		common.h \
-		Intersectable.h \
-		Plane3.h \
-		Matrix4x4.h \
-		AxisAlignedBox3.h \
-		Material.h \
-		Pvs.h \
-		Rectangle3.h \
-		Vector3.h \
-		Containers.h \
-		Ray.h
-
-Environment.o: Environment.cpp gzstream.h \
-		common.h \
-		Environment.h \
-		Vector3.h
-
-gzstream.o: gzstream.cpp gzstream.h
-
-common.o: common.cpp common.h
-
-UnigraphicsParser.o: UnigraphicsParser.cpp Vector3.h \
+		Ray.h \
+		
+
+KdTree.obj: KdTree.cpp  \
+		Environment.h \
+		Mesh.h \
+		KdTree.h \
+		common.h \
+		Intersectable.h \
+		Plane3.h \
+		Matrix4x4.h \
+		AxisAlignedBox3.h \
+		Material.h \
+		Pvs.h \
+		Rectangle3.h \
+		Vector3.h \
+		Containers.h \
+		Ray.h \
+		
+
+Environment.obj: Environment.cpp  \
+		gzstream.h \
+		common.h \
+		Environment.h \
+		Vector3.h \
+		
+
+gzstream.obj: gzstream.cpp  \
+		gzstream.h \
+		
+
+common.obj: common.cpp  \
+		common.h \
+		
+
+UnigraphicsParser.obj: UnigraphicsParser.cpp  \
+		Vector3.h \
 		Mesh.h \
 		SceneGraph.h \
@@ -282,7 +319,9 @@
 		Rectangle3.h \
 		Containers.h \
-		Parser.h
-
-X3dExporter.o: X3dExporter.cpp common.h \
+		Parser.h \
+		
+
+X3dExporter.obj: X3dExporter.cpp  \
+		common.h \
 		SceneGraph.h \
 		X3dExporter.h \
@@ -302,7 +341,9 @@
 		Intersectable.h \
 		Pvs.h \
-		Ray.h
-
-SceneGraph.o: SceneGraph.cpp SceneGraph.h \
+		Ray.h \
+		
+
+SceneGraph.obj: SceneGraph.cpp  \
+		SceneGraph.h \
 		X3dExporter.h \
 		Intersectable.h \
@@ -316,19 +357,27 @@
 		Exporter.h \
 		Material.h \
-		Pvs.h
-
-Material.o: Material.cpp common.h \
-		Material.h
-
-Matrix4x4.o: Matrix4x4.cpp Matrix4x4.h \
-		Vector3.h \
-		common.h
-
-Vector3.o: Vector3.cpp Matrix4x4.h \
+		Pvs.h \
+		
+
+Material.obj: Material.cpp  \
+		common.h \
+		Material.h \
+		
+
+Matrix4x4.obj: Matrix4x4.cpp  \
+		Matrix4x4.h \
+		Vector3.h \
+		common.h \
+		
+
+Vector3.obj: Vector3.cpp  \
+		Matrix4x4.h \
 		Vector3.h \
 		Halton.h \
-		common.h
-
-AxisAlignedBox3.o: AxisAlignedBox3.cpp AxisAlignedBox3.h \
+		common.h \
+		
+
+AxisAlignedBox3.obj: AxisAlignedBox3.cpp  \
+		AxisAlignedBox3.h \
 		Ray.h \
 		Polygon3.h \
@@ -342,13 +391,17 @@
 		Intersectable.h \
 		Material.h \
-		Pvs.h
-
-Ray.o: Ray.cpp Ray.h \
-		Plane3.h \
-		Matrix4x4.h \
-		Vector3.h \
-		common.h
-
-main.o: main.cpp SamplingPreprocessor.h \
+		Pvs.h \
+		
+
+Ray.obj: Ray.cpp  \
+		Ray.h \
+		Plane3.h \
+		Matrix4x4.h \
+		Vector3.h \
+		common.h \
+		
+
+main.obj: main.cpp  \
+		SamplingPreprocessor.h \
 		ExactPreprocessor.h \
 		Parser.h \
@@ -376,7 +429,9 @@
 		Vector3.h \
 		common.h \
-		Ray.h
-
-Mesh.o: Mesh.cpp Ray.h \
+		Ray.h \
+		
+
+Mesh.obj: Mesh.cpp  \
+		Ray.h \
 		Mesh.h \
 		MeshKdTree.h \
@@ -391,28 +446,34 @@
 		Pvs.h \
 		Rectangle3.h \
-		Containers.h
-
-Exporter.o: Exporter.cpp X3dExporter.h \
-		Exporter.h \
-		Containers.h \
-		Material.h
-
-Camera.o: Camera.cpp Camera.h \
-		Ray.h \
-		KdTree.h \
-		Mesh.h \
-		Exporter.h \
-		Vector3.h \
-		AxisAlignedBox3.h \
-		common.h \
-		Rectangle3.h \
-		Matrix4x4.h \
-		Plane3.h \
-		Containers.h \
-		Pvs.h \
-		Intersectable.h \
-		Material.h
-
-X3dParser.o: X3dParser.cpp X3dParser.h \
+		Containers.h \
+		
+
+Exporter.obj: Exporter.cpp  \
+		X3dExporter.h \
+		Exporter.h \
+		Containers.h \
+		Material.h \
+		
+
+Camera.obj: Camera.cpp  \
+		Camera.h \
+		Ray.h \
+		KdTree.h \
+		Mesh.h \
+		Exporter.h \
+		Vector3.h \
+		AxisAlignedBox3.h \
+		common.h \
+		Rectangle3.h \
+		Matrix4x4.h \
+		Plane3.h \
+		Containers.h \
+		Pvs.h \
+		Intersectable.h \
+		Material.h \
+		
+
+X3dParser.obj: X3dParser.cpp  \
+		X3dParser.h \
 		X3dParserXerces.h \
 		Mesh.h \
@@ -431,7 +492,9 @@
 		Vector3.h \
 		common.h \
-		Ray.h
-
-MeshKdTree.o: MeshKdTree.cpp Environment.h \
+		Ray.h \
+		
+
+MeshKdTree.obj: MeshKdTree.cpp  \
+		Environment.h \
 		Mesh.h \
 		MeshKdTree.h \
@@ -446,9 +509,13 @@
 		Vector3.h \
 		Containers.h \
-		Ray.h
-
-Pvs.o: Pvs.cpp Pvs.h
-
-MutualVisibility.o: MutualVisibility.cpp KdTree.h \
+		Ray.h \
+		
+
+Pvs.obj: Pvs.cpp  \
+		Pvs.h \
+		
+
+MutualVisibility.obj: MutualVisibility.cpp  \
+		KdTree.h \
 		AxisAlignedBox3.h \
 		Ray.h \
@@ -466,20 +533,28 @@
 		common.h \
 		Material.h \
-		Intersectable.h
-
-Triangle3.o: Triangle3.cpp Triangle3.h \
-		Vector3.h \
-		common.h
-
-Rectangle3.o: Rectangle3.cpp Rectangle3.h \
-		Vector3.h \
-		common.h
-
-Plane3.o: Plane3.cpp Plane3.h \
-		Matrix4x4.h \
-		Vector3.h \
-		common.h
-
-Polygon3.o: Polygon3.cpp Polygon3.h \
+		Intersectable.h \
+		
+
+Triangle3.obj: Triangle3.cpp  \
+		Triangle3.h \
+		Vector3.h \
+		common.h \
+		
+
+Rectangle3.obj: Rectangle3.cpp  \
+		Rectangle3.h \
+		Vector3.h \
+		common.h \
+		
+
+Plane3.obj: Plane3.cpp  \
+		Plane3.h \
+		Matrix4x4.h \
+		Vector3.h \
+		common.h \
+		
+
+Polygon3.obj: Polygon3.cpp  \
+		Polygon3.h \
 		Mesh.h \
 		ViewCellBsp.h \
@@ -494,7 +569,9 @@
 		Rectangle3.h \
 		Vector3.h \
-		common.h
-
-ViewCell.o: ViewCell.cpp ViewCell.h \
+		common.h \
+		
+
+ViewCell.obj: ViewCell.cpp  \
+		ViewCell.h \
 		Mesh.h \
 		Intersectable.h \
@@ -510,7 +587,9 @@
 		Rectangle3.h \
 		Vector3.h \
-		common.h
-
-ViewCellBsp.o: ViewCellBsp.cpp Plane3.h \
+		common.h \
+		
+
+ViewCellBsp.obj: ViewCellBsp.cpp  \
+		Plane3.h \
 		ViewCellBsp.h \
 		Mesh.h \
@@ -528,7 +607,10 @@
 		Material.h \
 		Pvs.h \
-		Rectangle3.h
-
-Halton.o: Halton.cpp Halton.h
+		Rectangle3.h \
+		
+
+Halton.obj: Halton.cpp  \
+		Halton.h \
+		
 
 ####### Install
Index: trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h	(revision 367)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h	(revision 369)
@@ -23,5 +23,5 @@
 public:
   enum RayType { LOCAL_RAY, GLOBAL_RAY, LINE_SEGMENT };
-
+	
   enum { NO_INTERSECTION=0, INTERSECTION_OUT_OF_LIMITS, INTERSECTION };
 
@@ -36,20 +36,20 @@
     // can be either mesh or a viewcell
     Intersectable *mObject;
-
+		
     // the face of the intersectable
     int mFace;
 
     Intersection(const float t,
-		 Intersectable *object,
-		 const int face):mT(t), mObject(object), mFace(face) {}
-
+								 Intersectable *object,
+								 const int face):mT(t), mObject(object), mFace(face) {}
+		
     Intersection() {}
-
+		
     bool operator<(
-		   const Intersection &b) const {
+									 const Intersection &b) const {
       return 
-	mT
-	<
-	b.mT;
+				mT
+				<
+				b.mT;
     }
     
@@ -70,6 +70,5 @@
   Ray(const Vector3 &wherefrom,
       const Vector3 &whichdir,
-      const int _type,
-      const void *_originCell = NULL) {
+      const int _type) {
     loc = wherefrom;
     if (_type == LINE_SEGMENT)
@@ -94,7 +93,7 @@
   // Inititalize the ray again when already constructed
   void Init(const Vector3 &wherefrom,
-	    const Vector3 &whichdir,
-	    const int _type, 
-	    bool dirNormalized = false) {
+						const Vector3 &whichdir,
+						const int _type, 
+						bool dirNormalized = false) {
     loc = wherefrom;
     dir = (dirNormalized || _type == LINE_SEGMENT) ? whichdir: Normalize(whichdir) ;
@@ -252,11 +251,17 @@
   int mRays;
   int mContributions;
-  PassingRaySet() {
+
+	PassingRaySet() {
     Reset();
   }
-  void
+
+	void
   Reset();
   
   void AddRay(const Ray &ray, const int contributions);
+	void AddRay2(const Ray &ray,
+							 const int objects,
+							 const int viewcells);
+
   int GetEntryIndex(const Vector3 &direction) const;
 
Index: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h	(revision 366)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h	(revision 369)
@@ -35,6 +35,6 @@
 	*/
 	static void DeriveViewCells(const ObjectContainer &objects, 
-								ViewCellContainer &viewCells, 
-								const int maxViewCells);
+															ViewCellContainer &viewCells, 
+															const int maxViewCells);
 
 	
Index: trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp	(revision 367)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp	(revision 369)
@@ -139,4 +139,16 @@
 }
 
+void
+PassingRaySet::AddRay2(const Ray &ray,
+											 const int objects,
+											 const int viewcells
+											 )
+{
+  int i = GetEntryIndex(ray.GetDir());
+  mRays++;
+  mContributions += objects*viewcells;
+  mDirectionalContributions[i] += objects*viewcells;
+}
+
 int
 PassingRaySet::GetEntryIndex(const Vector3 &direction) const
@@ -158,7 +170,8 @@
 }
 
-int Ray::ClassifyPlane(const Plane3 &plane, 
-					   const float minT, 
-					   const float maxT) const
+int
+Ray::ClassifyPlane(const Plane3 &plane, 
+									 const float minT, 
+									 const float maxT) const
 {
 	const Vector3 entp = Extrap(minT);
@@ -169,25 +182,25 @@
 
 	if (entSide < 0)
-	{
-		if (extSide >= 0)
 		{
-			return BACK_FRONT;
+			if (extSide >= 0)
+				{
+					return BACK_FRONT;
+				}
+			return BACK;
 		}
-		return BACK;
-	}
 	else if (entSide > 0)
-	{
-		if (extSide <= 0)
-			return FRONT_BACK;
-
-		return FRONT;
-	}
+		{
+			if (extSide <= 0)
+				return FRONT_BACK;
+			
+			return FRONT;
+		}
 	else if (entSide == 0)
-	{
-		if (extSide > 0)
-			return BACK_FRONT;
-		else if (extSide < 0)
-			return FRONT_BACK;
-	}
+		{
+			if (extSide > 0)
+				return BACK_FRONT;
+			else if (extSide < 0)
+				return FRONT_BACK;
+		}
 	
 	return COINCIDENT;
Index: trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h	(revision 365)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h	(revision 369)
@@ -161,9 +161,19 @@
   }
   
-  void AddPassingRay(const Ray &ray, const int contributions) {
+  void AddPassingRay(const Ray &ray,
+										 const int contributions) {
     mPassingRays.AddRay(ray, contributions);
 		//		Debug << "adding passing ray" << endl;
   }
-  
+
+	
+	void AddPassingRay2(const Ray &ray,
+											const int objects,
+											const int viewcells
+											) {
+    mPassingRays.AddRay2(ray, objects, viewcells);
+		//		Debug << "adding passing ray" << endl;
+  }
+
   /** \sa KdNode::IsLeaf() */
   virtual bool IsLeaf() const { return true; }
@@ -180,10 +190,12 @@
   /** Ray set description of the rays passing through this node */
   PassingRaySet mPassingRays;
-
+	
   /** PVS consisting of visible KdTree nodes */
   KdPvs mKdPvs;
-  
+	
+	/** PVS consisting of visible objects */
+  ViewCellPvs mPvs;
 };
-  
+
   
 
@@ -227,5 +239,5 @@
       
       bool operator()(const TraversalData a, const TraversalData b) {
-	return a.mPriority < b.mPriority;
+				return a.mPriority < b.mPriority;
       }
       
@@ -283,8 +295,8 @@
   void
   CollectObjects(KdNode *n, ObjectContainer &objects);
-
+	
   void
   CollectLeaves(vector<KdLeaf *> &leaves);
-
+	
   AxisAlignedBox3 GetBox(const KdNode *node) const {
     KdInterior *parent = node->mParent;
@@ -302,10 +314,9 @@
     return box;
   }
-
+	
   KdNode *
   FindRandomNeighbor(KdNode *n,
 										 bool onlyUnmailed
 										 );
-	
   
   KdNode *
Index: trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h	(revision 367)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h	(revision 369)
@@ -7,8 +7,4 @@
 #include "Preprocessor.h"
 
-struct SimpleRay {
-  Vector3 mOrigin;
-  Vector3 mDirection;
-};
 
 /** Sampling based visibility preprocessing. The implementation is based on heuristical
@@ -42,6 +38,9 @@
   GetNodeForPvs(KdLeaf *leaf);
 
-  int
-  AddNodeSamples(Intersectable *object, const Ray &ray);
+	int
+	AddNodeSamples(const Ray &ray,
+								 Intersectable *sObject,
+								 Intersectable *tObject
+								 );
 
   void
@@ -49,6 +48,7 @@
 
 	int
-	CastRay(Intersectable *object, Ray &ray, const bool reverseSample);
-
+	CastRay(Intersectable *object,
+					Ray &ray);
+	
 	KdNode *
 	GetNodeToSample(Intersectable *object);
Index: trunk/VUT/GtpVisibilityPreprocessor/src/default.env
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/default.env	(revision 365)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/default.env	(revision 369)
@@ -11,7 +11,7 @@
 #	filename ../data/vienna/vienna-buildings.x3d
 # filename ../data/vienna/viewcells-25-sel.x3d
-filename ../data/atlanta/atlanta2.x3d
+# filename ../data/atlanta/atlanta2.x3d
 #	filename ../data/soda/soda.dat
-#	filename ../data/soda/soda5.dat
+filename ../data/soda/soda5.dat
 }
 
@@ -56,5 +56,5 @@
 
 Sampling {
-	totalSamples	500000000
+	totalSamples 100000000
 	samplesPerPass  3
 }
Index: trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 367)
+++ trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp	(revision 369)
@@ -84,18 +84,32 @@
 
 int
-SamplingPreprocessor::AddNodeSamples(Intersectable *object,
-																		 const Ray &ray
+SamplingPreprocessor::AddNodeSamples(const Ray &ray,
+																		 Intersectable *sObject,
+																		 Intersectable *tObject
 																		 )
 {
   int contributingSamples = 0;
   int j;
-  for (j=0; j < ray.kdLeaves.size(); j++) {
-    KdNode *node = GetNodeForPvs( ray.kdLeaves[j] );
-    contributingSamples += object->mKdPvs.AddSample(node);
-  }
-   
-  if (mPass > 10)
-    for (j=1; j < ((int)ray.kdLeaves.size() - 1); j++) {
-      ray.kdLeaves[j]->AddPassingRay(ray, contributingSamples ? 1 : 0);
+	int objects = 0;
+	if (sObject)
+		objects++;
+	if (tObject)
+		objects++;
+
+	if (objects) {
+		for (j=0; j < ray.kdLeaves.size(); j++) {
+			KdNode *node = GetNodeForPvs( ray.kdLeaves[j] );
+			if (sObject)
+				contributingSamples += sObject->mKdPvs.AddSample(node);
+			if (tObject)
+				contributingSamples += tObject->mKdPvs.AddSample(node);
+		}
+	}
+	
+	for (j=1; j < ((int)ray.kdLeaves.size() - 1); j++) {
+		ray.kdLeaves[j]->AddPassingRay2(ray,
+																		objects,
+																		ray.kdLeaves.size()
+																		);
   }
   
@@ -148,6 +162,5 @@
 int
 SamplingPreprocessor::CastRay(Intersectable *object,
-															Ray &ray,
-															const bool reverseRay
+															Ray &ray
 															)
 {
@@ -159,5 +172,5 @@
 	long t2 = GetRealTime();
 
-	if (0 && object->GetId() > 2197) {
+	if (0 && object && object->GetId() > 2197) {
 		object->Describe(cout)<<endl;
 		cout<<ray<<endl;
@@ -171,5 +184,5 @@
 			mBspTree->CastRay(ray);
 			
-			if (!reverseRay)
+			if (object)
 				sampleContributions += AddObjectSamples(object, ray);
 			
@@ -184,12 +197,12 @@
 		{
 			if (ray.kdLeaves.size()) {
-				if (!reverseRay)
-					sampleContributions += AddNodeSamples(object, ray);
-				
-				if (ray.intersections.size()) {
-					sampleContributions += AddNodeSamples(ray.intersections[0].mObject, ray);
-				}
-			} 
-		} 	
+				Intersectable *terminator =
+					ray.intersections.size() ? ray.intersections[0].mObject: NULL;
+
+				sampleContributions += AddNodeSamples(ray,
+																							object,
+																							terminator);
+			}
+		}
 	
 	return sampleContributions;
@@ -278,5 +291,5 @@
 			// to the mesh
 			rays++;
-			edgeSamplesContributions += CastRay(object, ray, false);
+			edgeSamplesContributions += CastRay(object, ray);
 		}
 	}
@@ -410,5 +423,5 @@
 				for (int k=0; k < mSamplesPerPass; k++) {
 					bool reverseSample = false;
-
+					
 
 					if (nodeToSample) {
@@ -432,5 +445,5 @@
 					SetupRay(ray, point, direction, Ray::LOCAL_RAY);
 					
-					sampleContributions = CastRay(object, ray, reverseSample);
+					sampleContributions = CastRay(reverseSample ? NULL : object, ray);
 					
 					//-- CORR matt: put block inside loop
@@ -576,39 +589,39 @@
 	}
    for (int k=0; k < pvsOut; k++) {
-      Intersectable *object = objects[k];
-      char s[64];
-      sprintf(s, "sample-pvs%04d.x3d", k);
-      Exporter *exporter = Exporter::GetExporter(s);
-      exporter->SetWireframe();
-
-	
-	  KdPvsMap::iterator i = object->mKdPvs.mEntries.begin();
-	  Intersectable::NewMail();
-		  
-	  // avoid adding the object to the list
-	  object->Mail();
-	  ObjectContainer visibleObjects;
-
-	  for (; i != object->mKdPvs.mEntries.end(); i++) 
-	  {
-		  KdNode *node = (*i).first;
-		  exporter->ExportBox(mKdTree->GetBox(node));
-		  mKdTree->CollectObjects(node, visibleObjects);
-	  }
-
-	  exporter->ExportRays(rays[k], 1000, RgbColor(0, 1, 0));
-	  exporter->SetFilled();
-
-	  for (int j = 0; j < visibleObjects.size(); j++)
-		  exporter->ExportIntersectable(visibleObjects[j]);
-	
-
-	  Material m;
-	  m.mDiffuseColor = RgbColor(1, 0, 0);
-	  exporter->SetForcedMaterial(m);
-	  exporter->ExportIntersectable(object);
-
-	  delete exporter;
-    }
+		 Intersectable *object = objects[k];
+		 char s[64];
+		 sprintf(s, "sample-pvs%04d.x3d", k);
+		 Exporter *exporter = Exporter::GetExporter(s);
+		 exporter->SetWireframe();
+		 
+		 
+		 KdPvsMap::iterator i = object->mKdPvs.mEntries.begin();
+		 Intersectable::NewMail();
+		 
+		 // avoid adding the object to the list
+		 object->Mail();
+		 ObjectContainer visibleObjects;
+		 
+		 for (; i != object->mKdPvs.mEntries.end(); i++) 
+			 {
+				 KdNode *node = (*i).first;
+				 exporter->ExportBox(mKdTree->GetBox(node));
+				 mKdTree->CollectObjects(node, visibleObjects);
+			 }
+		 
+		 exporter->ExportRays(rays[k], 1000, RgbColor(0, 1, 0));
+		 exporter->SetFilled();
+		 
+		 for (int j = 0; j < visibleObjects.size(); j++)
+			 exporter->ExportIntersectable(visibleObjects[j]);
+		 
+		 
+		 Material m;
+		 m.mDiffuseColor = RgbColor(1, 0, 0);
+		 exporter->SetForcedMaterial(m);
+		 exporter->ExportIntersectable(object);
+		 
+		 delete exporter;
+	 }
   }
   
