Ignore:
Timestamp:
02/16/06 16:21:26 (18 years ago)
Author:
mattausch
Message:

removed problems with bsp due to polygons equal to scene box faces. removing
this polyogns in a preprocessing step. also using this for vsp bsp tree, because it
is generally a good thing.

File:
1 edited

Legend:

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

    r643 r648  
    332332                        AddMeshToPolygons(obj->GetMesh(), polys, obj); 
    333333                        ++ numObj; 
     334 
    334335                        //-- compute bounding box 
    335336                        if (!forcedBoundingBox) 
     
    381382        else  
    382383                mTermMinProbability *= mBox.GetVolume(); 
     384 
     385        // throw out unnecessary polygons 
     386        PreprocessPolygons(polys); 
    383387 
    384388        mBspStats.polys = (int)polys.size(); 
     
    19941998 
    19951999 
     2000void VspBspTree::PreprocessPolygons(PolygonContainer &polys) 
     2001{ 
     2002        // preprocess: throw out polygons coincident to the view space box (not needed) 
     2003        PolygonContainer boxPolys; 
     2004        mBox.ExtractPolys(boxPolys); 
     2005        vector<Plane3> boxPlanes; 
     2006 
     2007        PolygonContainer::iterator pit, pit_end = boxPolys.end(); 
     2008 
     2009        // extract planes of box 
     2010        // TODO: can be done more elegantly than first extracting polygons 
     2011        // and take their planes 
     2012        for (pit = boxPolys.begin(); pit != pit_end; ++ pit) 
     2013        { 
     2014                boxPlanes.push_back((*pit)->GetSupportingPlane()); 
     2015        } 
     2016 
     2017        pit_end = polys.end(); 
     2018 
     2019        for (pit = polys.begin(); pit != pit_end; ++ pit) 
     2020        { 
     2021                vector<Plane3>::const_iterator bit, bit_end = boxPlanes.end(); 
     2022                 
     2023                for (bit = boxPlanes.begin(); (bit != bit_end) && (*pit); ++ bit) 
     2024                { 
     2025                        const int cf = (*pit)->ClassifyPlane(*bit, mEpsilon); 
     2026 
     2027                        if (cf == Polygon3::COINCIDENT) 
     2028                        { 
     2029                                DEL_PTR(*pit); 
     2030                                //Debug << "coincident!!" << endl; 
     2031                        } 
     2032                } 
     2033        } 
     2034 
     2035        // remove deleted entries 
     2036        for (int i = 0; i < (int)polys.size(); ++ i) 
     2037        { 
     2038                while (!polys[i] && (i < (int)polys.size())) 
     2039                { 
     2040                        swap(polys[i], polys.back()); 
     2041                        polys.pop_back(); 
     2042                } 
     2043        } 
     2044} 
     2045 
     2046 
    19962047float VspBspTree::AccumulatedRayLength(const RayInfoContainer &rays) const 
    19972048{ 
Note: See TracChangeset for help on using the changeset viewer.