Changeset 2690


Ignore:
Timestamp:
05/20/08 17:15:44 (16 years ago)
Author:
mattausch
Message:

strange errors!!

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2689 r2690  
    1717VIEWPOINTS=../data/vienna/testwalk.vp 
    1818 
    19 LOG_PREFIX=../src/SG08/testwalk_cropped 
     19LOG_PREFIX=../src/SG08/try 
    2020#LOG_PREFIX=../src/SG08/city_full_100 
    2121 
     
    3030-scene_filename=$SCENE \ 
    3131-preprocessor=gvs \ 
    32 -preprocessor_use_vbos+ \ 
     32-preprocessor_use_vbos- \ 
    3333-gvs_epsilon=0.0001 \ 
    3434-gvs_total_samples=1000000 \ 
     
    3636-gvs_initial_samples=16 \ 
    3737-gvs_max_viewcells=1 \ 
    38 -gvs_min_contribution=100 \ 
     38-gvs_min_contribution=1500 \ 
    3939-gvs_per_viewcell=true \ 
    4040-gvs_stats=$LOG_PREFIX-gvsStats.log \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2689 r2690  
    667667         
    668668        //glFinish(); 
    669 #if 0 
    670         //-- now issue queries for all objects 
    671         for (int j = 0; j < (int)mObjects.size(); ++ j)  
    672         { 
    673                 mOcclusionQueries[j]->BeginQuery(); 
    674                 RenderIntersectable(mObjects[j]); 
    675                 mOcclusionQueries[j]->EndQuery(); 
    676  
    677                 unsigned int pixelCount; 
    678  
    679                 pixelCount = mOcclusionQueries[j]->GetQueryResult(); 
    680                  
    681                 mObjects[j]->mCounter += pixelCount; 
    682         } 
    683 #else 
    684  
    685669        int q = 0; 
    686670 
     
    703687                 
    704688                        //-- reenable other state 
    705 #if 0 
    706                         bool available; 
    707  
    708                         do  
    709                         { 
    710                                 available = mOcclusionQueries[t]->ResultAvailable(); 
    711                                  
    712                                 if (!available) cout << "W"; 
    713                         }  
    714                         while (!available); 
    715 #endif 
    716689 
    717690                        pixelCount = mOcclusionQueries[t]->GetQueryResult(); 
     
    722695                 
    723696                } 
    724  
    725                 //j += q; 
    726         } 
    727 #endif 
     697        } 
     698 
    728699        //glFinish(); 
    729700        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     
    873844 
    874845 
    875  
    876  
    877 void 
    878 GlRendererBuffer::EvalRenderCostSample(RenderCostSample &sample, 
    879                                                                            const bool useOcclusionQueries, 
    880                                                                            const int threshold 
    881                                                                            ) 
     846void GlRendererBuffer::EvalRenderCostSample(RenderCostSample &sample, 
     847                                                                                        const bool useOcclusionQueries, 
     848                                                                                        const int threshold) 
    882849{ 
    883850        // choose a random view point 
     
    902869 
    903870        for (it = mObjects.begin(); it != it_end; ++ it)  
    904         { 
    905871                (*it)->mCounter = 0; 
    906  
    907         } 
    908872 
    909873        ++ mFrame; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2689 r2690  
    152152#endif 
    153153        { 
    154                 //cout << "r"; 
    155154                // apply reverse sampling to find the gap 
    156155                VssRay *newRay = ReverseSampling(currentRay, hitTriangle, oldRay); 
     
    160159 
    161160                // set flag for visualization 
    162                 //newRay->mFlags |= VssRay::ReverseSample; 
     161                if (0) newRay->mFlags |= VssRay::ReverseSample; 
    163162                 
    164163                // check if ray is not further processed (ray not deleted because using ray pool) 
     
    185184void GvsPreprocessor::UpdateStatsForVisualization(KdIntersectable *kdInt) 
    186185{ 
    187         mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
     186        //mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
    188187 
    189188        // count new objects in pvs due to kd node conversion    
     
    222221 
    223222                // counter < 2 => not accounted for yet 
    224                 if (obj->mCounter < ACCOUNTED_OBJECT) 
     223                        // test of triangle was accounted for yet 
     224                if (result = AddTriangleObject(obj)) 
    225225                { 
    226                         obj->mCounter += ACCOUNTED_OBJECT; 
    227                         mTrianglePvs.push_back(obj); 
    228                  
    229                         mGenericStats = (int)mTrianglePvs.size(); 
    230  
    231226                        // exchange the triangle with the node in the pvs for kd pvs 
    232227                        if (mUseKdPvs) 
     
    664659 
    665660        while (!mRayQueue.empty())//&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) ) 
    666         {//cout<<"r"; 
    667                 //cout << "queue size: " << mRayQueue.size() << endl; 
     661        { 
    668662                // handle next ray 
    669663                VssRay *ray = mRayQueue.top(); 
     
    794788 
    795789 
    796 void GvsPreprocessor::ProcessViewCell() 
    797 { 
    798         // compute object that directly intersect view cell 
    799         IntersectWithViewCell(); 
    800  
    801         mGvsStats.mPerViewCellSamples = 0; 
    802  
    803         int oldContribution = mGvsStats.mTotalContribution; 
    804         int passSamples = 0; 
    805  
    806         mGenericStats = 0; 
    807         mGenericStats2 = 0; 
    808  
    809         while (1) 
    810         { 
    811                 mRayCaster->InitPass(); 
    812  
    813                 // Ray queue empty =>  
    814                 // cast a number of uniform samples to fill ray queue 
    815                 int newSamples = CastInitialSamples(mInitialSamples, mSamplingType); 
    816  
    817                 if (!mOnlyRandomSampling) 
    818                 { 
    819                         int samplesPerRun = ProcessQueue(); 
    820                         newSamples += samplesPerRun; 
    821                         //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " "; 
    822                 } 
    823  
    824                 passSamples += newSamples; 
    825         mGvsStats.mPerViewCellSamples += newSamples; 
    826  
    827                 if (passSamples >= mGvsSamplesPerPass) 
    828                 { 
    829                         ++ mPass; 
    830                         mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 
    831  
    832                         //////// 
    833                         //-- stats 
    834  
    835                         mGvsStats.mPass = mPass; 
    836  
    837                         cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl; 
    838                         cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl; 
    839  
    840                         //mGenericStats = mGvsStats.mPassContribution; 
    841  
    842                         // termination criterium 
    843                         if (mGvsStats.mPassContribution < mMinContribution) 
    844                                 break; 
    845  
    846                         // reset 
    847                         oldContribution = mGvsStats.mTotalContribution; 
    848                         mGvsStats.mPassContribution = 0; 
    849                         passSamples = 0; 
    850                 } 
    851         } 
    852 } 
    853  
    854  
    855790void GvsPreprocessor::CompileViewCellsFromPointList() 
    856791{ 
     
    945880} 
    946881 
    947 #if 0 
     882#if 1 
    948883void GvsPreprocessor::IntersectWithViewCell() 
    949884{ 
     
    10661001void GvsPreprocessor::PerViewCellComputation() 
    10671002{ 
    1068         ViewCell *vc; 
    1069  
    1070         while (vc = NextViewCell()) 
     1003        while (mCurrentViewCell = NextViewCell()) 
    10711004        { 
    10721005                // hack: reset counters 
     
    10761009                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 
    10771010 
    1078         ComputeViewCell(vc); 
     1011        ComputeViewCell(); 
    10791012        } 
    10801013} 
     
    10881021                        continue; 
    10891022 
    1090         ViewCell *vc = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint()); 
     1023        mCurrentViewCell = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint()); 
    10911024 
    10921025                // no valid view cell or view cell already computed 
    1093                 if (!vc || !vc->GetPvs().Empty() || !mRendererWidget->mComputeGVS) 
     1026                if (!mCurrentViewCell || !mCurrentViewCell->GetPvs().Empty() || !mRendererWidget->mComputeGVS) 
    10941027                        continue; 
    10951028 
     
    11011034                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 
    11021035 
    1103                 ComputeViewCell(vc); 
     1036                ComputeViewCell(); 
    11041037                ++ mProcessedViewCells; 
    11051038        } 
     
    13221255        app << "#Id\n" << mViewCellId << endl; 
    13231256        app << "#Time\n" << mTimePerViewCell << endl;; 
    1324         app << "#TriaePvs\n" << mTrianglePvs << endl; 
     1257        app << "#TriPvs\n" << mTrianglePvs << endl; 
    13251258        app << "#ObjectPvs\n" << mPerViewCellPvs << endl; 
    13261259        app << "#UpdatedPvs\n" << (int)mPvsCost << endl; 
     
    13511284 
    13521285 
    1353 void GvsPreprocessor::ComputeViewCell(ViewCell *vc) 
     1286void GvsPreprocessor::ComputeViewCell() 
    13541287{ 
    13551288        KdNode::NewMail(); 
    13561289 
    1357         mCurrentViewCell = vc; 
    1358          
    13591290        const long startTime = GetTime(); 
    13601291 
     
    13641295 
    13651296        // compute the pvs of the current view cell 
    1366         ProcessViewCell(); 
    1367  
    1368          
     1297        // compute object that directly intersect view cell 
     1298        //IntersectWithViewCell(); 
     1299 
     1300        mGvsStats.mPerViewCellSamples = 0; 
     1301 
     1302        int oldContribution = mGvsStats.mTotalContribution; 
     1303        int passSamples = 0; 
     1304 
     1305        mGenericStats = 0; 
     1306        mGenericStats2 = 0; 
     1307 
     1308        while (1) 
     1309        { 
     1310                int oldPvsSize = 0;//mCurrentViewCell->GetPvs().GetSize(); 
     1311 
     1312                mRayCaster->InitPass(); 
     1313 
     1314                // Ray queue empty =>  
     1315                // cast a number of uniform samples to fill ray queue 
     1316                int newSamples = CastInitialSamples(mInitialSamples, mSamplingType); 
     1317 
     1318                if (!mOnlyRandomSampling) 
     1319                { 
     1320                        int samplesPerRun = ProcessQueue(); 
     1321                        newSamples += samplesPerRun; 
     1322                        //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " "; 
     1323                } 
     1324 
     1325                passSamples += newSamples; 
     1326        mGvsStats.mPerViewCellSamples += newSamples; 
     1327 
     1328                if (passSamples >= mGvsSamplesPerPass) 
     1329                { 
     1330                        if (GVS_DEBUG) VisualizeViewCell(mTrianglePvs); 
     1331 
     1332                        const bool convertPerPass = false; 
     1333 
     1334                        if (convertPerPass) 
     1335                        {        
     1336                                int newObjects = ConvertObjectPvs(); 
     1337 
     1338                                cout << "added " << newObjects << " triangles to triangle pvs" << endl; 
     1339                                mGvsStats.mTotalContribution += newObjects; 
     1340                        } 
     1341 
     1342                        ++ mPass; 
     1343                        mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 
     1344 
     1345 
     1346                        //////// 
     1347                        //-- stats 
     1348 
     1349                        mGvsStats.mPass = mPass; 
     1350 
     1351                        cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl; 
     1352                        cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl; 
     1353                        cout << "obj contri=" << mCurrentViewCell->GetPvs().GetSize() - oldPvsSize << " (of " << mMinContribution << ")" << endl; 
     1354 
     1355                        // termination criterium 
     1356                        if (mGvsStats.mPassContribution < mMinContribution) 
     1357                                break; 
     1358 
     1359                        // reset 
     1360                        oldContribution = mGvsStats.mTotalContribution; 
     1361                        mGvsStats.mPassContribution = 0; 
     1362                        passSamples = 0; 
     1363                } 
     1364        } 
     1365         
     1366        // finally add objects that directly intersect the view cell 
     1367        //IntersectWithViewCell(); 
     1368 
     1369                 
    13691370        //////// 
    13701371        //-- stats 
    13711372 
     1373        // timing 
     1374        mGvsStats.mTimePerViewCell = TimeDiff(startTime, GetTime()) * 1e-3f; 
     1375 
     1376        ComputeStats(); 
     1377 
     1378        // clean up 
     1379        mTrianglePvs.clear(); 
     1380} 
     1381 
     1382 
     1383void GvsPreprocessor::ComputeStats() 
     1384{ 
    13721385        // compute pvs size using larger (bvh objects) 
    13731386        // note: for kd pvs we had to do this during gvs computation 
     
    14021415 
    14031416        mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 
    1404          
    1405         // timing 
    1406         const long currentTime = GetTime(); 
    1407         mGvsStats.mTimePerViewCell = TimeDiff(startTime, currentTime) * 1e-3f; 
    14081417 
    14091418 
     
    14111420        // global values 
    14121421 
    1413         mGvsStats.mViewCells = mProcessedViewCells;//mPass; 
     1422        mGvsStats.mViewCells = mProcessedViewCells; 
    14141423        mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 
    14151424        mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 
     
    14211430 
    14221431        cout << "id: " << mCurrentViewCell->GetId() << " pvs cost: "  
    1423          << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl; 
    1424  
    1425  
    1426         mTrianglePvs.clear(); 
    1427 } 
    1428  
    1429 } 
     1432             << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl; 
     1433} 
     1434 
     1435 
     1436ObjectContainer triangles; 
     1437 
     1438int GvsPreprocessor::ConvertObjectPvs() 
     1439{ 
     1440        int newObjects = 0; 
     1441 
     1442        ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator(); 
     1443 
     1444        triangles.clear(); 
     1445 
     1446        // output PVS of view cell 
     1447        while (pit.HasMoreEntries()) 
     1448        {                
     1449                KdIntersectable *kdInt = static_cast<KdIntersectable *>(pit.Next()); 
     1450 
     1451                mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), triangles); 
     1452 
     1453                ObjectContainer::const_iterator oit, oit_end = triangles.end(); 
     1454 
     1455                for (oit = triangles.begin(); oit != oit_end; ++ oit) 
     1456                { 
     1457                        if (AddTriangleObject(*oit)) 
     1458                                ++ newObjects; 
     1459                } 
     1460        } 
     1461 
     1462        return newObjects; 
     1463} 
     1464 
     1465 
     1466bool GvsPreprocessor::AddTriangleObject(Intersectable *triObj) 
     1467{ 
     1468        if ((triObj->mCounter < ACCOUNTED_OBJECT)) 
     1469        { 
     1470                triObj->mCounter += ACCOUNTED_OBJECT; 
     1471 
     1472                mTrianglePvs.push_back(triObj); 
     1473                mGenericStats = (int)mTrianglePvs.size(); 
     1474                return true; 
     1475        } 
     1476 
     1477        return false; 
     1478} 
     1479 
     1480} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2687 r2690  
    231231        void StorePvs(const ObjectContainer &objectPvs); 
    232232 
    233         /** Compute visibility for a given view cell. 
    234         */ 
    235         void ComputeViewCell(ViewCell *vc); 
    236         /** Runs gvs on the current view cell. 
    237         */ 
    238         void ProcessViewCell(); 
     233        /** Compute visibility for the current view cell using gvs 
     234        */ 
     235        void ComputeViewCell(); 
    239236        /** Use this for qt visualization. 
    240237        */ 
     
    245242 
    246243        void CompileViewCellsFromPointList(); 
     244 
     245        bool AddTriangleObject(Intersectable *triObj); 
     246 
     247        void ComputeStats(); 
     248 
     249        int ConvertObjectPvs(); 
    247250 
    248251 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r2677 r2690  
    11551155 
    11561156 
    1157 void KdTree::CollectObjectsWithoutMail(KdNode *n, ObjectContainer &objects) 
     1157void KdTree::CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) 
    11581158{ 
    11591159        stack<KdNode *> nodeStack; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r2670 r2690  
    403403  void 
    404404  CollectObjects(KdNode *n, ObjectContainer &objects); 
    405 void 
    406 CollectObjectsWithoutMail(KdNode *n, ObjectContainer &objects); 
    407   void 
    408   CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 
     405   
     406  /** Collects objects with dublicates (no mailing going on) 
     407  */ 
     408  void CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects); 
     409  void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 
    409410 
    410411  void 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2678 r2690  
    23732373 
    23742374 
    2375 void ViewCellsManager::UpdateStatsForViewCell(ViewCell *vc, Intersectable *obj) 
    2376 { 
     2375void ViewCellsManager::UpdateStatsForViewCell(ViewCell *vc, Intersectable *obj, int numTriangles) 
     2376{ 
     2377#ifdef USE_VERBOSE_PVS 
    23772378        KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj); 
    23782379 
     
    23992400 
    24002401        //cout << "x " << radius << " " << dist << " " << fullRadius << " " << f << " " << f * f << endl; 
    2401  
    2402         const int numTriangles = kdObj->ComputeNumTriangles(); 
    2403 #ifdef USE_VERBOSE_PVS 
     2402        //const int numTriangles = kdObj->ComputeNumTriangles(); 
     2403 
    24042404        vc->GetPvs().mStats.mDistanceWeightedTriangles += f * numTriangles;  
    24052405        vc->GetPvs().mStats.mDistanceWeightedPvs += f ; 
     
    24272427        bool hasAbsContribution; 
    24282428 
    2429         // todo: maybe not correct for kd node pvs 
     2429        // todo: probably not correct for kd node pvs 
    24302430        if (addSamplesToPvs)  
    24312431        { 
     
    24332433                //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 
    24342434                 
    2435                 if (hasAbsContribution) 
    2436                 { 
    2437                         UpdateStatsForViewCell(viewCell, obj); 
    2438                 } 
     2435                //if (hasAbsContribution)       UpdateStatsForViewCell(viewCell, obj); 
     2436                 
    24392437        } 
    24402438        else  
     
    61956193                const int colorCode = 0; 
    61966194 
    6197                 const float maxRenderCost = -1;//UpdateObjectCosts(); 
     6195                const float maxRenderCost = -1; 
    61986196                const bool exportBounds = false; 
    61996197 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2638 r2690  
    584584 
    585585 
    586         void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj); 
     586        void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj, int numTriangles); 
    587587 
    588588 
Note: See TracChangeset for help on using the changeset viewer.