Ignore:
Timestamp:
11/07/06 13:56:58 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1717 r1718  
    838838   
    839839        const AxisAlignedBox3 nodeBbox = tData.mNode->GetBoundingBox(); 
    840  
    841         const float minBox = nodeBbox.Min(axis); 
    842         const float maxBox = nodeBbox.Max(axis); 
    843840        const float boxArea = nodeBbox.SurfaceArea(); 
    844841 
    845842        float minSum = 1e20f; 
    846843   
    847         float minBorder = maxBox; 
    848         float maxBorder = minBox; 
     844        float minBorder = nodeBbox.Max(axis); 
     845        float maxBorder = nodeBbox.Min(axis); 
    849846        float areaLeft = 0, areaRight = 0; 
    850847 
     
    854851        vector<float> bordersRight; 
    855852 
    856         if (mUseBboxAreaForSah) 
    857         { 
    858                 // we keep track of both borders of the bounding boxes => 
    859                 // store the events in descending order 
    860  
    861                 bordersRight.resize(mSubdivisionCandidates->size()); 
    862  
    863                 SortableEntryContainer::reverse_iterator rcit =  
    864                         mSubdivisionCandidates->rbegin(), rcit_end =  
    865                         mSubdivisionCandidates->rend(); 
    866          
    867                 vector<float>::reverse_iterator rbit = bordersRight.rbegin(); 
    868          
    869                 for (; rcit != rcit_end; ++ rcit, ++ rbit)  
    870                 { 
    871                         Intersectable *obj = (*rcit).mObject; 
    872                         const AxisAlignedBox3 obox = obj->GetBox(); 
    873  
    874                         if (obox.Min(axis) < minBorder) 
    875                         { 
    876                                 minBorder = obox.Min(axis); 
    877                         } 
    878  
    879                         (*rbit) = minBorder; 
    880                 } 
     853        // we keep track of both borders of the bounding boxes => 
     854        // store the events in descending order 
     855 
     856        bordersRight.resize(mSubdivisionCandidates->size()); 
     857 
     858        SortableEntryContainer::reverse_iterator rcit =  
     859                mSubdivisionCandidates->rbegin(), rcit_end =  
     860                mSubdivisionCandidates->rend(); 
     861 
     862        vector<float>::reverse_iterator rbit = bordersRight.rbegin(); 
     863 
     864        for (; rcit != rcit_end; ++ rcit, ++ rbit)  
     865        { 
     866                Intersectable *obj = (*rcit).mObject; 
     867                const AxisAlignedBox3 obox = obj->GetBox(); 
     868 
     869                if (obox.Min(axis) < minBorder) 
     870                { 
     871                        minBorder = obox.Min(axis); 
     872                } 
     873 
     874                (*rbit) = minBorder; 
    881875        } 
    882876 
     
    899893                const AxisAlignedBox3 obox = obj->GetBox(); 
    900894 
    901                 if (mUseBboxAreaForSah) 
    902                 { 
    903                         AxisAlignedBox3 lbox = nodeBbox; 
    904                         AxisAlignedBox3 rbox = nodeBbox; 
    905          
    906                         // the borders of the bounding boxes have changed 
    907                         if (obox.Max(axis) > maxBorder) 
    908                         { 
    909                                 maxBorder = obox.Max(axis); 
    910                         } 
    911  
    912                         minBorder = (*bit); 
    913  
    914                         lbox.SetMax(axis, maxBorder); 
    915                         rbox.SetMin(axis, minBorder); 
    916          
    917                         al = lbox.SurfaceArea(); 
    918                         ar = rbox.SurfaceArea(); 
    919                 } 
    920                 else 
    921                 { 
    922                         // just add up areas of the objects itself 
    923                         // As we are not sampling volumetric visibility, 
    924                         // this should provide better heuristics 
    925                         const float area = obj->GetArea();//obox.SurfaceArea(); 
    926  
    927                         al += area; 
    928                         ar -= area; 
    929                 } 
     895                // the borders of the bounding boxes have changed 
     896                if (obox.Max(axis) > maxBorder) 
     897                { 
     898                        maxBorder = obox.Max(axis); 
     899                } 
     900 
     901                minBorder = (*bit); 
     902 
     903                AxisAlignedBox3 lbox = nodeBbox; 
     904                AxisAlignedBox3 rbox = nodeBbox; 
     905 
     906                lbox.SetMax(axis, maxBorder); 
     907                rbox.SetMin(axis, minBorder); 
     908 
     909                al = lbox.SurfaceArea(); 
     910                ar = rbox.SurfaceArea(); 
    930911 
    931912                const bool noValidSplit = ((objectsLeft <= Limits::Small) || (objectsRight <= Limits::Small)); 
    932  
    933913                const float sum =  noValidSplit ? 1e25 : objectsLeft * al + objectsRight * ar; 
    934914       
     
    10541034                AxisAlignedBox3 rbox = nodeBbox; 
    10551035         
    1056                 // the borders of the bounding boxes have changed 
     1036                // the borders of the left bounding box have changed 
    10571037                for (int i = 0; i < 3; ++ i) 
    10581038                { 
     
    23862366 
    23872367 
    2388 } 
     2368void BvHierarchy::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
     2369{ 
     2370        stack<BvhNode *> nodeStack; 
     2371 
     2372        nodeStack.push(mRoot); 
     2373 
     2374        while (!nodeStack.empty())  
     2375        { 
     2376                BvhNode *node = nodeStack.top(); 
     2377 
     2378                nodeStack.pop(); 
     2379 
     2380                if (node->IsLeaf())  
     2381                { 
     2382                        BvhLeaf *leaf = (BvhLeaf *)node; 
     2383 
     2384                        ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
     2385 
     2386                        for (oit = leaf->mObjects.begin(); oit != oit_end; ++oit)  
     2387                        { 
     2388                                Intersectable *object = *oit; 
     2389                                if (Overlap(box, object->GetBox()))  
     2390                                { 
     2391                                        object->Mail(); 
     2392                                        objects.push_back(object); 
     2393                                } 
     2394                        } 
     2395                }  
     2396                else  
     2397                { 
     2398                        BvhInterior *interior = (BvhInterior *)node; 
     2399 
     2400                        if (Overlap(box, interior->GetBoundingBox())) 
     2401                                nodeStack.push(interior->GetFront()); 
     2402 
     2403                        if (Overlap(box, interior->GetBoundingBox())) 
     2404                                nodeStack.push(interior->GetBack()); 
     2405                } 
     2406        } 
     2407} 
     2408 
     2409} 
Note: See TracChangeset for help on using the changeset viewer.