Ignore:
Timestamp:
11/02/06 19:09:30 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1708 r1709  
    296296        int stype; 
    297297         
     298        const int numStrategies = 3; 
     299 
    298300        stype = SamplingStrategy::OBJECT_BASED_DISTRIBUTION; 
    299         mPreprocessor->GenerateRays(samplesPerPass / 4, sampleType, simpleRays); 
     301        mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 
    300302         
    301303        stype = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 
    302         mPreprocessor->GenerateRays(samplesPerPass / 4, sampleType, simpleRays); 
    303          
    304         stype = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 
    305         mPreprocessor->GenerateRays(samplesPerPass / 4, sampleType, simpleRays); 
     304        mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 
     305         
     306        if (0) 
     307        { 
     308                stype = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 
     309                mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 
     310        } 
    306311 
    307312        stype = SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION; 
    308         mPreprocessor->GenerateRays(samplesPerPass / 4, sampleType, simpleRays); 
     313        mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 
    309314 
    310315        cout << "generated " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    516521        if (mEvaluateViewCells) 
    517522        { 
    518 cout << "here42 ***********" << endl; 
    519523                EvalViewCellPartition(); 
    520524        } 
     
    794798        mViewCellsTree->CollectBestViewCellSet(viewCells, nViewCells); 
    795799 
    796         int maxPvs, maxVal, minVal; 
     800        float maxPvs, maxVal, minVal; 
    797801 
    798802        // sort by pvs size 
    799803        sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 
    800804 
    801         maxPvs = mViewCellsTree->GetPvsSize(viewCells.back()); 
     805        maxPvs = mViewCellsTree->GetPvsCost(viewCells.back()); 
    802806        minVal = 0; 
    803807 
     
    805809        int histoMaxVal; 
    806810        Environment::GetSingleton()->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal); 
    807         maxVal = max(histoMaxVal, maxPvs); 
     811        maxVal = max((float)histoMaxVal, maxPvs); 
    808812                 
    809813        Debug << "histogram minpvssize: " << minVal << " maxpvssize: " << maxVal  
     
    814818        const int intervals = min(histoIntervals, (int)viewCells.size()); 
    815819 
    816         const int range = maxVal - minVal; 
    817         int stepSize = range / intervals; 
     820        const float range = maxVal - minVal; 
     821        int stepSize = (int)(range / intervals); 
    818822 
    819823        // set step size to avoid endless loop 
     
    825829        const float totalVol = GetViewSpaceBox().GetVolume(); 
    826830 
    827         int currentPvs = minVal;//(int)ceil(minRenderCost); 
     831        float currentPvs = minVal; 
    828832         
    829833        int i = 0; 
     
    840844 
    841845                while ((i < (int)viewCells.size()) &&  
    842                            (mViewCellsTree->GetPvsSize(viewCells[i]) < currentPvs)) 
     846                           (mViewCellsTree->GetPvsCost(viewCells[i]) < currentPvs)) 
    843847                { 
    844848                        volDif += viewCells[i]->GetVolume(); 
     
    851855                 
    852856                if (0 && (i < (int)viewCells.size())) 
    853                         Debug << "new pvs size increase: " << mViewCellsTree->GetPvsSize(viewCells[i])  
     857                        Debug << "new pvs cost increase: " << mViewCellsTree->GetPvsCost(viewCells[i])  
    854858                        << " " << currentPvs << endl; 
    855859         
     
    864868                outstream << "#VolumeSum\n" << volRatioSum << endl << endl; 
    865869         
    866                 //if ((i >= (int)viewCells.size()) || (currentPvs >= maxPvs))   break; 
    867  
    868870                //-- increase current pvs size to define next interval 
    869871                currentPvs += stepSize; 
     
    10091011                        ObjectPvs pvs; 
    10101012 
    1011                         cout << "updating pvs for contribution ... " << endl; 
     1013                        cout << "updating pvs for evaluation ... " << endl; 
    10121014 
    10131015                        UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 
     
    14991501                                                                                                float &deviation, 
    15001502                                                                                                float &variance, 
    1501                                                                                                 int &totalPvs, 
     1503                                                                                                float &totalCost, 
    15021504                                                                                                float &avgRenderCost) 
    15031505{ 
     
    15061508 
    15071509        totalRenderCost = 0; 
    1508         totalPvs = 0; 
     1510        totalCost = 0; 
    15091511 
    15101512        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     
    15141516                ViewCell *vc = *it; 
    15151517                totalRenderCost += vc->GetPvs().EvalPvsCost() * vc->GetVolume(); 
    1516                 totalPvs += (int)vc->GetPvs().EvalPvsCost(); 
     1518                totalCost += (int)vc->GetPvs().EvalPvsCost(); 
    15171519        } 
    15181520 
     
    15201522        totalRenderCost /= mViewSpaceBox.GetVolume(); 
    15211523        expectedRenderCost = totalRenderCost / (float)mViewCells.size(); 
    1522         avgRenderCost = totalPvs / (float)mViewCells.size(); 
     1524        avgRenderCost = totalCost / (float)mViewCells.size(); 
    15231525 
    15241526 
     
    17441746void ViewCellsManager::GetPvsStatistics(PvsStatistics &stat) 
    17451747{ 
    1746   // update pvs of view cells tree if necessary 
    1747   UpdatePvs(); 
    1748    
    1749   ViewCellContainer::const_iterator it = mViewCells.begin(); 
    1750    
    1751   stat.viewcells = 0; 
    1752   stat.minPvs = 100000000; 
    1753   stat.maxPvs = 0; 
    1754   stat.avgPvs = 0.0f; 
    1755    
    1756   for (; it != mViewCells.end(); ++ it)  
    1757         { 
    1758           ViewCell *viewcell = *it; 
    1759  
    1760           //      bool mCountKdPvs = false; 
    1761           const int pvsSize = mViewCellsTree->GetPvsSize(viewcell); 
    1762  
    1763  
    1764           if (pvsSize < stat.minPvs) 
    1765                 stat.minPvs = pvsSize; 
    1766           if (pvsSize > stat.maxPvs) 
    1767                 stat.maxPvs = pvsSize; 
    1768            
    1769           stat.avgPvs += pvsSize; 
    1770            
    1771           ++ stat.viewcells; 
    1772         } 
    1773    
    1774   if (stat.viewcells) 
    1775         stat.avgPvs/=stat.viewcells; 
     1748        // update pvs of view cells tree if necessary 
     1749        UpdatePvs(); 
     1750 
     1751        ViewCellContainer::const_iterator it = mViewCells.begin(); 
     1752 
     1753        stat.viewcells = 0; 
     1754        stat.minPvs = 100000000; 
     1755        stat.maxPvs = 0; 
     1756        stat.avgPvs = 0.0f; 
     1757 
     1758        for (; it != mViewCells.end(); ++ it)  
     1759        { 
     1760                ViewCell *viewcell = *it; 
     1761 
     1762                const float pvsCost = mViewCellsTree->GetPvsCost(viewcell); 
     1763 
     1764                if (pvsCost < stat.minPvs) 
     1765                        stat.minPvs = pvsCost; 
     1766                if (pvsCost > stat.maxPvs) 
     1767                        stat.maxPvs = pvsCost; 
     1768 
     1769                stat.avgPvs += pvsCost; 
     1770 
     1771                ++ stat.viewcells; 
     1772        } 
     1773 
     1774        if (stat.viewcells) 
     1775                stat.avgPvs/=stat.viewcells; 
    17761776} 
    17771777 
     
    20532053float ViewCellsManager::GetRendercost(ViewCell *viewCell) const 
    20542054{ 
    2055         return (float)mViewCellsTree->GetPvsSize(viewCell); 
     2055        return (float)mViewCellsTree->GetPvsCost(viewCell); 
    20562056} 
    20572057 
     
    23272327 
    23282328void ViewCellsManager::UpdateScalarPvsSize(ViewCell *vc,  
    2329                                                                                    const int pvsSize,  
     2329                                                                                   const float pvsCost,  
    23302330                                                                                   const int entriesInPvs) const 
    23312331{ 
    2332         vc->mPvsSize = pvsSize; 
     2332        vc->mPvsCost = pvsCost; 
    23332333        vc->mEntriesInPvs = entriesInPvs; 
    23342334 
     
    25252525                        { 
    25262526                                importance =  
    2527                                         (float)mViewCellsTree->GetPvsSize(vc) /  
     2527                                        (float)mViewCellsTree->GetPvsCost(vc) /  
    25282528                                        (float)mCurrentViewCellsStats.maxPvs; 
    25292529                        } 
     
    25782578        if (root->IsLeaf()) 
    25792579        {  
     2580                //cout << "updating leaf" << endl; 
    25802581                // we assume that pvs is explicitly stored in leaves 
    25812582                pvs = root->GetPvs(); 
    25822583                UpdateScalarPvsSize(root, pvs.EvalPvsCost(), pvs.GetSize()); 
    2583                  
    25842584                return; 
    25852585        } 
    2586          
     2586 
     2587        //cout << "recursivly updating pvs" << endl; 
     2588 
    25872589        //////////////// 
    25882590        //-- interior node => propagate pvs up the tree 
     
    25972599        // pvss of child nodes 
    25982600        vector<ObjectPvs> pvsList; 
     2601        pvsList.resize((int)interior->mChildren.size()); 
    25992602 
    26002603        ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 
    2601         pvsList.resize((int)interior->mChildren.size()); 
     2604         
    26022605        int i = 0; 
     2606 
    26032607        for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ i) 
    26042608        { 
    2605                 //ObjectPvs objPvs; 
    2606                  
    26072609                ////////////////// 
    26082610                //-- recursivly compute child pvss 
    2609  
    26102611                UpdatePvsForEvaluation(*vit, pvsList[i]/*objPvs*/); 
    2611  
    2612                 // store pvs in vector 
    2613                 //pvsList.push_back(objPvs); 
    26142612        } 
    26152613 
     
    30473045                Exporter *exporter = Exporter::GetExporter(s); 
    30483046                 
    3049                 cout << "view cell " << idx << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 
     3047                cout << "view cell " << idx << ": pvs cost=" << (int)mViewCellsTree->GetPvsCost(vc) << endl; 
    30503048 
    30513049                if (exportRays) 
     
    44004398                Exporter *exporter = Exporter::GetExporter(s); 
    44014399                 
    4402                 const int pvsSize = (int)mViewCellsTree->GetPvsSize(vc); 
    4403                 cout << "view cell " << vc->GetId() << ": pvs size=" << pvsSize << endl; 
     4400                const float pvsCost = mViewCellsTree->GetPvsCost(vc); 
     4401                cout << "view cell " << vc->GetId() << ": pvs cost=" << pvsCost << endl; 
    44044402 
    44054403                if (exportRays) 
     
    52855283                Exporter *exporter = Exporter::GetExporter(s); 
    52865284                 
    5287                 cout << "view cell " << vc->GetId() << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 
     5285                cout << "view cell " << vc->GetId() << ": pvs cost=" << mViewCellsTree->GetPvsCost(vc) << endl; 
    52885286 
    52895287                if (exportPvs) 
     
    56615659 
    56625660 
    5663 #if 0 
     5661#if 1 
    56645662#if TEST_EVALUATION 
    56655663void VspOspViewCellsManager::EvalViewCellPartition() 
     
    57305728        { 
    57315729                ViewCell *vc = *vit; 
    5732                 int pvs = vc->GetPvs().EvalPvsCost(); 
    5733                 float vol = vc->GetVolume(); 
    5734                 rc += pvs * vol; 
     5730                const float pvsCost = vc->GetPvs().EvalPvsCost(); 
     5731                const float vol = vc->GetVolume(); 
     5732                rc += pvsCost * vol; 
    57355733        } 
    57365734 
     
    58265824                sprintf(str, "-%09d-eval.log", castSamples); 
    58275825                string filename = string(statsPrefix) + string(str); 
    5828  
    5829                 mHierarchyManager->EvaluateSubdivision(evaluationSamples, mPreprocessor->mObjects, filename); 
     5826                ofstream ofstr(filename.c_str()); 
     5827                mHierarchyManager->EvaluateSubdivision2(ofstr); 
    58305828 
    58315829                timeDiff = TimeDiff(startTime, GetTime()); 
     
    58335831                Debug << "statistis compted in " << timeDiff * 1e-3 << " secs" << endl; 
    58345832         
    5835                 //disposeRays(evaluationSamples, NULL); 
    5836         } 
    5837          
    5838         disposeRays(evaluationSamples, NULL); 
    5839  
     5833                disposeRays(evaluationSamples, NULL); 
     5834        } 
    58405835} 
    58415836#endif 
Note: See TracChangeset for help on using the changeset viewer.