Changeset 339


Ignore:
Timestamp:
10/18/05 14:21:26 (19 years ago)
Author:
bittner
Message:

changed mailbox naming convention, added intersectable ids

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/Intersectable.h

    r308 r339  
    88class Intersectable { 
    99public: 
    10   static int mailID; 
    11   int mailbox; 
     10        // last mail id -> warning not thread safe! 
     11        // both mailId and mailbox should be unique for each thread!!! 
     12        static int sMailId; 
     13        int mMailbox; 
     14         
     15        // unique object Id 
     16        int mId; 
    1217 
    13   KdPvs mKdPvs; 
     18        // object based pvs 
     19        KdPvs mKdPvs; 
    1420   
    1521  enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL }; 
    1622   
    17   Intersectable():mailbox(0) {} 
    18    
    19   void Mail() { mailbox = mailID; } 
    20   static void NewMail() { mailID++; } 
    21   bool Mailed() const { return mailbox == mailID; } 
    22   int IncMail() { return ++mailbox - mailID; } 
     23  Intersectable():mMailbox(0) {} 
     24 
     25        void SetId(const int id) { mId = id; } 
     26        int GetId() { return mId; } 
     27         
     28        void Mail() { mMailbox = sMailId; } 
     29  static void NewMail() { sMailId++; } 
     30  bool Mailed() const { return mMailbox == sMailId; } 
     31  int IncMail() { return ++mMailbox - sMailId; } 
    2332 
    2433  virtual AxisAlignedBox3 GetBox() = 0; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Makefile

    r333 r339  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (1.07a) (Qt 3.3.2) on: Tue Sep 06 13:46:00 2005 
     3# Generated by qmake (1.07a) (Qt 3.3.2) on: Tue Oct 18 11:00:55 2005 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    1313LEX             = flex 
    1414YACC            = byacc 
    15 CFLAGS  =       -nologo -Zm200 -W0 -MD -O2 -GX  -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT -DQT_NO_DEBUG 
    16 CXXFLAGS        =       -nologo -Zm200 -W0 -MD -O2 -GX  -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT -DQT_NO_DEBUG 
     15CFLAGS  =       -nologo -Zm200 -W0 -MDd -Zi -Gm -GX  -DUNICODE -DWIN32 -DQT_DLL -DQT_THREAD_SUPPORT 
     16CXXFLAGS        =       -nologo -Zm200 -W0 -MDd -Zi -Gm -GX  -DUNICODE -DWIN32 -DQT_DLL -DQT_THREAD_SUPPORT 
    1717LEXFLAGS        = 
    1818YACCFLAGS       =-d 
    19 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" 
    20 LINK    =       link 
    21 LFLAGS  =       /NOLOGO delayimp.lib /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" 
    22 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" "xerces-c_2.lib" "devil.lib" "ilu.lib" "ilut.lib" "opengl32.lib" "glu32.lib" "delayimp.lib" 
     19INCPATH =        -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" 
     20LINK    =       "c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe" 
     21LFLAGS  =       /NOLOGO /DEBUG /SUBSYSTEM:CONSOLE /LIBPATH:"../support/xerces/lib" /LIBPATH:"../support/devil/lib" /LIBPATH:"$(QTDIR)\lib" 
     22LIBS    =        "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" 
    2323MOC             =       $(QTDIR)\bin\moc.exe 
    2424UIC             =       $(QTDIR)\bin\uic.exe 
     
    148148uicables: $(UICIMPLS) $(UICDECLS) 
    149149 
    150 Makefile: preprocessor.pro  C:\Qt\3.3.2\mkspecs\win32-msvc\qmake.conf C:\Qt\3.3.2\lib\qtmain.prl 
     150Makefile: preprocessor.pro  C:\Qt\3.3.2\mkspecs\win32-msvc.net\qmake.conf C:\Qt\3.3.2\lib\qtmain.prl 
    151151        $(QMAKE) -o Makefile preprocessor.pro 
    152152qmake:  
     
    188188        -$(DEL_FILE) ViewCell.obj 
    189189        -$(DEL_FILE) ViewCellBsp.obj 
     190        -$(DEL_FILE) preprocessor.pdb 
     191        -$(DEL_FILE) preprocessor.ilk 
     192        -$(DEL_FILE) vc*.pdb 
     193        -$(DEL_FILE) vc*.idb 
     194 
    190195 
    191196 
     
    231236                MutualVisibility.h \ 
    232237                Polygon3.h \ 
     238                ViewCell.h \ 
    233239                Containers.h \ 
    234240                AxisAlignedBox3.h \ 
     
    255261                KdTree.h \ 
    256262                ViewCellBsp.h \ 
     263                ViewCell.h \ 
    257264                Intersectable.h \ 
    258265                Plane3.h \ 
     
    373380                AxisAlignedBox3.h \ 
    374381                Ray.h \ 
    375                 Rectangle3.h \ 
    376                 Matrix4x4.h \ 
    377                 Vector3.h \ 
    378                 Plane3.h \ 
    379                 common.h \ 
     382                Polygon3.h \ 
     383                Rectangle3.h \ 
     384                Matrix4x4.h \ 
     385                Vector3.h \ 
     386                Plane3.h \ 
     387                common.h \ 
     388                Containers.h \ 
     389                Mesh.h \ 
     390                Intersectable.h \ 
     391                Material.h \ 
     392                Pvs.h \ 
    380393                 
    381394 
    382395Ray.obj: Ray.cpp  \ 
    383396                Ray.h \ 
     397                Plane3.h \ 
    384398                Matrix4x4.h \ 
    385399                Vector3.h \ 
     
    396410                Camera.h \ 
    397411                MeshKdTree.h \ 
     412                Exporter.h \ 
     413                X3dExporter.h \ 
     414                ViewCell.h \ 
     415                SceneGraph.h \ 
    398416                Preprocessor.h \ 
    399417                Containers.h \ 
     
    433451                X3dExporter.h \ 
    434452                Exporter.h \ 
     453                Containers.h \ 
    435454                Material.h \ 
    436455                 
     
    459478                Mesh.h \ 
    460479                SceneGraph.h \ 
     480                Triangle3.h \ 
     481                ViewCell.h \ 
    461482                Parser.h \ 
    462                 Intersectable.h \ 
    463                 Plane3.h \ 
    464                 Matrix4x4.h \ 
    465                 AxisAlignedBox3.h \ 
    466                 Material.h \ 
    467                 Pvs.h \ 
    468                 Rectangle3.h \ 
    469                 Vector3.h \ 
    470                 common.h \ 
    471                 Containers.h \ 
     483                Containers.h \ 
     484                Intersectable.h \ 
     485                Plane3.h \ 
     486                Matrix4x4.h \ 
     487                AxisAlignedBox3.h \ 
     488                Material.h \ 
     489                Pvs.h \ 
     490                Rectangle3.h \ 
     491                Vector3.h \ 
     492                common.h \ 
     493                Ray.h \ 
    472494                 
    473495 
     
    535557                Polygon3.h \ 
    536558                Mesh.h \ 
    537                 Containers.h \ 
    538                 Intersectable.h \ 
    539                 Plane3.h \ 
    540                 Matrix4x4.h \ 
    541                 AxisAlignedBox3.h \ 
     559                ViewCellBsp.h \ 
     560                AxisAlignedBox3.h \ 
     561                Ray.h \ 
     562                Containers.h \ 
     563                Intersectable.h \ 
     564                Plane3.h \ 
     565                Matrix4x4.h \ 
    542566                Material.h \ 
    543567                Pvs.h \ 
     
    550574                ViewCell.h \ 
    551575                Mesh.h \ 
     576                Intersectable.h \ 
    552577                MeshKdTree.h \ 
    553578                Triangle3.h \ 
    554                 Intersectable.h \ 
    555                 Containers.h \ 
    556                 AxisAlignedBox3.h \ 
    557                 Pvs.h \ 
    558                 Rectangle3.h \ 
    559                 Matrix4x4.h \ 
    560                 Vector3.h \ 
    561                 Plane3.h \ 
    562                 common.h \ 
    563                 Material.h \ 
    564                 Ray.h \ 
     579                Containers.h \ 
     580                Ray.h \ 
     581                Plane3.h \ 
     582                Matrix4x4.h \ 
     583                AxisAlignedBox3.h \ 
     584                Material.h \ 
     585                Pvs.h \ 
     586                Rectangle3.h \ 
     587                Vector3.h \ 
     588                common.h \ 
    565589                 
    566590 
     
    575599                Ray.h \ 
    576600                AxisAlignedBox3.h \ 
     601                Exporter.h \ 
    577602                Vector3.h \ 
    578603                Containers.h \ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp

    r333 r339  
    44#include "Triangle3.h" 
    55 
    6 int MeshInstance::mailID = 21843194198; 
     6int Intersectable::sMailId = 21843194198; 
    77 
    88void 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Parser.h

    r261 r339  
    1313public: 
    1414  Parser() {} 
    15   virtual bool ParseFile(const string filename, SceneGraphNode **root) = 0; 
     15 
     16        virtual bool ParseFile(const string filename, SceneGraphNode **root) = 0; 
     17         
    1618}; 
    1719 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r331 r339  
    1313{ 
    1414} 
     15 
    1516 
    1617Preprocessor::~Preprocessor() 
     
    4445} 
    4546 
    46 bool Preprocessor::ParseViewCellsOptions() 
     47bool 
     48Preprocessor::ParseViewCellsOptions() 
    4749{ 
    4850        // parse type of view cells 
     
    114116 
    115117  bool result = parser->ParseFile(filename, &mSceneGraph->mRoot); 
    116    
     118 
     119         
     120         
    117121  delete parser; 
    118122 
     123        if (result) 
     124                mSceneGraph->AssignObjectIds(); 
     125         
    119126  return result; 
    120127} 
     
    152159bool 
    153160Preprocessor::Export( const string filename, 
    154                       const bool scene, 
    155                       const bool kdtree, 
    156                           const bool bsptree 
    157                       ) 
     161                                                                                        const bool scene, 
     162                                                                                        const bool kdtree, 
     163                                                                                        const bool bsptree 
     164                                                                                        ) 
    158165{ 
    159166  Exporter *exporter = Exporter::GetExporter(filename); 
    160  
     167         
    161168  if (exporter) { 
    162169    if (scene) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r335 r339  
    2727void 
    2828SamplingPreprocessor::SetupRay(Ray &ray,  
    29                                                           const Vector3 &point,  
    30                                                           const Vector3 &direction, 
    31                                                           const int type) 
     29                                                                                                                        const Vector3 &point,  
     30                                                                                                                        const Vector3 &direction, 
     31                                                                                                                        const int type) 
    3232{ 
    3333  ray.intersections.clear(); 
     
    148148 
    149149int 
    150 SamplingPreprocessor::CastRay(Intersectable *object, Ray &ray) 
     150SamplingPreprocessor::CastRay(Intersectable *object, 
     151                                                                                                                        Ray &ray) 
    151152{ 
    152153        int sampleContributions = 0; 
    153154 
     155        long t1 = GetTime(); 
    154156        // cast ray to KD tree to find intersection with other objects 
    155157        mKdTree->CastRay(ray); 
    156          
     158        long t2 = GetTime(); 
     159 
     160        cout<<object->GetId()<<" "<<TimeDiff(t1, t2); 
     161 
    157162        if (mViewCellsType == BSP_VIEW_CELLS) 
    158         { 
    159                 // cast ray to BSP tree to get intersection with view cells 
    160                 if (mBspTree) 
    161163                { 
    162                         mBspTree->CastRay(ray); 
    163                  
    164                         sampleContributions += AddObjectSamples(object, ray); 
     164                        // cast ray to BSP tree to get intersection with view cells 
     165                        if (mBspTree) 
     166                                { 
     167                                        mBspTree->CastRay(ray); 
     168                                         
     169                                        sampleContributions += AddObjectSamples(object, ray); 
    165170                                 
    166                         if (!ray.intersections.empty()) // second intersection found 
    167                         { 
    168                                 sampleContributions +=  
    169                                         AddObjectSamples(ray.intersections[0].mObject, ray); 
    170                         } 
     171                                        if (!ray.intersections.empty()) // second intersection found 
     172                                                { 
     173                                                        sampleContributions +=  
     174                                                                AddObjectSamples(ray.intersections[0].mObject, ray); 
     175                                                } 
     176                                } 
    171177                } 
    172         } 
    173178        else 
    174         { 
    175                 if (ray.leaves.size()) { 
    176                         sampleContributions += AddNodeSamples(object, ray); 
    177                  
    178                         if (ray.intersections.size()) { 
    179                                 sampleContributions += AddNodeSamples(ray.intersections[0].mObject, ray); 
    180                         } 
    181                 }  
    182         }        
     179                { 
     180                        if (ray.leaves.size()) { 
     181                                sampleContributions += AddNodeSamples(object, ray); 
     182                                 
     183                                if (ray.intersections.size()) { 
     184                                        sampleContributions += AddNodeSamples(ray.intersections[0].mObject, ray); 
     185                                } 
     186                        }  
     187                }        
    183188         
    184189        return sampleContributions; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SceneGraph.cpp

    r260 r339  
    44#include "SceneGraph.h" 
    55#include "X3dExporter.h" 
     6#include "Intersectable.h" 
    67 
    78 
     
    5051  return number; 
    5152} 
     53 
     54 
     55int 
     56SceneGraph::AssignObjectIds() 
     57{ 
     58  int id = 1; 
     59  stack<SceneGraphNode *> nodeStack; 
     60   
     61  nodeStack.push(mRoot); 
     62   
     63  while (!nodeStack.empty()) { 
     64    SceneGraphNode *node = nodeStack.top(); 
     65    nodeStack.pop(); 
     66                 
     67    ObjectContainer::const_iterator mi = node->mGeometry.begin(); 
     68    for (; mi != node->mGeometry.end(); mi++)  
     69      (*mi)->SetId(id++); 
     70     
     71    SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 
     72    for (; ni != node->mChildren.end(); ni++) { 
     73      nodeStack.push(*ni); 
     74    } 
     75  } 
     76        // return max id 
     77  return id; 
     78} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SceneGraph.h

    r176 r339  
    2727   
    2828  int CollectObjects(ObjectContainer *instances); 
    29    
     29 
     30  int 
     31        AssignObjectIds(); 
     32 
    3033protected: 
    3134}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r338 r339  
    11011101        // needed for balanced view cells criterium 
    11021102        ViewCell::NewMail(); 
    1103         int backId = ViewCell::mailID; 
     1103        int backId = ViewCell::sMailId; 
    11041104        ViewCell::NewMail(); 
    1105         int frontId = ViewCell::mailID; 
     1105        int frontId = ViewCell::sMailId; 
    11061106        ViewCell::NewMail(); 
    1107         int frontAndBackId = ViewCell::mailID; 
     1107        int frontAndBackId = ViewCell::sMailId; 
    11081108 
    11091109        PolygonContainer::const_iterator it, it_end = polys.end(); 
     
    11451145                        if (classification == Plane3::FRONT_SIDE) 
    11461146                        { 
    1147                                 if ((viewCell->mailbox != frontId) &&  
    1148                                         (viewCell->mailbox != frontAndBackId)) 
     1147                                if ((viewCell->mMailbox != frontId) &&  
     1148                                        (viewCell->mMailbox != frontAndBackId)) 
    11491149                                { 
    11501150                                        sumBalancedViewCells += 1.0; 
    11511151 
    1152                                         if (viewCell->mailbox != backId) 
    1153                                                 viewCell->mailbox = frontId; 
     1152                                        if (viewCell->mMailbox != backId) 
     1153                                                viewCell->mMailbox = frontId; 
    11541154                                        else 
    1155                                                 viewCell->mailbox = frontAndBackId; 
     1155                                                viewCell->mMailbox = frontAndBackId; 
    11561156                                         
    11571157                                        ++ totalViewCells; 
     
    11601160                        else if (classification == Plane3::BACK_SIDE) 
    11611161                        { 
    1162                                 if ((viewCell->mailbox != backId) && 
    1163                                     (viewCell->mailbox != frontAndBackId)) 
     1162                                if ((viewCell->mMailbox != backId) && 
     1163                                    (viewCell->mMailbox != frontAndBackId)) 
    11641164                                { 
    11651165                                        sumBalancedViewCells -= 1.0; 
    11661166 
    1167                                         if (viewCell->mailbox != frontId) 
    1168                                                 viewCell->mailbox = backId; 
     1167                                        if (viewCell->mMailbox != frontId) 
     1168                                                viewCell->mMailbox = backId; 
    11691169                                        else 
    1170                                                 viewCell->mailbox = frontAndBackId;  
     1170                                                viewCell->mMailbox = frontAndBackId;  
    11711171 
    11721172                                        ++ totalViewCells; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro

    r333 r339  
    1313 
    1414# debuc config 
    15 CONFIG          += console warn_off thread release 
     15CONFIG          += console warn_off thread debug 
    1616 
    1717# RELEASE CONFIG 
Note: See TracChangeset for help on using the changeset viewer.