Changeset 582


Ignore:
Timestamp:
02/02/06 19:16:39 (18 years ago)
Author:
mattausch
Message:

fixed bug in mergueue to find root of merge and sort out doube view cells

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r581 r582  
    176176        # samples used for view cell construction 
    177177        Construction { 
    178                 samples 1200000 
     178                samples 800000 
    179179                samplesPerPass 300000 
    180180        } 
    181181 
    182         active 150 
     182        #number of active view cells 
     183        active 250 
     184        maxStaticMemory 40 
    183185 
    184186        exportToFile false 
     
    268270        PostProcess { 
    269271                maxCostRatio 0.005 
    270                 minViewCells 1000 
     272                minViewCells 1 
    271273                maxPvsSize   5000 
    272274        } 
     
    279281VspBspTree { 
    280282        Construction { 
    281                 samples 900000 
     283                samples 300000 
    282284                epsilon 0.005 
    283285                randomize false 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r581 r582  
    13251325                "false"); 
    13261326 
     1327        RegisterOption("ViewCells.maxStaticMemory",  
     1328                optFloat,  
     1329                "view_cells_max_static_mem=",  
     1330                "8.0"); 
     1331 
    13271332 
    13281333        /************************************************************************************/ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r581 r582  
    308308{ 
    309309        environment->GetBoolValue("ViewCells.Visualization.exportMergedViewCells", mExportMergedViewCells); 
     310        environment->GetFloatValue("ViewCells.maxStaticMemory", mMaxMemory); 
    310311 
    311312        //-- merge options 
     
    314315        environment->GetFloatValue("ViewCells.PostProcess.maxCostRatio", mMergeMaxCostRatio); 
    315316         
     317 
     318        Debug << "========= view cell tree options ================\n"; 
     319        Debug << "minimum view cells: " << mMergeMinViewCells << endl; 
     320        Debug << "max cost ratio: " << mMergeMaxCostRatio << endl; 
     321        Debug << "max memory: " << mMaxMemory << endl; 
     322 
    316323        MergeCandidate::sRenderCostWeight = mRenderCostWeight; 
    317324 
    318325        mStats.open("mergeStats.log"); 
     326} 
     327 
     328 
     329// return memory usage in MB 
     330float ViewCellsTree::GetMemUsage() const 
     331{ 
     332        return 0; 
     333                /*(sizeof(ViewCellsTree) + 
     334                 mBspStats.Leaves() * sizeof(BspLeaf) + 
     335                 mBspStats.Interior() * sizeof(BspInterior) + 
     336                 mBspStats.accumRays * sizeof(RayInfo)) / (1024.0f * 1024.0f);*/ 
    319337} 
    320338 
     
    387405                                                                          const ObjectContainer &objects) 
    388406{ 
    389         // number of view cells equals the number of leaves  
    390         // (without the invalid ones ) 
    391         //mNumViewCells = mBspStats.Leaves();//- mBspStats.invalidLeaves; 
    392         mNumViewCells = (int)mViewCellsManager->GetViewCells().size(); 
     407        mNumActiveViewCells = (int)mViewCellsManager->GetViewCells().size(); 
    393408 
    394409        float variance = 0; 
     
    432447        // view cell manager. They will change with 
    433448        // subsequent merges 
    434         ViewCellContainer &viewCells = mViewCellsManager->GetViewCells(); 
     449        ViewCellContainer &activeViewCells = mViewCellsManager->GetViewCells(); 
    435450 
    436451 
     
    455470        float realExpectedCost = mExpectedCost; 
    456471        float realAvgRenderCost = mAvgRenderCost; 
    457         int realNumViewCells = mNumViewCells; 
     472        int realNumActiveViewCells = mNumActiveViewCells; 
    458473         
    459474        // maximal ratio of old expected render cost to expected render 
     
    461476        float avgCostMaxDeviation; 
    462477        int maxMergesPerPass; 
    463         int numActiveViewCells = 0; 
     478        int numMergedViewCells = 0; 
    464479 
    465480        environment->GetIntValue("ViewCells.PostProcess.maxMergesPerPass", maxMergesPerPass); 
     
    472487        //-- use priority queue to merge leaf pairs 
    473488 
    474         while (!mMergeQueue.empty() && (realNumViewCells > mMergeMinViewCells)) 
     489        while (!mMergeQueue.empty())// && (realNumActiveViewCells > mMergeMinViewCells)) 
    475490        { 
    476491                //-- reset merge queue if the ratio of current expected cost / real expected cost 
     
    495510                        mExpectedCost = realExpectedCost; 
    496511                        mAvgRenderCost = realAvgRenderCost; 
    497                         mNumViewCells = realNumViewCells; 
     512                        mNumActiveViewCells = realNumActiveViewCells; 
    498513                         
    499                         const int numActiveViewCells = UpdateMergedViewCells(viewCells); 
    500  
     514                        const int numMergedViewCells = UpdateActiveViewCells(activeViewCells); 
     515                 
     516                        // recompute priorities => reset render cost 
    501517                    ResetMergeQueue(); 
    502518 
     
    509525                        if (mExportMergedViewCells) 
    510526                        { 
    511                                 ExportMergedViewCells(viewCells, objects, numActiveViewCells); 
     527                                ExportMergedViewCells(activeViewCells, objects, numMergedViewCells); 
    512528                        } 
    513529                } 
     
    524540                mMergeQueue.pop(); 
    525541         
    526                 // both view cells equal! 
     542                // both view cells equal 
     543                // NOTE: do I really still need this? probably cannot happen!! 
    527544                if (mc.mLeftViewCell == mc.mRightViewCell) 
    528545                        continue; 
     
    532549                        ViewCell::NewMail(); 
    533550                                                 
    534                         -- realNumViewCells; 
     551                        -- realNumActiveViewCells; 
    535552                        ++ mergeStats.merged; 
    536553                        ++ mergedPerPass; 
     
    547564                        mDeviation += mc.GetDeviationIncr(); 
    548565                                                 
    549                         realExpectedCost = totalCost / (float)realNumViewCells; 
     566                        realExpectedCost = totalCost / (float)realNumActiveViewCells; 
    550567                         
    551568                        const float currentMergeCost = mc.GetMergeCost(); 
     
    557574 
    558575                        totalPvs += pvsDiff; 
     576 
    559577                        // set timestamp 
    560578                        mergedVc->SetTimeStamp(mergeStats.merged); 
    561579 
    562                         realAvgRenderCost = (float)totalPvs / (float)realNumViewCells; 
     580                        realAvgRenderCost = (float)totalPvs / (float)realNumActiveViewCells; 
    563581#if VC_HISTORY 
    564582                        if (mc.mLeftViewCell->IsSibling(mc.mRightViewCell)) 
     
    566584#endif 
    567585                        if (((mergeStats.merged % statsOut) == 0) ||  
    568                                 (realNumViewCells == mMergeMinViewCells)) 
     586                                (realNumActiveViewCells == mMergeMinViewCells)) 
    569587                        { 
    570588                                cout << "merged " << mergeStats.merged << " view cells" << endl; 
     
    573591                                        << "#Pass\n" << pass << endl 
    574592                                        << "#Merged\n" << mergeStats.merged << endl  
    575                                         << "#Viewcells\n" << realNumViewCells << endl  
     593                                        << "#Viewcells\n" << realNumActiveViewCells << endl  
    576594                                        << "#CurrentCost\n" << currentMergeCost << endl 
    577595                                        << "#RelativeCost\n" << currentMergeCost / mOverallCost << endl 
     
    584602                                        << "#AvgRenderCost\n" << mAvgRenderCost << endl 
    585603                                        << "#expectedCostRatio\n" << mExpectedCost / realExpectedCost << endl 
    586                                         << "#Deviation\n" << mDeviation / (float)realNumViewCells << endl 
     604                                        << "#Deviation\n" << mDeviation / (float)realNumActiveViewCells << endl 
    587605                                        << "#TotalDeviation\n" << mDeviation<< endl; 
    588606                        } 
     
    592610                        // merge candidate not valid, because one of the leaves was already 
    593611                        // merged with another one => validate and reinsert into queue 
    594                         SetMergeCandidateValid(mc); 
    595                         mMergeQueue.push(mc); 
     612                        if (ValidateMergeCandidate(mc)) 
     613                        { 
     614                                EvalMergeCost(mc); 
     615                                mMergeQueue.push(mc); 
     616                        } 
    596617                } 
    597618        } 
     
    600621        mExpectedCost = realExpectedCost; 
    601622        mAvgRenderCost = realAvgRenderCost; 
    602         mNumViewCells = realNumViewCells; 
    603  
    604         UpdateMergedViewCells(viewCells); 
     623        mNumActiveViewCells = realNumActiveViewCells; 
     624 
     625        UpdateActiveViewCells(activeViewCells); 
    605626        ResetMergeQueue(); 
    606  
    607627 
    608628        // create a root node if the merge was not done till root level, 
    609629        // else take the single node as new root 
    610         if ((int)viewCells.size() > 1) 
    611         { 
    612                 Debug << "here888" << endl; 
    613                 ViewCellInterior *root = new ViewCellInterior(); 
     630        if ((int)activeViewCells.size() > 1) 
     631        { 
     632                Debug << "creating root of view cell hierarchy for " << (int)activeViewCells.size() << " view cells" << endl; 
     633                for (int i = 0;  i < activeViewCells.size(); ++ i){ 
     634                        Debug << "here233 " << activeViewCells[i]->GetParent() << endl; 
     635                        Debug << "here233 " << activeViewCells[i] << endl; 
     636                } 
     637                ViewCellInterior *root = mViewCellsManager->MergeViewCells(activeViewCells); 
    614638 
    615639                root->SetTimeStamp(mergeStats.merged + 1); 
    616  
    617                 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 
    618                 for (it = viewCells.begin(); it != it_end; ++ it) 
    619                         root->SetupChildLink(*it); 
    620  
    621640                mRoot = root; 
    622641        } 
    623         else if ((int)viewCells.size() == 1) 
    624         { 
    625                 Debug << "here555" << endl; 
    626                 mRoot = viewCells[0]; 
     642        else if ((int)activeViewCells.size() == 1) 
     643        { 
     644                Debug << "setting root of the merge history" << endl; 
     645                mRoot = activeViewCells[0]; 
    627646        } 
    628647 
     
    668687                 
    669688                // recalculate cost 
    670                 SetMergeCandidateValid(mc); 
    671                 buf.push_back(mc);                               
     689                if (ValidateMergeCandidate(mc)) 
     690                { 
     691                        EvalMergeCost(mc); 
     692                        buf.push_back(mc);                               
     693                } 
    672694        } 
    673695 
     
    684706 
    685707 
    686 int ViewCellsTree::UpdateMergedViewCells(ViewCellContainer &viewCells) 
    687 { 
    688         int numActiveViewCells = 0; 
    689  
     708int ViewCellsTree::UpdateActiveViewCells(ViewCellContainer &viewCells) 
     709{ 
     710        int numMergedViewCells = 0; 
     711 
     712        Debug << "updating active vc: " << viewCells.size() << endl; 
    690713        // find all already merged view cells and remove them from view cells 
     714                 
     715        // sort out all view cells which are not active anymore, i.e., they 
     716        // were already part of a merge 
    691717        int i = 0; 
    692718 
     719        ViewCell::NewMail(); 
     720 
    693721        while (1) 
    694722        { 
    695                 while (!viewCells.empty() && (!viewCells.back()->GetParent())) 
     723                // remove all merged view cells from end of the vector 
     724                while (!viewCells.empty() && (viewCells.back()->GetParent())) 
    696725                { 
    697726                        viewCells.pop_back(); 
     
    703732 
    704733                // already merged view cell, put it to end of vector 
    705                 if (!viewCells[i]->IsRoot()) 
     734                if (viewCells[i]->GetParent()) 
    706735                        swap(viewCells[i], viewCells.back()); 
    707736                 
    708                 ++ i; 
    709         } 
     737                viewCells[i ++]->Mail(); 
     738        } 
     739 
    710740 
    711741        // add new view cells to container only if they don't have been  
    712742        // merged in the mean time 
    713         while (!mActiveViewCells.empty()) 
    714         { 
    715                 if (!mActiveViewCells.back()->GetParent()) 
    716                 { 
    717                         viewCells.push_back(mActiveViewCells.back()); 
    718                         ++ numActiveViewCells; 
    719                 } 
    720  
    721                 mActiveViewCells.pop_back(); 
    722         } 
     743        ViewCellContainer::const_iterator ait, ait_end = mMergedViewCells.end(); 
     744        for (ait = mMergedViewCells.begin(); ait != ait_end; ++ ait) 
     745        { 
     746                ViewCell *vc = mMergedViewCells.back(); 
     747                if (!vc->GetParent() && !vc->Mailed()) 
     748                { 
     749                        vc->Mail(); 
     750                        viewCells.push_back(vc); 
     751                        ++ numMergedViewCells; 
     752                } 
     753        } 
     754 
     755        mMergedViewCells.clear(); 
    723756 
    724757        // update standard deviation 
     
    737770 
    738771        mDeviation /= (float)viewCells.size(); 
    739  
    740         // clear the view cells which were merged 
    741         mInactiveViewCells.clear(); 
    742         // remove the new view cells 
    743         mActiveViewCells.clear(); 
    744  
    745         return numActiveViewCells; 
     772         
     773        return numMergedViewCells; 
    746774} 
    747775 
     
    749777void ViewCellsTree::ExportMergedViewCells(ViewCellContainer &viewCells,  
    750778                                                                                  const ObjectContainer &objects, 
    751                                                                                   const int numActiveViewCells) 
     779                                                                                  const int numMergedViewCells) 
    752780{ 
    753781         
     
    771799                        // assign special material to new view cells 
    772800                        // new view cells are on the back of container 
    773                         if (i ++ >= (viewCells.size() - numActiveViewCells)) 
     801                        if (i ++ >= (viewCells.size() - numMergedViewCells)) 
    774802                        { 
    775803                                //m = RandomMaterial(); 
     
    798826ViewCellInterior *ViewCellsTree::MergeViewCells(ViewCell *l, ViewCell *r, int &pvsDiff) //const 
    799827{ 
    800         ViewCellInterior *vc = mViewCellsManager->MergeViewCells(*l, *r); 
     828        ViewCellInterior *vc = mViewCellsManager->MergeViewCells(l, r); 
    801829 
    802830        // if merge was unsuccessful 
     
    817845 
    818846 
    819         //-- clean up old view cells 
    820         if (0 && !mExportMergedViewCells) 
    821         { 
    822                 DEL_PTR(l); 
    823                 DEL_PTR(r); 
    824         } 
    825         else  
    826         { 
    827                 mInactiveViewCells.push_back(l); 
    828                 mInactiveViewCells.push_back(r); 
    829                  
    830                 mActiveViewCells.push_back(vc); 
    831         } 
     847        // new view cells are stored in this vector 
     848        mMergedViewCells.push_back(vc); 
    832849 
    833850        pvsDiff = vc->GetPvs().GetSize() - pvs1 - pvs2; 
     
    10181035         
    10191036        return mRenderCostWeight * (renderCost1 + renderCost2) + 
    1020                   (1.0f - mRenderCostWeight) * (dev1 + dev2) / (float)mNumViewCells; 
     1037                  (1.0f - mRenderCostWeight) * (dev1 + dev2) / (float)mNumActiveViewCells; 
    10211038} 
    10221039 
     
    11121129        { 
    11131130                const float penalty = EvalPvsPenalty(vc->GetPvs().GetSize(), lower, upper); 
    1114                 return (mAvgRenderCost - penalty) * (mAvgRenderCost - penalty) / (float)mNumViewCells; 
     1131                return (mAvgRenderCost - penalty) * (mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 
    11151132        } 
    11161133 
     
    11281145        { 
    11291146                const float penalty = EvalPvsPenalty(vc->GetPvs().GetSize(), lower, upper); 
    1130                 return fabs(mAvgRenderCost - penalty) / (float)mNumViewCells; 
     1147                return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 
    11311148        } 
    11321149 
     
    11531170 
    11541171 
    1155 void ViewCellsTree::SetMergeCandidateValid(MergeCandidate &mc) const 
     1172bool ViewCellsTree::ValidateMergeCandidate(MergeCandidate &mc) const 
    11561173{ 
    11571174        while (mc.mLeftViewCell->mParent) 
     
    11651182        } 
    11661183 
    1167         EvalMergeCost(mc); 
     1184        return mc.mLeftViewCell != mc.mRightViewCell; 
    11681185} 
    11691186 
     
    12101227 
    12111228        if (1) 
    1212                 newDev = fabs(mAvgRenderCost - newPenalty) / (float)mNumViewCells; 
     1229                newDev = fabs(mAvgRenderCost - newPenalty) / (float)mNumActiveViewCells; 
    12131230        else 
    1214                 newDev = fabs(mExpectedCost - newCost) / (float)mNumViewCells; 
     1231                newDev = fabs(mExpectedCost - newCost) / (float)mNumActiveViewCells; 
    12151232         
    12161233        oldDev = GetDeviation(vc1) + GetDeviation(vc2); 
     
    12511268        TraversalQueue tqueue; 
    12521269        tqueue.push(mRoot); 
    1253         Debug << "here34 " << numViewCells << endl; 
     1270         
    12541271        while (!tqueue.empty()) 
    12551272        { 
    12561273                ViewCell *vc = tqueue.top(); 
    1257                 tqueue.pop(); 
    1258                 Debug << "here7 " << vc->GetTimeStamp() << endl; 
    1259                 if (vc->IsLeaf()) 
    1260                 { 
    1261                         Debug << "here6" << endl; 
     1274                 
     1275                // save the view cells if it is a leaf or if enough view cells have already been traversed 
     1276                // because of the priority queue, this will be the optimal set of v 
     1277                if (vc->IsLeaf() || ((viewCells.size() + tqueue.size()) >= numViewCells)) 
     1278                { 
    12621279                        viewCells.push_back(vc); 
    12631280                } 
    1264                 else if (viewCells.size() + tqueue.size() < numViewCells) 
    1265                 {       Debug << "here4" << endl; 
     1281                else  
     1282                {        
    12661283                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
    12671284 
     
    12731290                        } 
    12741291                } 
     1292 
     1293                tqueue.pop(); 
    12751294        } 
    12761295} 
     
    13901409bool MergeCandidate::IsValid() const 
    13911410{ 
    1392         return !(mLeftViewCell->mParent && mRightViewCell->mParent); 
     1411        return !(mLeftViewCell->mParent || mRightViewCell->mParent); 
    13931412} 
    13941413 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r581 r582  
    325325        float GetDeviation(ViewCell *vc) const; 
    326326 
    327         /** Recalculates this merge candidate and sets valid. 
    328         */ 
    329         void SetMergeCandidateValid(MergeCandidate &mc) const; 
     327        /** Tries to set this merge candidate to valid.  
     328                @returns false if both view cells are the same 
     329        */ 
     330        bool ValidateMergeCandidate(MergeCandidate &mc) const; 
    330331 
    331332        /** Merge view cells of leaves l1 and l2. 
     
    360361 
    361362        /** Updates the current top level of view cells. 
    362         */ 
    363         int UpdateMergedViewCells(ViewCellContainer &viewCells); 
     363                @returns number of newly merged view cells 
     364        */ 
     365        int UpdateActiveViewCells(ViewCellContainer &viewCells); 
    364366 
    365367        void ComputeCommonPvs(ViewCellInterior *interior); 
     368 
     369 
     370        /** Returns memory usage of view cells. 
     371        */ 
     372        float GetMemUsage() const; 
     373 
    366374 
    367375 
     
    375383         
    376384                 
    377         ViewCellContainer mInactiveViewCells; 
    378         ViewCellContainer mActiveViewCells; 
     385        ViewCellContainer mMergedViewCells; 
     386         
    379387 
    380388        /// weights between variance and render cost increase (must be between zero and one) 
     
    389397        int mUseAreaForPvs; 
    390398 
    391         int mNumViewCells; 
     399        int mNumActiveViewCells; 
    392400 
    393401        /// minimal number of view cells 
     
    402410        MergeQueue mMergeQueue; 
    403411 
    404          
     412        float mMaxMemory; 
    405413 
    406414}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r580 r582  
    10301030} 
    10311031 
     1032 
    10321033void BspTree::SortSplitCandidates(const PolygonContainer &polys,  
    10331034                                                                  const int axis,  
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r581 r582  
    5656        environment->GetBoolValue("ViewCells.PostProcess.useRaysForMerge", mUseRaysForMerge); 
    5757         
    58         environment->GetIntValue("ViewCells.active", mNumActiveViewCells); 
     58        environment->GetIntValue("ViewCells.active", mNumMergedViewCells); 
    5959 
    6060        mMinPvsSize = emptyViewCells ? 1 : 0; 
     
    107107{ 
    108108        cout << "disposing samples ... "; 
     109        long startTime = GetTime(); 
     110        int n = (int)rays.size(); 
     111 
    109112        if (outRays) 
    110113        { 
     
    121124        } 
    122125        cout << "finished" << endl; 
     126        Debug << "disposed " << n << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    123127} 
    124128 
     
    519523 
    520524 
    521 ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCell &left, ViewCell &right) const 
     525ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCell *left, ViewCell *right) const 
    522526{ 
    523527        // generate parent view cell 
     
    525529 
    526530        // merge pvs 
    527         vc->GetPvs().Merge(left.GetPvs(), right.GetPvs()); 
     531        vc->GetPvs().Merge(left->GetPvs(), right->GetPvs()); 
    528532 
    529533        //-- merge ray sets 
    530534        if (0) 
    531535        { 
    532                 stable_sort(left.mPiercingRays.begin(), left.mPiercingRays.end()); 
    533                 stable_sort(right.mPiercingRays.begin(), right.mPiercingRays.end()); 
    534  
    535                 std::merge(left.mPiercingRays.begin(), left.mPiercingRays.end(), 
    536                                    right.mPiercingRays.begin(), right.mPiercingRays.end(), 
     536                stable_sort(left->mPiercingRays.begin(), left->mPiercingRays.end()); 
     537                stable_sort(right->mPiercingRays.begin(), right->mPiercingRays.end()); 
     538 
     539                std::merge(left->mPiercingRays.begin(), left->mPiercingRays.end(), 
     540                                   right->mPiercingRays.begin(), right->mPiercingRays.end(), 
    537541                                   vc->mPiercingRays.begin()); 
    538542        } 
    539543 
    540544 
    541         vc->SetupChildLink(&left); 
    542         vc->SetupChildLink(&right); 
    543  
     545        vc->SetupChildLink(left); 
     546        vc->SetupChildLink(right); 
     547 
     548 
     549        return vc; 
     550} 
     551 
     552 
     553ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCellContainer &children) const 
     554{ 
     555        ViewCellInterior *vc = new ViewCellInterior();//GenerateViewCell(); 
     556 
     557        ViewCellContainer::const_iterator it, it_end = children.end(); 
     558 
     559        for (it = children.begin(); it != it_end; ++ it) 
     560        { 
     561                // merge pvs 
     562                vc->GetPvs().Merge(vc->GetPvs(), (*it)->GetPvs()); 
     563 
     564                vc->SetupChildLink(*it); 
     565        } 
    544566 
    545567        return vc; 
     
    845867                if (!mOnlyValidViewCells || (*it)->GetValid()) 
    846868                { 
    847                         ExportColor(exporter, *it); 
    848                         ExportViewCellGeometry(exporter, *it); 
    849                 } 
    850         } 
     869                        ExportColor(exporter, *it);              
     870                        ExportViewCellGeometry(exporter, *it);           
     871                } 
     872        } 
     873 
    851874} 
    852875 
     
    11751198                VssRayContainer vcRays; 
    11761199                Intersectable::NewMail(); 
    1177 #if 0 
    1178                 BspViewCell *vc = dynamic_cast<BspViewCell *>(mViewCells[i]); 
    1179 #else 
    1180                 BspViewCell *vc = dynamic_cast<BspViewCell *>(mViewCells[Random((int)mViewCells.size())]); 
    1181 #endif 
     1200                ViewCell *vc; 
     1201 
     1202                if (0) 
     1203                        vc = mViewCells[i]; 
     1204                else 
     1205                        vc = mViewCells[Random((int)mViewCells.size())]; 
     1206 
    11821207                cout << "creating output for view cell " << i << " ... "; 
    11831208 
     
    12131238 
    12141239                        //-- export view cell 
     1240#if VC_HISTORY 
    12151241                        mBspTree->ConstructGeometry(vc, vcGeom); 
    12161242                        exporter->ExportPolygons(vcGeom.mPolys); 
     1243#endif 
    12171244                } 
    12181245 
     
    12711298                // cast line segment to get intersections with bsp leaves 
    12721299                CastLineSegment(vssRay->mTermination, vssRay->mOrigin, viewCells); 
    1273  
     1300#if VC_HISTORY 
    12741301                ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    12751302                for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    12761303                { 
    1277                         BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     1304                        ViewCell *vc = *vit; 
    12781305                        ray->intersections.push_back(BspIntersection(0, vc->mLeaf)); 
    12791306                } 
    1280  
     1307#endif 
    12811308                mBspRays.push_back(ray); 
    12821309        } 
     
    13341361        { 
    13351362                BspNodeGeometry geom; 
    1336                 mBspTree->ConstructGeometry( 
    1337                         dynamic_cast<BspViewCell *>(vc), geom); 
     1363#if VC_HISTORY 
     1364                mBspTree->ConstructGeometry(vc, geom); 
    13381365                exporter->ExportPolygons(geom.mPolys); 
     1366#endif 
    13391367        } 
    13401368} 
     
    20812109        { 
    20822110                // we can use the view cells tree hierarchy to get the right set 
    2083                 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumActiveViewCells); 
     2111                mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); 
    20842112        } 
    20852113 
     
    23802408                        for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
    23812409                        { 
    2382                                 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     2410                                ViewCell *vc = *vit; 
    23832411 
    23842412                                vm = RandomMaterial(); 
     
    25472575                        for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
    25482576                        { 
    2549                                 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     2577                                ViewCell *vc = *vit; 
    25502578 
    25512579                                ViewCellContainer leaves; 
     
    26582686                VssRayContainer vcRays; 
    26592687                Intersectable::NewMail(); 
    2660                 BspViewCell *vc; 
     2688                ViewCell *vc; 
    26612689         
    26622690                if (0) // largest view cell pvs first 
    2663                 { 
    2664                         vc = dynamic_cast<BspViewCell *>(mViewCells[i]); 
    2665                 } 
     2691                        vc = mViewCells[i]; 
    26662692                else 
    2667                 { 
    2668                         vc = dynamic_cast<BspViewCell *> 
    2669                                 (mViewCells[Random((int)mViewCells.size())]); 
    2670                 } 
     2693                        vc = mViewCells[Random((int)mViewCells.size())]; 
    26712694 
    26722695        if (1) 
     
    26782701                                for     (int j = 0; j < (int)ray->mViewCells.size(); ++ j) 
    26792702                                { 
    2680                                         BspViewCell *bspVc = dynamic_cast<BspViewCell *>(ray->mViewCells[j]); 
    2681                                         BspLeaf *leaf = bspVc->mLeaf; 
    2682                                         if (vc == bspVc) 
     2703                                        ViewCell *rayvc = ray->mViewCells[j]; 
     2704#if VC_HISTORY 
     2705                                        BspLeaf *leaf = rayvc->mLeaf; 
     2706                                        if (vc == rayvc) 
    26832707                                                vcRays.push_back(ray); 
     2708#endif 
    26842709                                } 
    26852710                        } 
     
    28352860 
    28362861        BspNodeGeometry geom; 
    2837         mVspBspTree-> 
    2838                 ConstructGeometry(dynamic_cast<BspViewCell *>(vc), geom); 
     2862        mVspBspTree->ConstructGeometry(vc, geom); 
    28392863        exporter->ExportPolygons(geom.mPolys); 
    28402864} 
     
    28452869        ViewCellContainer leaves; 
    28462870        mViewCellsTree->CollectLeaves(vc, leaves); 
    2847  
    28482871 
    28492872        int maxDist = 0; 
     
    28862909 
    28872910        BspNodeGeometry geom; 
    2888         BspViewCell *bspVc = dynamic_cast<BspViewCell *>(vc); 
    2889         mVspBspTree->ConstructGeometry(bspVc, geom); 
     2911         
     2912        mVspBspTree->ConstructGeometry(vc, geom); 
    28902913 
    28912914        Mesh *mesh = new Mesh(); 
     
    29843007void VspBspViewCellsManager::Finalize(ViewCell *viewCell, const bool createMesh) 
    29853008{ 
    2986         BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCell); 
    2987         CreateMesh(vc); 
     3009        CreateMesh(viewCell); 
    29883010 
    29893011        float area = 0; 
     
    29913013 
    29923014        ViewCellContainer leaves; 
    2993         mViewCellsTree->CollectLeaves(vc, leaves); 
     3015        mViewCellsTree->CollectLeaves(viewCell, leaves); 
    29943016 
    29953017        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r581 r582  
    135135                @returns new view cell based on the merging. 
    136136        */ 
    137         ViewCellInterior *MergeViewCells(ViewCell &front, ViewCell &back) const; 
     137        ViewCellInterior *MergeViewCells(ViewCell *front, ViewCell *back) const; 
     138 
     139        /** Merges a container of view cells. 
     140                @returns new view cell based on the merging. 
     141        */ 
     142        ViewCellInterior *MergeViewCells(ViewCellContainer &children) const; 
    138143         
    139144        /** Generates view cell of type specified by this manager 
     
    429434        float mMaxPvsRatio; 
    430435 
    431         int mNumActiveViewCells; 
     436        int mNumMergedViewCells; 
    432437 
    433438        ViewCellsStatistics mViewCellsStats; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r580 r582  
    132132        Debug << "max plane candidates: " << mMaxRayCandidates << endl; 
    133133        Debug << "randomize: " << randomize << endl; 
    134 //      Debug << "minimum view cells: " << mMergeMinViewCells << endl; 
     134 
    135135        Debug << "using area for pvs: " << mUseAreaForPvs << endl; 
    136136        Debug << "render cost weight: " << mRenderCostWeight << endl; 
     
    20492049 
    20502050 
    2051 void VspBspTree::ConstructGeometry(BspViewCell *vc,  
     2051void VspBspTree::ConstructGeometry(ViewCell *vc,  
    20522052                                                                   BspNodeGeometry &vcGeom) const 
    20532053{ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r580 r582  
    218218        /** Construct geometry of view cell. 
    219219        */ 
    220         void ConstructGeometry(BspViewCell *vc, BspNodeGeometry &geom) const; 
     220        void ConstructGeometry(ViewCell *vc, BspNodeGeometry &geom) const; 
    221221 
    222222        /** Returns random leaf of BSP tree. 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp

    r580 r582  
    21962196 
    21972197        VspKdViewCell *vc = dynamic_cast<VspKdViewCell *>( 
    2198                 mViewCellsManager->MergeViewCells(*fVc, *bVc)); 
     2198                mViewCellsManager->MergeViewCells(fVc, bVc)); 
    21992199 
    22002200        // if merge was unsuccessful 
  • trunk/VUT/GtpVisibilityPreprocessor/src/common.h

    r574 r582  
    145145                                                        while (0) 
    146146#endif 
    147 #endif 
     147 
     148#else 
    148149 
    149150#ifndef CLEAR_CONTAINER 
     
    153154while (0) 
    154155#endif 
     156 
     157#endif 
     158 
    155159 
    156160inline 
Note: See TracChangeset for help on using the changeset viewer.