Ignore:
Timestamp:
01/22/07 20:25:06 (17 years ago)
Author:
bittner
Message:

pvs efficiency tuning

File:
1 edited

Legend:

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

    r2014 r2015  
    744744{ 
    745745        int hits = 0; 
    746  
    747746        float mint = 0.0f, maxt = 1.0f; 
    748747        const Vector3 dir = termination - origin; 
     
    765764        while (1) 
    766765        { 
    767                 if (!node->IsLeaf()) 
     766          if (!node->IsLeaf()) { 
     767                KdInterior *in = (KdInterior *)node; 
     768                position = in->mPosition; 
     769                axis = in->mAxis; 
     770                 
     771                if (entp[axis] <= position) 
     772                  { 
     773                        if (extp[axis] <= position) 
     774                          { 
     775                                node = in->mBack; 
     776                                // cases N1,N2,N3,P5,Z2,Z3 
     777                                continue; 
     778                          }  
     779                        else 
     780                          { 
     781                                // case N4 
     782                                node = in->mBack; 
     783                                farChild = in->mFront; 
     784                          } 
     785                  } 
     786                else 
     787                  { 
     788                        if (position <= extp[axis]) 
     789                          { 
     790                                node = in->mFront; 
     791                                // cases P1,P2,P3,N5,Z1 
     792                                continue; 
     793                          } 
     794                        else 
     795                          { 
     796                                node = in->mFront; 
     797                                farChild = in->mBack; 
     798                                // case P4 
     799                          } 
     800                  } 
     801                 
     802                // $$ modification 3.5.2004 - hints from Kamil Ghais 
     803                // case N4 or P4 
     804                float tdist = (position - origin[axis]) / dir[axis]; 
     805                //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 
     806                extp = origin + dir * tdist; 
     807                maxt = tdist; 
     808          } 
     809          else 
    768810                { 
    769                         KdInterior *in = (KdInterior *)node; 
    770                         position = in->mPosition; 
    771                         axis = in->mAxis; 
    772  
    773                         if (entp[axis] <= position) 
    774                         { 
    775                                 if (extp[axis] <= position) 
    776                                 { 
    777                                         node = in->mBack; 
    778                                         // cases N1,N2,N3,P5,Z2,Z3 
    779                                         continue; 
    780                                 }  
    781                                 else 
    782                                 { 
    783                                         // case N4 
    784                                         node = in->mBack; 
    785                                         farChild = in->mFront; 
    786                                 } 
    787                         } 
    788                         else 
    789                         { 
    790                                 if (position <= extp[axis]) 
    791                                 { 
    792                                         node = in->mFront; 
    793                                         // cases P1,P2,P3,N5,Z1 
    794                                         continue; 
    795                                 } 
    796                                 else 
    797                                 { 
    798                                         node = in->mFront; 
    799                                         farChild = in->mBack; 
    800                                         // case P4 
    801                                 } 
    802                         } 
    803  
    804                         // $$ modification 3.5.2004 - hints from Kamil Ghais 
    805                         // case N4 or P4 
    806                         float tdist = (position - origin[axis]) / dir[axis]; 
    807                         //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 
    808                         extp = origin + dir * tdist; 
    809                         maxt = tdist; 
    810                 } 
    811                 else 
    812                 { 
    813                         // compute intersection with all objects in this leaf 
     811                  // compute intersection with all objects in this leaf 
    814812                  KdLeaf *leaf = (KdLeaf *)node; 
    815  
    816                         // add view cell to intersections 
    817                         ViewCell *vc = leaf->mViewCell; 
    818  
    819                         if (!vc->Mailed()) 
    820                         { 
    821                                 vc->Mail(); 
    822                                 viewcells.push_back(vc); 
    823                                 ++ hits; 
    824                         } 
    825  
    826                         // get the next node from the stack 
    827                         if (tStack.empty()) 
    828                                 break; 
    829  
    830                         entp = extp; 
    831                         mint = maxt; 
    832                          
    833                         RayTraversalData &s  = tStack.top(); 
    834                         node = s.mNode; 
    835                         extp = s.mExitPoint; 
    836                         maxt = s.mMaxT; 
    837                         tStack.pop(); 
     813                   
     814                  // add view cell to intersections 
     815                  ViewCell *vc = leaf->mViewCell; 
     816                   
     817                  if (!vc->Mailed()) { 
     818                        vc->Mail(); 
     819                        viewcells.push_back(vc); 
     820                        ++ hits; 
     821                  } 
     822                   
     823                  // get the next node from the stack 
     824                  if (tStack.empty()) 
     825                        break; 
     826                   
     827                  entp = extp; 
     828                  mint = maxt; 
     829                   
     830                  RayTraversalData &s  = tStack.top(); 
     831                  node = s.mNode; 
     832                  extp = s.mExitPoint; 
     833                  maxt = s.mMaxT; 
     834                  tStack.pop(); 
    838835                } 
    839836        } 
    840  
     837         
    841838        return hits; 
    842839} 
Note: See TracChangeset for help on using the changeset viewer.