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

implemented improved ray casting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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; 
Note: See TracChangeset for help on using the changeset viewer.