Changeset 1972


Ignore:
Timestamp:
01/12/07 22:41:01 (17 years ago)
Author:
mattausch
Message:

implemented improved ray casting

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r1971 r1972  
    8585  mUseForcedColors = false; 
    8686  mRenderBoxes = false; 
    87   //mUseGlLists = true; 
    88   mUseGlLists = false; 
     87  mUseGlLists = true; 
     88  //mUseGlLists = false; 
    8989 
    9090  Environment::GetSingleton()->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp

    r1971 r1972  
    456456        const int layers = ApplyDepthPeeling(rays); 
    457457 
    458         const float rays_per_sec = rays.size() / TimeDiff(startTime, GetTime()) * 1e-3; 
    459         cout << "cast " << rays.size() << " samples in " << layers << " layers in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs (" << rays_per_sec << " rays/sec)" << endl; 
     458        const float rays_per_sec = (float)rays.size() / (TimeDiff(startTime, GetTime()) * 1e-3f); 
     459        cout << "cast " << rays.size() << " samples in " << layers << " layers in "  
     460                 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs (" << rays_per_sec << " rays/sec)" << endl; 
     461 
    460462        return layers; 
    461463} 
     
    852854void GlobalLinesRenderer::Visualize(const VssRayContainer &vssRays) 
    853855{ 
     856        cout << "exporting visualization ... "; 
    854857        Exporter *exporter = Exporter::GetExporter("globalLines.wrl"); 
    855858         
     
    877880                } 
    878881 
    879                 if (ray->mPass == 4) 
     882                //if (ray->mPass == 4) 
    880883                        outRays.push_back(ray); 
    881884        }        
    882885 
    883         exporter->ExportRays(outRays); 
    884  
     886        //exporter->ExportRays(outRays); 
     887        cout << "finished" << endl; 
    885888        delete exporter; 
    886889} 
     
    10301033        } 
    10311034 
    1032         Debug << "time spent in rendering: " << renderTime << endl; 
    1033         Debug << "time spent in buffer: " << bufferTime << endl; 
     1035        Debug << "time spent in rendering: " << renderTime * 1e-3f << endl; 
     1036        Debug << "time spent in buffer: " << bufferTime * 1e-3f << endl; 
    10341037         
    10351038        PrintGLerror("endpeeling"); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp

    r1960 r1972  
    107107 
    108108void IntelRayCaster::CastRays16( 
    109                                                                 const int index, 
    110109                                                                SimpleRayContainer &rays,  
    111110                                                                VssRayContainer &vssRays, 
     
    116115        int i; 
    117116        const int num = 16; 
    118  
     117         
    119118#if DEBUG_RAYCAST 
    120119        Debug<<"C16 "<<flush; 
     
    132131 
    133132        for (i=0; i < num; i++) { 
    134           mlrtaStoreRayAS16(&rays[index + i].mOrigin.x, 
    135                                                 &rays[index + i].mDirection.x, 
     133          mlrtaStoreRayAS16(&rays[i].mOrigin.x, 
     134                                                &rays[i].mDirection.x, 
    136135                                                i); 
    137136        } 
     
    150149                for (i=0; i < num; i++)  
    151150                  { 
    152                         Vector3 dir = -rays[index + i].mDirection; 
    153                         mlrtaStoreRayAS16(&rays[index+i].mOrigin.x, 
     151                        Vector3 dir = -rays[i].mDirection; 
     152                        mlrtaStoreRayAS16(&rays[i].mOrigin.x, 
    154153                                                          &dir.x, 
    155154                                                          i); 
     
    186185 
    187186                        //-rays[index+i].mDirection; // $$ temporary 
    188                         hitA.mPoint = rays[index+i].Extrap(forward_dist[i]); 
     187                        hitA.mPoint = rays[i].Extrap(forward_dist[i]); 
    189188                } 
    190189         
     
    202201                                hitB.mNormal = mPreprocessor.GetParentNormal(backward_hit_triangles[i]); 
    203202 
    204                                 // normalB = rays[index+i].mDirection; // $$ temporary 
    205                                 hitB.mPoint = rays[index+i].Extrap(-backward_dist[i]); 
     203                                // normalB = rays[i].mDirection; // $$ temporary 
     204                                hitB.mPoint = rays[i].Extrap(-backward_dist[i]); 
    206205                        } 
    207206                } 
     
    211210#endif 
    212211 
    213                 ProcessRay(rays[index + i], 
     212                ProcessRay(rays[i], 
    214213                                   hitA, 
    215214                                   hitB, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h

    r1925 r1972  
    4444                                                const bool pruneInvalidRays = true); 
    4545 
    46         virtual void CastRays16(const int i, 
     46        virtual void CastRays16( 
    4747                                                        SimpleRayContainer &rays,  
    4848                                                        VssRayContainer &vssRays, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp

    r1964 r1972  
    192192} 
    193193 
    194 void InternalRayCaster::CastRays16(const int index, 
    195                                                                    SimpleRayContainer &rays,  
     194 
     195void InternalRayCaster::CastRays16(SimpleRayContainer &rays,  
    196196                                                                   VssRayContainer &vssRays, 
    197197                                                                   const AxisAlignedBox3 &sbox, 
     
    199199                                                                   const bool pruneInvalidRays) 
    200200{ 
    201         const int num = 16; 
    202  
    203201#if DEBUG_RAYCAST 
    204202        Debug << "C16 " << flush; 
    205203#endif 
    206204 
     205        SimpleRayContainer::const_iterator sit, sit_end = rays.end(); 
     206 
    207207        // no acceleration for ray bundles implemented right now 
    208         for (int i = index; i < index + num; i++)  
     208        for (sit = rays.begin(); sit != sit_end; ++ sit)  
    209209        { 
    210                 CastRay(rays[i], vssRays, sbox, castDoubleRays, pruneInvalidRays); 
     210                CastRay(*sit, vssRays, sbox, castDoubleRays, pruneInvalidRays); 
    211211        } 
    212212 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h

    r1824 r1972  
    3636 
    3737        virtual int CastRay( 
    38         const SimpleRay &simpleRay, 
    39         VssRayContainer &vssRays, 
    40                 const AxisAlignedBox3 &box, 
    41                 const bool castDoubleRay, 
    42                 const bool pruneInvalidRays = true 
    43                 ); 
     38                                                const SimpleRay &simpleRay, 
     39                                                VssRayContainer &vssRays, 
     40                                                const AxisAlignedBox3 &box, 
     41                                                const bool castDoubleRay, 
     42                                                const bool pruneInvalidRays = true 
     43                                                ); 
    4444 
    45          virtual void CastRays16( 
    46                  const int i, 
    47                  SimpleRayContainer &rays,  
    48                  VssRayContainer &vssRays, 
    49                  const AxisAlignedBox3 &sbox, 
    50                  const bool castDoubleRay, 
    51                  const bool pruneInvalidRays = true 
    52                  ); 
     45         virtual void CastRays16(SimpleRayContainer &rays,  
     46                                                         VssRayContainer &vssRays, 
     47                                                         const AxisAlignedBox3 &sbox, 
     48                                                         const bool castDoubleRay, 
     49                                                         const bool pruneInvalidRays = true 
     50                                                         ); 
    5351 
    5452        virtual int 
    55         CastGlobalRay(const SimpleRay &simpleRay, 
    56                                                                 VssRayContainer &vssRays, 
    57                                                                 const AxisAlignedBox3 &box, 
    58                                                                 const bool pruneInvalidRays 
    59                                                                 ); 
     53        CastGlobalRay( 
     54                                  const SimpleRay &simpleRay, 
     55                                  VssRayContainer &vssRays, 
     56                                  const AxisAlignedBox3 &box, 
     57                                  const bool pruneInvalidRays 
     58                                  ); 
    6059 
    6160protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp

    r1876 r1972  
    6464                pch = strtok(NULL, " "); 
    6565        } 
    66         //if (indices.size() > 4) return NULL; 
    6766 
    6867        return new Face(indices);  
     
    7069 
    7170 
    72 static Triangle3 LoadTriangle(char *str,  
    73                                                           const VertexContainer &vertices,  
    74                                                           map<int, Vector3> &hashTable) 
     71static void LoadTriangles(char *str,  
     72                                                  const VertexContainer &vertices,  
     73                                                  map<int, Vector3> &hashTable, 
     74                          vector<Triangle3> &triangles) 
    7575{ 
    7676        char *pch = strtok(str + 1, " "); 
     
    7878        VertexIndexContainer indices; 
    7979         
     80        int i = 0; 
    8081        while (pch != NULL) 
    8182        { 
    8283                const int index = (int)strtol(pch, NULL, 10) - 1; 
     84                ++ i; 
    8385                                 
    8486                // store vertex in hash table 
    85                 hashTable[index] = vertices[index]; 
     87                //hashTable[index] = vertices[index]; 
    8688                indices.push_back(index); 
    8789                 
    8890                pch = strtok(NULL, " "); 
    89         } 
    90          
    91     return Triangle3(vertices[indices[0]], vertices[indices[1]], vertices[indices[2]]);  
     91 
     92                // problem: don't know how intel ray tracer tesselates 
     93                if ((int)indices.size() > 2) 
     94                { 
     95                        int index_2 = (int)indices.size() - 2; 
     96                        int index_3 = (int)indices.size() - 1; 
     97 
     98                        triangles.push_back(Triangle3(vertices[indices[0]],  
     99                                                                                  vertices[indices[index_2]],  
     100                                                                                  vertices[indices[index_3]]));  
     101                } 
     102        } 
    92103} 
    93104 
     
    230241                                else 
    231242                                { 
    232                                         Triangle3 triangle = LoadTriangle(str, vertices, hashTable); 
     243                                        vector<Triangle3> triangles; 
     244                                         
     245                                        LoadTriangles(str, vertices, hashTable, triangles); 
    233246                                 
    234                                         TriangleIntersectable *obj = new TriangleIntersectable(triangle); 
    235                                         root->mGeometry.push_back(obj); 
    236  
    237                                         // matt: we don't really need to keep an additional data structure 
    238                                         // if working with triangles => remove this 
    239                                         if (parents)  
     247                                        vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 
     248 
     249                                        for (tit = triangles.begin(); tit != tit_end; ++ tit) 
    240250                                        { 
    241                                                 FaceParentInfo info(obj, 0); 
    242                                                 parents->push_back(info); 
     251                                                TriangleIntersectable *obj = new TriangleIntersectable(*tit);    
     252                                                root->mGeometry.push_back(obj); 
     253 
     254                                                // matt: we don't really need to keep an additional data structure 
     255                                                // if working with triangles => remove this 
     256                                                if (0 && parents)  
     257                                                { 
     258                                                        FaceParentInfo info(obj, 0); 
     259                                                        parents->push_back(info); 
     260                                                } 
    243261                                        } 
    244262                                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1970 r1972  
    11511151        const long t1 = GetTime(); 
    11521152 
    1153         for (int i = 0; i < (int)rays.size();) 
    1154         { 
    1155                 // HACK: does not really go together with the 16 ray bundles 
    1156                 if (rays[i].mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION) 
    1157                 { 
    1158                         mGlobalLinesRenderer->CastGlobalLines(rays[i], vssRays); 
    1159                         i ++; 
     1153        SimpleRayContainer::const_iterator rit, rit_end = rays.end(); 
     1154 
     1155        SimpleRayContainer rayBucket; 
     1156        int i = 0; 
     1157        for (rit = rays.begin(); rit != rit_end; ++ rit, ++ i) 
     1158        { 
     1159                SimpleRay ray = *rit; 
     1160                // HACK: global lines must be treated special 
     1161                if (ray.mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION) 
     1162                { 
     1163                        mGlobalLinesRenderer->CastGlobalLines(ray, vssRays); 
    11601164                        continue; 
    11611165                } 
    11621166 
    1163                 if (i + 16 < (int)rays.size())  
     1167                rayBucket.push_back(ray); 
     1168 
     1169                // 16 rays gathered => do ray casting 
     1170                if ((int)rayBucket.size() >= 16) 
    11641171                { 
    11651172                        mRayCaster->CastRays16( 
    1166                                                                    i, 
    1167                                                                    rays,                                 
     1173                                                                   rayBucket,                            
    11681174                                                                   vssRays, 
    11691175                                                                   mViewCellsManager->GetViewSpaceBox(), 
    11701176                                                                   castDoubleRays, 
    11711177                                                                   pruneInvalidRays); 
    1172                         i += 16; 
    1173                 } 
    1174                 else  
     1178 
     1179                        rayBucket.clear(); 
     1180                } 
     1181         
     1182                if ((int)rays.size() > 10000 && i % 10000 == 0) 
     1183                        cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 
     1184        } 
     1185     
     1186        // cast rest of rays 
     1187        SimpleRayContainer::const_iterator sit, sit_end = rayBucket.end(); 
     1188 
     1189        for (sit = rayBucket.begin(); sit != sit_end; ++ sit) 
     1190        { 
     1191                SimpleRay ray = *sit; 
     1192                // HACK: global lines must be treated special 
     1193                if (ray.mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION) 
     1194                { 
     1195                        mGlobalLinesRenderer->CastGlobalLines(ray, vssRays); 
     1196                } 
     1197                else 
    11751198                { 
    11761199                        mRayCaster->CastRay( 
    1177                                                                 rays[i], 
     1200                                                                ray, 
    11781201                                                                vssRays, 
    11791202                                                                mViewCellsManager->GetViewSpaceBox(), 
    11801203                                                                castDoubleRays, 
    11811204                                                                pruneInvalidRays); 
    1182                         ++ i; 
    1183                 } 
    1184  
    1185                 if (rays.size() > 10000 && i % 10000 == 0) 
    1186                   cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 
    1187         } 
    1188  
    1189         if (rays.size() > 10000)  
     1205                } 
     1206        } 
     1207 
     1208        if ((int)rays.size() > 10000)  
    11901209        { 
    11911210                cout << endl; 
    1192  
    1193                 long t2 = GetTime(); 
     1211        long t2 = GetTime(); 
    11941212 
    11951213#if SHOW_RAYCAST_TIMING 
    11961214                if (castDoubleRays) 
    1197             cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 
     1215                        cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 
    11981216                else 
    11991217                        cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r1969 r1972  
    183183   
    184184  lastPos = event->pos(); 
    185 updateGL(); 
     185  updateGL(); 
    186186} 
    187187 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h

    r1942 r1972  
    4545        VssRay *CastRay(const SimpleRay &simpleRay, 
    4646                                        const AxisAlignedBox3 &box); 
    47                                         //const bool castDoubleRay); 
    4847 
    4948        virtual int CastRay(const SimpleRay &simpleRay, 
     
    5453                                                ) = 0; 
    5554 
    56          virtual void CastRays16(const int i, 
     55         virtual void CastRays16( 
    5756                                                         SimpleRayContainer &rays, 
    5857                                                         VssRayContainer &vssRays, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r1949 r1972  
    194194                                OptimizeForWindowsApplication="TRUE" 
    195195                                AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(QTDIR)\include\Qt&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include&quot;;QtInterface" 
    196                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT;TRY_GLOBAL_LINES" 
     196                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL;USE_QT" 
    197197                                RuntimeLibrary="2" 
    198198                                RuntimeTypeInfo="TRUE" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1966 r1972  
    58295829 
    58305830                const long starttime = GetTime(); 
    5831                 cout << "exporting final view cells (after initial construction + post process) ... "; 
     5831                cout << "exporting final view cells (after initial construction + post process) ... " << endl; 
    58325832 
    58335833                // matt: hack for clamping scene 
     
    58355835                bbox.Scale(scale); 
    58365836 
    5837                 if (0 && mExportRays) 
     5837                if (1 && mExportRays) 
    58385838                {        
    58395839                        exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 
Note: See TracChangeset for help on using the changeset viewer.