Ignore:
Timestamp:
01/02/06 13:42:43 (19 years ago)
Author:
mattausch
Message:

valid view point regions working now for bsp view cells (crit: maxpvs)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r487 r489  
    4545mViewCellsManager(NULL), 
    4646mStoreRays(false), 
    47 mOnlyDrivingAxis(false) 
     47mOnlyDrivingAxis(false), 
     48mOutOfBoundsCell(NULL) 
    4849{ 
    4950        bool randomize = false; 
     
    128129        } 
    129130 
     131 
    130132        mSplitCandidates = new vector<SortableEntry>; 
    131133 
    132134        Debug << endl; 
     135} 
     136 
     137 
     138BspViewCell *VspBspTree::GetOrCreateOutOfBoundsCell() 
     139{ 
     140        if (!mOutOfBoundsCell) 
     141                mOutOfBoundsCell = new BspViewCell(); 
     142 
     143        return mOutOfBoundsCell; 
    133144} 
    134145 
     
    401412        { 
    402413                BspLeaf *leaf = dynamic_cast<BspLeaf *>(newNode); 
     414                BspViewCell *viewCell; 
    403415 
    404416                if (!CheckValid(tData)) 
     
    406418                        leaf->SetTreeValid(false); 
    407419                        PropagateUpValidity(leaf); 
    408                 } 
    409  
    410                 // create new view cell for this leaf 
    411                 BspViewCell *viewCell = new BspViewCell(); 
     420                        // view cell for invalid view space 
     421                        viewCell = GetOrCreateOutOfBoundsCell(); 
     422                } 
     423                else 
     424                { 
     425                        // create new view cell for this leaf 
     426                        viewCell = new BspViewCell(); 
     427                } 
     428                 
    412429                leaf->SetViewCell(viewCell); 
    413430         
     
    12061223        { 
    12071224                BspNode *node = nodeStack.top(); 
    1208  
    12091225                nodeStack.pop(); 
     1226                 
     1227                // this subtree is not valid view space 
     1228                if (!node->TreeValid()) 
     1229                        continue; 
    12101230 
    12111231                if (node->IsLeaf()) 
     
    12241244} 
    12251245 
     1246 
    12261247AxisAlignedBox3 VspBspTree::GetBoundingBox() const 
    12271248{ 
     
    12291250} 
    12301251 
     1252 
    12311253BspNode *VspBspTree::GetRoot() const 
    12321254{ 
    12331255        return mRoot; 
    12341256} 
     1257 
     1258 
     1259BspViewCell *VspBspTree::GetOutOfBoundsCell() const 
     1260{ 
     1261        return mOutOfBoundsCell; 
     1262} 
     1263 
    12351264 
    12361265void VspBspTree::EvaluateLeafStats(const VspBspTraversalData &data) 
     
    13991428                BspNode *node = nodeStack.top(); 
    14001429                nodeStack.pop(); 
     1430                // this subtree is not valid view space 
     1431                if (!node->TreeValid()) 
     1432                        continue; 
    14011433 
    14021434                if (node->IsLeaf()) 
     
    16351667                nodeStack.pop(); 
    16361668 
     1669                // view space not valid 
     1670                if (!node->TreeValid()) 
     1671                        continue; 
     1672 
    16371673                if (node->IsLeaf()) 
    16381674                { 
     
    16871723        return (int)neighbors.size(); 
    16881724} 
     1725 
    16891726 
    16901727BspLeaf *VspBspTree::GetRandomLeaf(const Plane3 &halfspace) 
     
    20022039 
    20032040                        BspLeaf *leaf = new BspLeaf(interior->GetParent(), vc); 
     2041                        leaf->SetTreeValid(frontLeaf->TreeValid()); 
    20042042 
    20052043                        // replace a link from node's parent 
     
    21702208           
    21712209                iit = ray->intersections.begin(); 
    2172                 BspLeaf *prevLeaf = (*(iit ++)).mLeaf; 
     2210                BspLeaf *leaf = (*(iit ++)).mLeaf; 
    21732211                 
    21742212                // create leaf pvs (needed for post processing) 
    2175                 if (!prevLeaf->mPvs) 
    2176                 { 
    2177                         prevLeaf->mPvs =  
    2178                                 new ObjectPvs(prevLeaf->GetViewCell()->GetPvs()); 
     2213                if (!leaf->mPvs) 
     2214                { 
     2215                        leaf->mPvs =  
     2216                                new ObjectPvs(leaf->GetViewCell()->GetPvs()); 
    21792217 
    21802218                        BspMergeCandidate::sOverallCost +=  
    2181                                 prevLeaf->mArea * prevLeaf->mPvs->GetSize(); 
     2219                                leaf->mArea * leaf->mPvs->GetSize(); 
    21822220                         
    21832221                        ++ leaves; 
     
    21852223                 
    21862224                // traverse intersections  
    2187                 // consecutive leaves are neighbors =>  
    2188                 // add them to queue 
     2225                // consecutive leaves are neighbors => add them to queue 
    21892226                for (; iit != ray->intersections.end(); ++ iit) 
    21902227                { 
    2191             BspLeaf *leaf = (*iit).mLeaf; 
    2192              
     2228                        // next pair 
     2229                        BspLeaf *prevLeaf = leaf; 
     2230            leaf = (*iit).mLeaf; 
     2231 
     2232                        // view space does not correspond to valid space 
     2233                        if (!leaf->TreeValid() || !prevLeaf->TreeValid()) 
     2234                                continue; 
     2235 
     2236            // create leaf pvs (needed for post processing) 
    21932237                        if (!leaf->mPvs) 
    21942238                        { 
     
    22292273                                mMergeQueue.push(BspMergeCandidate(leaf, prevLeaf)); 
    22302274                        } 
    2231  
    2232                         prevLeaf = leaf; 
    22332275        } 
    22342276        } 
Note: See TracChangeset for help on using the changeset viewer.