Changeset 395 for trunk


Ignore:
Timestamp:
11/09/05 15:09:09 (19 years ago)
Author:
bittner
Message:

vss preprocessor updates

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
2 edited

Legend:

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

    r387 r395  
    196196 
    197197 
     198void 
     199VssTreeLeaf::EvalPvsSize() 
     200{ 
     201        if (!mValidPvs) { 
     202                Intersectable::NewMail(); 
     203                int pvsSize = 0; 
     204                for(VssTreeNode::RayInfoContainer::iterator ri = rays.begin(); 
     205                                ri != rays.end(); 
     206                                ri++) 
     207                        if ((*ri).mRay->IsActive()) { 
     208                                Intersectable *object; 
     209#if BIDIRECTIONAL_RAY 
     210                                object = (*ri).mRay->mOriginObject; 
     211                                if (object && !object->Mailed()) { 
     212                                        pvsSize++; 
     213                                        object->Mail(); 
     214                                } 
     215#endif 
     216                                object = (*ri).mRay->mTerminationObject; 
     217                                if (object && !object->Mailed()) { 
     218                                        pvsSize++; 
     219                                        object->Mail(); 
     220                                } 
     221                        } 
     222                mPvsSize = pvsSize; 
     223                mValidPvs = true; 
     224        } 
     225} 
    198226 
    199227 
     
    238266         
    239267         
    240         if (forcedBoundingBox) 
     268        if ( forcedBoundingBox ) 
    241269                bbox = *forcedBoundingBox; 
    242270 
     
    245273 
    246274  stat.rays = leaf->rays.size(); 
    247         EvalLeafPvs(leaf); 
    248   stat.initialPvsSize = leaf->mPvsSize; 
     275        leaf->EvalPvsSize(); 
     276  stat.initialPvsSize = leaf->GetPvsSize(); 
    249277  // Subdivide(); 
    250278  root = Subdivide(TraversalData(leaf, bbox, 0)); 
     
    263291} 
    264292 
    265 void 
    266 VssTree::EvalLeafPvs(VssTreeLeaf *leaf) 
    267 { 
    268         Intersectable::NewMail(); 
    269         int pvsSize = 0; 
    270         for(VssTreeNode::RayInfoContainer::iterator ri = leaf->rays.begin(); 
    271                         ri != leaf->rays.end(); 
    272                         ri++) 
    273                 if ((*ri).mRay->IsActive()) { 
    274                         Intersectable *object; 
    275 #if BIDIRECTIONAL_RAY 
    276                         object = (*ri).mRay->mOriginObject; 
    277                         if (object && !object->Mailed()) { 
    278                                 pvsSize++; 
    279                                 object->Mail(); 
    280                         } 
    281 #endif 
    282                         object = (*ri).mRay->mTerminationObject; 
    283                         if (object && !object->Mailed()) { 
    284                                 pvsSize++; 
    285                                 object->Mail(); 
    286                         } 
    287                 } 
    288         leaf->mPvsSize = pvsSize; 
    289 } 
    290293 
    291294 
     
    433436         
    434437        // eval pvs size 
    435         int pvsSize = leaf->mPvsSize; 
     438        int pvsSize = leaf->GetPvsSize(); 
    436439 
    437440        Intersectable::NewMail(3); 
     
    600603         
    601604        int rl=0, rr = leaf->rays.size(); 
    602         int pl=0, pr = leaf->mPvsSize; 
     605        int pl=0, pr = leaf->GetPvsSize(); 
    603606        float minBox = box.Min(axis); 
    604607        float maxBox = box.Max(axis); 
     
    675678  } 
    676679   
    677   float oldCost = leaf->mPvsSize; 
     680  float oldCost = leaf->GetPvsSize(); 
    678681  float newCost = ct_div_ci + minSum/sizeBox; 
    679682  float ratio = newCost/oldCost; 
     
    739742        //  if ( (int)(leaf->rays.size()) < termMinCost) 
    740743        //    stat.minCostNodes++; 
    741         if ( leaf->mPvsSize < termMinPvs) 
     744        if ( leaf->GetPvsSize() < termMinPvs) 
    742745                stat.minCostNodes++; 
    743746   
     
    765768{ 
    766769   
    767   if ( (leaf->mPvsSize < termMinPvs) || 
     770  if ( (leaf->GetPvsSize() < termMinPvs) || 
    768771                         (leaf->GetAvgRayContribution() > termMaxRayContribution ) || 
    769772       (leaf->depth >= termMaxDepth) || 
     
    813816 
    814817  VssTreeLeaf *back = new VssTreeLeaf(node, raysBack); 
    815         back->mPvsSize = pvsBack; 
     818        back->SetPvsSize(pvsBack); 
    816819  VssTreeLeaf *front = new VssTreeLeaf(node, raysFront); 
    817         front->mPvsSize = pvsFront; 
     820        front->SetPvsSize(pvsFront); 
    818821 
    819822  // replace a link from node's parent 
     
    968971  if ( 
    969972                        //      leaf->rays.size() > (unsigned)termMinCost && 
    970                         (leaf->mPvsSize >= termMinPvs) && 
     973                        (leaf->GetPvsSize() >= termMinPvs) && 
    971974      SqrMagnitude(leafBBox.Size()) > sizeThreshold) { 
    972975     
     
    11301133 
    11311134    if (!data.node->IsLeaf()) { 
    1132  
    11331135      TraverseInternalNode(data, tstack); 
    1134  
    11351136    } else { 
    11361137      // remove the ray from the leaf 
     
    11961197  else { 
    11971198    // directional split 
    1198 //      if (DotProd(data.rayData.mRay->GetNormalizedDir(), in->refDir) > sinRefDir ) 
    1199 //        tstack.push(RayTraversalData(in->front, data.rayData)); 
    1200 //      else 
    1201 //        tstack.push(RayTraversalData(in->back, data.rayData)); 
    1202   } 
    1203    
     1199                if (data.rayData.mRay->GetDirParametrization(in->axis - 3) > in->position) 
     1200                        tstack.push(RayTraversalData(in->front, data.rayData)); 
     1201                else 
     1202                        tstack.push(RayTraversalData(in->back, data.rayData)); 
     1203  } 
    12041204} 
    12051205 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.h

    r387 r395  
    375375  public VssTreeNode 
    376376{ 
     377private: 
     378        int mPvsSize; 
    377379public: 
    378380  static int mailID; 
     
    380382   
    381383  RayInfoContainer rays; 
    382         int mPvsSize; 
    383    
     384        bool mValidPvs; 
     385         
    384386  VssTreeLeaf(VssTreeInterior *p, 
    385387                                                        const int nRays 
    386                                                         ):VssTreeNode(p), rays(), mPvsSize(0) { 
     388                                                        ):VssTreeNode(p), rays(), mPvsSize(0), mValidPvs(false) { 
    387389    rays.reserve(nRays); 
    388390  } 
     
    397399   
    398400  void AddRay(const RayInfo &data) { 
     401                mValidPvs = false; 
    399402    rays.push_back(data); 
    400403    data.mRay->Ref(); 
    401404  } 
     405         
     406        int GetPvsSize() const { 
     407                return mPvsSize; 
     408        } 
     409        void SetPvsSize(const int s) { 
     410                mPvsSize = s; 
     411        } 
     412 
     413        void 
     414        EvalPvsSize(); 
    402415 
    403416  void Mail() { mailbox = mailID; } 
     
    410423 
    411424        float GetAvgRayContribution() const { 
    412                 return mPvsSize/(float)rays.size(); 
     425                return GetPvsSize()/(float)rays.size(); 
    413426        } 
    414427}; 
     
    471484#if 1 
    472485                        return 
    473                                 leafa->mPvsSize*a.bbox.GetVolume() 
     486                                leafa->GetPvsSize()*a.bbox.GetVolume() 
    474487                                < 
    475                                 leafb->mPvsSize*b.bbox.GetVolume(); 
     488                                leafb->GetPvsSize()*b.bbox.GetVolume(); 
    476489#endif 
    477490#if 0 
    478491                        return 
    479                                 leafa->mPvsSize 
     492                                leafa->GetPvsSize() 
    480493                                < 
    481                                 leafb->mPvsSize; 
     494                                leafb->GetPvsSize(); 
    482495#endif 
    483496#if 0 
    484497                        return 
    485                                 leafa->mPvsSize/(leafa->rays.size()+1) 
     498                                leafa->GetPvsSize()/(leafa->rays.size()+1) 
    486499                                > 
    487                                 leafb->mPvsSize/(leafb->rays.size()+1); 
     500                                leafb->GetPvsSize()/(leafb->rays.size()+1); 
    488501#endif 
    489502#if 0 
    490503                        return 
    491                                 leafa->mPvsSize*leafa->rays.size() 
     504                                leafa->GetPvsSize()*leafa->rays.size() 
    492505                                < 
    493                                 leafb->mPvsSize*leafb->rays.size(); 
     506                                leafb->GetPvsSize()*leafb->rays.size(); 
    494507#endif 
    495508    } 
     
    751764  EvaluateLeafStats(const TraversalData &data); 
    752765 
    753         void 
    754         EvalLeafPvs(VssTreeLeaf *leaf); 
    755766 
    756767        int 
Note: See TracChangeset for help on using the changeset viewer.