Ignore:
Timestamp:
07/18/06 19:03:14 (18 years ago)
Author:
mattausch
Message:

added kd pvs support, changed way of counting pvs

File:
1 edited

Legend:

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

    r1139 r1141  
    823823 
    824824        Debug << "updating active vc: " << (int)viewCells.size() << endl; 
    825         // find all already merged view cells and remove them from view cells 
     825         
     826        // find all already merged view cells and remove them from the 
     827        // container view cells 
    826828                 
    827829        // sort out all view cells which are not active anymore, i.e., they 
     
    883885                const int upper = mViewCellsManager->GetMaxPvsSize(); 
    884886 
    885                 const float penalty = EvalPvsPenalty((*vit)->GetPvs().GetSize(), lower, upper); 
     887                const float penalty = EvalPvsPenalty((*vit)->GetPvs().CountPvs(), lower, upper); 
    886888                 
    887889                mDeviation += fabs(mAvgRenderCost - penalty); 
     
    943945 
    944946// TODO: should be done in view cells manager 
    945 ViewCellInterior *ViewCellsTree::MergeViewCells(ViewCell *l,  
    946                                                                                                 ViewCell *r,  
     947ViewCellInterior *ViewCellsTree::MergeViewCells(ViewCell *left,  
     948                                                                                                ViewCell *right,  
    947949                                                                                                int &pvsDiff) //const 
    948950{ 
    949         ViewCellInterior *vc = mViewCellsManager->MergeViewCells(l, r); 
     951        // create merged view cell 
     952        ViewCellInterior *vc =  
     953                mViewCellsManager->MergeViewCells(left, right); 
    950954 
    951955        // if merge was unsuccessful 
     
    953957 
    954958        // set to the new parent view cell 
    955         l->SetParent(vc); 
    956         r->SetParent(vc); 
    957  
    958         // set new size of view cell 
     959        left->SetParent(vc); 
     960        right->SetParent(vc); 
     961 
     962         
    959963        if (mUseAreaForPvs) 
    960964        { 
    961                 vc->SetArea(l->GetArea() + l->GetArea()); 
     965                // set new area of view cell 
     966                // not not correct, but costly to compute real area!! 
     967                vc->SetArea(left->GetArea() + right->GetArea()); 
    962968        } 
    963969        else 
    964         { 
    965                 vc->SetVolume(r->GetVolume() + l->GetVolume()); 
     970        {       // set new volume of view cell 
     971                vc->SetVolume(left->GetVolume() + right->GetVolume()); 
    966972        } 
    967973 
     
    971977        vc->Mail(); 
    972978 
    973         const int pvs1 = l->GetPvs().GetSize(); 
    974         const int pvs2 = r->GetPvs().GetSize(); 
    975  
    976  
    977         // new view cells are stored in this vector 
     979        const int pvs1 = left->GetPvs().CountPvs(); 
     980        const int pvs2 = right->GetPvs().CountPvs(); 
     981 
     982 
     983        // the new view cells are stored in this container 
    978984        mMergedViewCells.push_back(vc); 
    979985 
    980         pvsDiff = vc->GetPvs().GetSize() - pvs1 - pvs2; 
    981  
    982  
    983  
    984         //Ždon't store intermediate pvs 
     986        pvsDiff = vc->GetPvs().CountPvs() - pvs1 - pvs2; 
     987 
     988 
     989        // don't store pvs in interior cells, just a scalar 
    985990        if (mViewCellsStorage == PVS_IN_LEAVES) 
    986991        { 
    987                 l->mPvsSize = l->GetPvs().GetSize();  
    988                 l->mPvsSizeValid = true; 
     992                left->mPvsSize = left->GetPvs().GetSize();  
     993                left->mPvsSizeValid = true; 
    989994                 
    990                 if (!l->IsLeaf()) 
    991                         l->GetPvs().Clear(); 
     995                // remove pvs, we don't store interior pvss 
     996                if (!left->IsLeaf()) 
     997                { 
     998                        left->GetPvs().Clear(); 
     999                } 
     1000 
     1001                right->mPvsSize = right->GetPvs().CountPvs();  
     1002                right->mPvsSizeValid = true; 
    9921003                 
    993                 r->mPvsSize = r->GetPvs().GetSize();  
    994                 r->mPvsSizeValid = true; 
    995                  
    996                 if (!r->IsLeaf()) 
    997                         r->GetPvs().Clear(); 
    998          
    999 } 
    1000  
     1004                // remove pvs, we don't store interior pvss 
     1005                if (!right->IsLeaf()) 
     1006                { 
     1007                        right->GetPvs().Clear(); 
     1008                } 
     1009        } 
    10011010 
    10021011        return vc; 
     
    12581267                const float penalty =  
    12591268                        EvalPvsPenalty(vc->GetPvs().GetSize(), lower, upper); 
     1269 
    12601270                return (mAvgRenderCost - penalty) * (mAvgRenderCost - penalty) /  
    12611271                        (float)mNumActiveViewCells; 
     
    12741284        if (1) 
    12751285        { 
    1276                 const float penalty = EvalPvsPenalty(vc->GetPvs().GetSize(), lower, upper); 
     1286                const float penalty = EvalPvsPenalty(vc->GetPvs().CountPvs(), lower, upper); 
    12771287                return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 
    12781288        } 
     
    12831293 
    12841294 
    1285  
    12861295float ViewCellsTree::GetRenderCost(ViewCell *vc) const 
    12871296{ 
    12881297        if (mUseAreaForPvs) 
    1289                 return vc->GetPvs().GetSize() * vc->GetArea(); 
    1290  
    1291         return vc->GetPvs().GetSize() * vc->GetVolume(); 
     1298        { 
     1299                return vc->GetPvs().CountPvs() * vc->GetArea(); 
     1300        } 
     1301 
     1302        return vc->GetPvs().CountPvs() * vc->GetVolume(); 
    12921303} 
    12931304 
     
    13281339                newPvs = (int)ComputeMergedPvsCost(mc.mLeftViewCell->GetPvs(), mc.mRightViewCell->GetPvs()); 
    13291340 
    1330         const float newPenalty = EvalPvsPenalty(newPvs, 
     1341        const float newPenalty = EvalPvsPenalty(newPvs,  
    13311342                                                                                        mViewCellsManager->GetMinPvsSize(), 
    13321343                                                                                        mViewCellsManager->GetMaxPvsSize()); 
     
    14771488                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
    14781489                        { 
    1479                                 int pvsSize = GetPvsSize(*it); 
     1490                                const int pvsSize = GetPvsSize(*it); 
    14801491                                childCost += (float) pvsSize * (*it)->GetVolume(); 
    14811492                                childPvs += pvsSize; 
     
    16031614 
    16041615 
    1605  
    16061616        // delete all the objects from the leaf sets which were moved to parent pvs 
    16071617        ObjectPvsMap::const_iterator oit_end = interior->GetPvs().mEntries.end(); 
     
    16151625                } 
    16161626        } 
    1617  
    1618         /*int dummy = interior->GetPvs().GetSize(); 
    1619  
    1620         for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 
    1621         { 
    1622                 dummy += (*cit)->GetPvs().GetSize(); 
    1623         }*/ 
    1624  
    16251627} 
    16261628 
     
    17291731                        { 
    17301732                                if (countKdPvs) 
    1731                                         pvsSize = vc->GetPvs().GetSize(); 
     1733                                        pvsSize = vc->GetPvs().CountPvs(); 
    17321734                                else 
    17331735                                        pvsSize = CountKdPvs(dynamic_cast<ViewCellLeaf *>(vc)); 
     
    18171819        case PVS_IN_INTERIORS: 
    18181820        default: 
    1819                 Debug << "in interiors: " << vc->mPvsSize << " $$ " << vc->GetPvs().GetSize() << endl; 
    1820                 pvsSize = vc->GetPvs().GetSize();                
     1821                Debug << "in interiors: " << vc->mPvsSize << " $$ " << vc->GetPvs().CountPvs() << endl; 
     1822                pvsSize = vc->GetPvs().CountPvs();               
    18211823        } 
    18221824 
     
    18401842        if ((mViewCellsStorage == PVS_IN_INTERIORS) || vc->IsLeaf()) 
    18411843        { 
    1842                 pvsSize = vc->GetPvs().GetSize(); 
     1844                pvsSize = vc->GetPvs().CountPvs(); 
    18431845        } 
    18441846 
Note: See TracChangeset for help on using the changeset viewer.