Changeset 562


Ignore:
Timestamp:
01/20/06 22:32:51 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r558 r562  
    2525        type vss 
    2626#       type rss 
     27        detectEmptyViewSpace true 
    2728} 
    2829 
    2930VssPreprocessor { 
    3031        samplesPerPass  100000 
    31         initialSamples 800000 
     32        initialSamples 1800000 
    3233        vssSamples 0 
    3334        vssSamplesPerPass 500000 
     
    3637        storeInitialSamples false 
    3738        useViewSpaceBox true 
    38         testBeamSampling true 
     39#       testBeamSampling true 
    3940} 
    4041 
     
    259260VspBspTree { 
    260261        Construction { 
    261                 samples 300000 
     262                samples 900000 
    262263                epsilon 0.005 
    263264                randomize false 
     
    323324        PostProcess { 
    324325                maxCostRatio 0.1 
    325                 minViewCells 100 
    326                 useRaysForMerge true 
     326                minViewCells 110 
     327                useRaysForMerge false 
    327328        } 
    328329} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r561 r562  
    2626mTotalArea(0.0f), 
    2727mViewCellsFinished(false), 
    28 mMaxPvsSize(99999), 
     28mMaxPvsSize(9999999), 
     29mMinPvsSize(1), // only empty view cells are invalid 
    2930mMaxPvsRatio(1.0) 
    3031{ 
     
    3940mPostProcessSamples(0), 
    4041mVisualizationSamples(0), 
    41 mViewCellsFinished(false) 
     42mTotalAreaValid(false), 
     43mTotalArea(0.0f), 
     44mViewCellsFinished(false), 
     45mMaxPvsSize(9999999), 
     46mMinPvsSize(1), // only empty view cells are invalid 
     47mMaxPvsRatio(1.0) 
    4248{ 
    4349        mViewSpaceBox.Initialize(); 
     
    111117 
    112118bool ViewCellsManager::CheckValidity(ViewCell *vc,  
    113                                                                          float minPvsRatio,  
    114                                                                          float maxPvsRatio) const 
    115 { 
    116         if ((vc->GetPvs().GetSize() > mMaxPvsSize * maxPvsRatio) || 
    117                 (vc->GetPvs().GetSize() < mMaxPvsSize * minPvsRatio)) 
     119                                                                         int minPvsSize,  
     120                                                                         int maxPvsSize) const 
     121{ 
     122        if ((vc->GetPvs().GetSize() > mMaxPvsSize) || 
     123                (vc->GetPvs().GetSize() < mMinPvsSize)) 
    118124        {        
    119125                return false; 
     
    121127 
    122128        return true; 
     129} 
     130 
     131 
     132void ViewCellsManager::SetValidity(ViewCell *vc,  
     133                                                                   int minPvs,  
     134                                                                   int maxPvs) const 
     135{ 
     136        vc->SetValid(CheckValidity(vc, minPvs, maxPvs)); 
    123137} 
    124138 
     
    427441 
    428442 
     443int ViewCellsManager::GetMinPvsSize() const 
     444{ 
     445        return mMinPvsSize; 
     446} 
     447 
     448 
     449 
    429450float ViewCellsManager::GetMaxPvsRatio() const 
    430451{ 
     
    442463        // matt TODO: remove this!! 
    443464        Ray hray(ray); 
     465        //static Ray hray; 
     466        //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 
     467         
    444468        float tmin = 0, tmax = 1.0; 
    445469 
    446         //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 
    447470        if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
    448471                return; 
     
    451474        Vector3 termination = hray.Extrap(tmax); 
    452475 
    453         CastLineSegment(origin, 
    454                                         termination, 
    455                                         viewcells); 
     476        CastLineSegment(origin, termination, viewcells); 
    456477        //Debug << "constribution: " << (int)viewcells.size() << endl; 
    457478        // copy viewcells memory efficiently 
     
    23732394                                                                                 ViewCell *vc) const 
    23742395{ 
    2375         if (CheckValidity(vc, 0.0, mMaxPvsRatio) && (mColorCode == 0)) // Random color 
     2396        if (CheckValidity(vc, mMinPvsSize, mMaxPvsSize) && (mColorCode == 0)) // Random color 
    23762397                return; 
    23772398 
     
    24062427        } 
    24072428 
    2408         m.mDiffuseColor.b = CheckValidity(vc, 0.0, mMaxPvsRatio) ? 1.0f : 0.0f; 
     2429        m.mDiffuseColor.b = CheckValidity(vc, mMinPvsSize, mMaxPvsSize) ? 1.0f : 0.0f; 
    24092430        m.mDiffuseColor.r = importance; 
    24102431        m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r; 
     
    24882509         
    24892510        mViewCellsFinished = true; 
     2511        mMaxPvsSize = (int)objects->size(); 
    24902512 
    24912513        FinalizeViewCells(true); 
    2492  
     2514         
    24932515        Debug << (int)mViewCells.size() << " view cells loaded" << endl; 
    24942516 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r561 r562  
    254254        */ 
    255255        virtual bool CheckValidity(ViewCell *vc,  
    256                                                            float minPvsRatio,  
    257                                                            float maxPvsRatio) const; 
     256                                                           int minPvsSize,  
     257                                                           int maxPvsSize) const; 
     258 
     259         
     260        /** Sets validity of view cell 
     261        */ 
     262        virtual void SetValidity(ViewCell *vc,  
     263                                                         int minPvsSize,  
     264                                                         int maxPvsSize) const; 
    258265 
    259266        /** Returns maximal allowed pvs size. 
    260267        */ 
    261268        int GetMaxPvsSize() const; 
     269 
     270        /** Returns maximal allowed pvs size. 
     271        */ 
     272        int GetMinPvsSize() const; 
    262273 
    263274        /** Returns maximal ratio. i.e., currentPVs / maxPvs, 
     
    338349 
    339350        int mMaxPvsSize; 
     351        int mMinPvsSize; 
    340352        float mMaxPvsRatio; 
    341353 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r561 r562  
    329329                float minT, maxT; 
    330330 
     331                //static Ray hray; 
     332                //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 
     333 
    331334                // TODO: not very efficient to implictly cast between rays types 
    332335                if (mBox.GetRaySegment(*ray, minT, maxT)) 
     
    393396                                                          geom); 
    394397 
     398        // first node is kd node 
     399        tData.mIsKdNode = true; 
     400 
    395401        tStack.push(tData); 
    396402 
     
    510516                } 
    511517                 
    512                 if (!mViewCellsManager->CheckValidity(viewCell, 0.0, mViewCellsManager->GetMaxPvsRatio())) 
     518                if (0 && !mViewCellsManager->CheckValidity(viewCell, 0, mViewCellsManager->GetMaxPvsSize())) 
    513519                { 
    514520                        viewCell->SetValid(false); 
     
    880886        box.Initialize(); 
    881887         
    882         //TODO: for kd split geometry already is box 
     888        //TODO: for kd split geometry already is box => only take minmax vertices 
    883889        if (1) 
    884890        { 
     
    9971003        const int pvsSize = data.mPvs; 
    9981004 
     1005        RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 
     1006 
    9991007        // this is the main ray classification loop! 
    1000         for(RayInfoContainer::iterator ri = data.mRays->begin(); 
    1001                 ri != data.mRays->end(); ++ ri) 
    1002         { 
    1003                 if (!(*ri).mRay->IsActive()) 
    1004                         continue; 
     1008        for(rit = data.mRays->begin(); rit != rit_end; ++ rit) 
     1009        { 
     1010                //if (!(*rit).mRay->IsActive()) continue; 
    10051011 
    10061012                // determine the side of this ray with respect to the plane 
    10071013                float t; 
    1008                 int side = (*ri).ComputeRayIntersection(axis, position, t); 
    1009          
    1010                 AddObjToPvs((*ri).mRay->mTerminationObject, side, pvsFront, pvsBack, pvsTotal); 
    1011                 AddObjToPvs((*ri).mRay->mOriginObject, side, pvsFront, pvsBack, pvsTotal); 
     1014                const int side = (*rit).ComputeRayIntersection(axis, position, t); 
     1015         
     1016                AddObjToPvs((*rit).mRay->mTerminationObject, side, pvsFront, pvsBack, pvsTotal); 
     1017                AddObjToPvs((*rit).mRay->mOriginObject, side, pvsFront, pvsBack, pvsTotal); 
    10121018        } 
    10131019 
     
    10151021        float pOverall; 
    10161022 
    1017         // -- simplified computation for mid split 
    1018          
    1019          
     1023        //-- compute heurstics 
     1024        //   we take simplified computation for mid split 
     1025                 
    10201026        pOverall = data.mProbability; 
    10211027 
     
    10461052        } 
    10471053 
    1048         //Debug << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 
    1049         //Debug << pFront << " " << pBack << " " << pOverall << endl; 
     1054#ifdef _DEBUG 
     1055        Debug << axis << " " << pvsSize << " " << pvsBack << " " << pvsFront << endl; 
     1056        Debug << pFront << " " << pBack << " " << pOverall << endl; 
     1057#endif 
    10501058 
    10511059        const float newCost = pvsBack * pBack + pvsFront * pFront; 
    1052         const float oldCost = (float)pvsSize * pOverall; 
     1060        const float oldCost = (float)pvsSize * pOverall + Limits::Small; 
    10531061 
    10541062        return  (mCtDivCi + newCost) / oldCost; 
     
    10981106        for (int i = 0; i < limit; ++ i) 
    10991107        { 
    1100                 //-- assure that no index is taken twice 
     1108                // the already taken candidates are stored behind maxIdx 
     1109                // => assure that no index is taken twice 
    11011110                const int candidateIdx = (int)RandomValue(0, (Real)(-- maxIdx)); 
    11021111                Polygon3 *poly = (*data.mPolygons)[candidateIdx]; 
     
    11271136                                                                                   &fGeom, &bGeom,  
    11281137                                                                                   pFront, pBack, 
    1129                                                                                    onlyAxisAligned);      
     1138                                                                                   data.mIsKdNode);       
     1139 
     1140        bool isAxisAlignedSplit = false; 
    11301141 
    11311142        if (candidateCost < lowestCost) 
     
    11361147                // assign already computed values 
    11371148                // we can do this because we always save the 
    1138                 // computed values from the axis aligned splits 
    1139                  
     1149                // computed values from the axis aligned splits          
    11401150                frontData.mGeometry = fGeom; 
    11411151                backData.mGeometry = bGeom; 
     
    11461156                //! error also computed if cost ratio is missed 
    11471157                ++ mStat.splits[axis]; 
     1158                isAxisAlignedSplit = true; 
    11481159        } 
    11491160        else 
     
    11521163                DEL_PTR(bGeom); 
    11531164        } 
     1165 
     1166        frontData.mIsKdNode = backData.mIsKdNode = (data.mIsKdNode && isAxisAlignedSplit); 
    11541167 
    11551168#ifdef _DEBUG 
     
    12951308                const int cf = rayInf.ComputeRayIntersection(candidatePlane, t); 
    12961309 
    1297         if (cf >= 0) 
    1298                         ++ raysFront; 
    1299                 if (cf <= 0) 
    1300                         ++ raysBack; 
     1310        if (0) 
     1311                { 
     1312                        if (cf >= 0) 
     1313                                ++ raysFront; 
     1314                        if (cf <= 0) 
     1315                                ++ raysBack; 
     1316                } 
    13011317 
    13021318                if (mSplitPlaneStrategy & LEAST_RAY_SPLITS) 
     
    13681384 
    13691385        // normalize cost by sum of linear factors 
    1370         return cost / (float)mCostNormalizer; 
     1386        if(0) 
     1387                return cost / (float)mCostNormalizer; 
     1388        else 
     1389                return cost; 
    13711390} 
    13721391 
     
    16441663                                BspViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 
    16451664                         
    1646                                 if (!mViewCellsManager->CheckValidity(viewCell, 0.0, mViewCellsManager->GetMaxPvsRatio())) 
     1665                                if (!mViewCellsManager->CheckValidity(viewCell, 
     1666                                                                                                          mViewCellsManager->GetMinPvsSize(),  
     1667                                                                                                          mViewCellsManager->GetMaxPvsSize())) 
    16471668                                { 
    16481669                                        vector<BspLeaf *>::const_iterator it, it_end = viewCell->mLeaves.end(); 
     
    16811702                } 
    16821703        } 
     1704 
     1705        Debug << "invalid leaves: " << mStat.invalidLeaves << endl; 
    16831706} 
    16841707 
     
    19181941 
    19191942int VspBspTree::FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors, 
    1920                                                    const bool onlyUnmailed) const 
     1943                                                          const bool onlyUnmailed) const 
    19211944{ 
    19221945        stack<bspNodePair> nodeStack; 
     
    19371960        nodeStack.push(bspNodePair(mRoot, rgeom)); 
    19381961 
    1939         Debug << "here77" << endl; 
    1940  
    19411962        while (!nodeStack.empty()) 
    19421963        { 
    19431964                BspNode *node = nodeStack.top().first; 
    19441965                BspNodeGeometry *geom = nodeStack.top().second; 
    1945  
     1966         
    19461967                nodeStack.pop(); 
    19471968 
    19481969                if (node->IsLeaf()) 
    1949                 {        
    1950                         Debug << "here22" << endl; 
     1970                { 
    19511971                        // test if this leaf is in valid view space 
    19521972                        if (node->TreeValid() && 
     
    19541974                                (!onlyUnmailed || !node->Mailed())) 
    19551975                        { 
    1956                                 Debug << "here" << endl; 
    19571976                                bool isAdjacent = true; 
    1958 #if 1 
    1959  
    1960                                 // test all planes of current node if still adjacent 
    1961                                 for (int i = 0; (i < halfSpaces.size()) && isAdjacent; ++ i) 
     1977 
     1978                                if (1) 
    19621979                                { 
    1963                                         const int cf = 
    1964                                                 Polygon3::ClassifyPlane(geom->mPolys, 
    1965                                                                                                 halfSpaces[i], 
    1966                                                                                                 mEpsilon); 
    1967  
    1968                                         if (cf == Polygon3::BACK_SIDE) 
     1980                                        // test all planes of current node if still adjacent 
     1981                                        for (int i = 0; (i < halfSpaces.size()) && isAdjacent; ++ i) 
    19691982                                        { 
    1970                                                 isAdjacent = false; 
     1983                                                const int cf = 
     1984                                                        Polygon3::ClassifyPlane(geom->mPolys, 
     1985                                                                                                        halfSpaces[i], 
     1986                                                                                                        mEpsilon); 
     1987 
     1988                                                if (cf == Polygon3::BACK_SIDE) 
     1989                                                { 
     1990                                                        isAdjacent = false; 
     1991                                                } 
    19711992                                        } 
    19721993                                } 
    1973 #else // TODO: why is this wrong?? 
    1974                                 // test all planes of current node if still adjacent 
    1975                                 for (int i = 0; (i < (int)nodeGeom.mPolys.size()) && isAdjacent; ++ i) 
     1994                                else 
    19761995                                { 
    1977                                         Debug << "here33" << endl; 
    1978                                         Polygon3 *poly = nodeGeom.mPolys[i]; 
    1979  
    1980                                         const int cf = 
    1981                                                 Polygon3::ClassifyPlane(geom->mPolys, 
    1982                                                                                                 poly->GetSupportingPlane(), 
    1983                                                                                                 mEpsilon); 
    1984  
    1985                                         if (cf == Polygon3::BACK_SIDE) 
     1996                                        // TODO: why is this wrong?? 
     1997                                        // test all planes of current node if still adjacent 
     1998                                        for (int i = 0; (i < (int)nodeGeom.mPolys.size()) && isAdjacent; ++ i) 
    19861999                                        { 
    1987                                                 isAdjacent = false; 
     2000                                                Polygon3 *poly = nodeGeom.mPolys[i]; 
     2001 
     2002                                                const int cf = 
     2003                                                        Polygon3::ClassifyPlane(geom->mPolys, 
     2004                                                                                                        poly->GetSupportingPlane(), 
     2005                                                                                                        mEpsilon); 
     2006 
     2007                                                if (cf == Polygon3::BACK_SIDE) 
     2008                                                { 
     2009                                                        isAdjacent = false; 
     2010                                                } 
    19882011                                        } 
    19892012                                } 
    1990 #endif 
    1991                                 Debug << "here2" << endl; 
    19922013                                // neighbor was found 
    19932014                                if (isAdjacent) 
     2015                                {        
    19942016                                        neighbors.push_back(dynamic_cast<BspLeaf *>(node)); 
     2017                                } 
     2018                        } 
     2019                } 
     2020                else 
     2021                { 
     2022                        BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     2023 
     2024                        const int cf = Polygon3::ClassifyPlane(nodeGeom.mPolys, 
     2025                                                                                                   interior->GetPlane(), 
     2026                                                                                                   mEpsilon); 
     2027                         
     2028                        BspNode *front = interior->GetFront(); 
     2029                        BspNode *back = interior->GetBack(); 
     2030             
     2031                        BspNodeGeometry *fGeom = new BspNodeGeometry(); 
     2032                        BspNodeGeometry *bGeom = new BspNodeGeometry(); 
     2033 
     2034                        geom->SplitGeometry(*fGeom, 
     2035                                                                *bGeom, 
     2036                                                                interior->GetPlane(), 
     2037                                                                mBox, 
     2038                                                                mEpsilon); 
     2039                 
     2040                        if (cf == Polygon3::FRONT_SIDE) 
     2041                        { 
     2042                                nodeStack.push(bspNodePair(interior->GetFront(), fGeom)); 
     2043                                DEL_PTR(bGeom); 
    19952044                        } 
    19962045                        else 
    19972046                        { 
    1998                                 BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    1999  
    2000                                 const int cf = Polygon3::ClassifyPlane(nodeGeom.mPolys, 
    2001                                                                                                            interior->GetPlane(), 
    2002                                                                                                            mEpsilon); 
    2003                          
    2004                                 BspNode *front = interior->GetFront(); 
    2005                                 BspNode *back = interior->GetBack(); 
    2006              
    2007                                 BspNodeGeometry *fGeom = new BspNodeGeometry(); 
    2008                                 BspNodeGeometry *bGeom = new BspNodeGeometry(); 
    2009  
    2010                                 geom->SplitGeometry(*fGeom, 
    2011                                                                         *bGeom, 
    2012                                                                         interior->GetPlane(), 
    2013                                                                         mBox, 
    2014                                                                         mEpsilon); 
    2015                  
    2016                                 if (cf == Polygon3::FRONT_SIDE) 
     2047                                if (cf == Polygon3::BACK_SIDE) 
    20172048                                { 
    2018                                         nodeStack.push(bspNodePair(interior->GetFront(), fGeom)); 
    2019                                         DEL_PTR(bGeom); 
     2049                                        nodeStack.push(bspNodePair(interior->GetBack(), bGeom)); 
     2050                                        DEL_PTR(fGeom); 
    20202051                                } 
    20212052                                else 
    2022                                 { 
    2023                                         if (cf == Polygon3::BACK_SIDE) 
    2024                                         { 
    2025                                                 nodeStack.push(bspNodePair(interior->GetBack(), bGeom)); 
    2026                                                 DEL_PTR(fGeom); 
    2027                                         } 
    2028                                         else 
    2029                                         {       // random decision 
    2030                                                 nodeStack.push(bspNodePair(front, fGeom)); 
    2031                                                 nodeStack.push(bspNodePair(back, bGeom)); 
    2032                                         } 
     2053                                {       // random decision 
     2054                                        nodeStack.push(bspNodePair(front, fGeom)); 
     2055                                        nodeStack.push(bspNodePair(back, bGeom)); 
    20332056                                } 
    20342057                        } 
    20352058                } 
    2036  
     2059         
    20372060                DEL_PTR(geom); 
    20382061        } 
     
    27922815        mergeStats.Start(); 
    27932816        // TODO: REMOVE LATER for performance! 
    2794         const bool showMergeStats = true; 
     2817        const bool showMergeStats = false; 
     2818 
    27952819        //BspMergeCandidate::sOverallCost = mBox.SurfaceArea() * mStat.maxPvs; 
    27962820        long startTime = GetTime(); 
     
    28082832                mergeStats.nodes = CollectMergeCandidates(leaves); 
    28092833        } 
    2810          
     2834                 
    28112835 
    28122836        mergeStats.collectTime = TimeDiff(startTime, GetTime()); 
     
    28142838        startTime = GetTime(); 
    28152839 
     2840        // number of view cells withouth the invalid ones 
    28162841        int nViewCells = mStat.Leaves() - mStat.invalidLeaves; 
    2817         int pass = 0; 
    2818         const int nextPass = 200; 
    2819  
    2820         cout << "starting merge ... "; 
     2842        Debug << "number of view cells taken into account: " << nViewCells << endl; 
     2843        // pass is needed for statistics. the last n passes are 
     2844        // recorded 
     2845        const int maxPasses = 1000; 
     2846        int pass = max(nViewCells - mMergeMinViewCells - maxPasses, 0); 
     2847        const int nextPass = 50; 
     2848 
     2849        cout << "starting merge ... " << endl; 
    28212850 
    28222851        //-- use priority queue to merge leaf pairs 
     
    28252854                    mMergeMaxCostRatio * BspMergeCandidate::sOverallCost)) 
    28262855        { 
    2827                 /*Debug << "abs mergecost: " << mMergeQueue.top().GetMergeCost() << " rel mergecost: " 
     2856#ifdef _DEBUG 
     2857                Debug << "abs mergecost: " << mMergeQueue.top().GetMergeCost() << " rel mergecost: " 
    28282858                          << mMergeQueue.top().GetMergeCost() / BspMergeCandidate::sOverallCost  
    2829                           << " max ratio: " << mMergeMaxCostRatio << endl;*/ 
     2859                          << " max ratio: " << mMergeMaxCostRatio << endl; 
     2860#endif 
     2861 
    28302862                BspMergeCandidate mc = mMergeQueue.top(); 
    28312863                mMergeQueue.pop(); 
     
    28412873 
    28422874                        MergeViewCells(mc.GetLeaf1(), mc.GetLeaf2()); 
    2843                                                  
    2844                          
     2875                                         
    28452876                        // increase absolute merge cost 
    28462877                        BspMergeCandidate::sOverallCost += mc.GetMergeCost(); 
    28472878                         
     2879 
     2880                        -- nViewCells; 
     2881                        ++ mergeStats.merged; 
    28482882 
    28492883                        if (showMergeStats) 
     
    28582892                                mergeStats.accTreeDist += dist; 
    28592893 
    2860  
    2861                                 if (((mergeStats.merged % nextPass) == 0) || (nViewCells == mMergeMinViewCells)) 
     2894                                //Debug << "viewcells: " << nViewCells << " mergemin " << mMergeMinViewCells << endl; 
     2895                                if ((mergeStats.merged == pass) || (nViewCells == mMergeMinViewCells)) 
    28622896                                { 
     2897                                        pass += nextPass; 
    28632898                                        mStats  
    28642899                                                << "#Pass\n" << pass ++ << endl 
    28652900                                                << "#Merged\n" << mergeStats.merged << endl  
    28662901                                                << "#Viewcells\n" << nViewCells << endl  
    2867                                                 << "#OverallCost\n" << BspMergeCandidate::sOverallCost << endl  
     2902                                                << "#OverallCost\n" << BspMergeCandidate::sOverallCost << endl 
    28682903                                                << "#CurrentCost\n" << mergeCost << endl 
    2869                                                 << "#RelCost\n" << mc.GetMergeCost() / BspMergeCandidate::sOverallCost << endl 
     2904                                                << "#RelativeCost\n" << mergeCost / BspMergeCandidate::sOverallCost << endl 
    28702905                                                << "#CurrentPvs\n" << mc.GetLeaf1()->GetViewCell()->GetPvs().GetSize() << endl; 
    2871  
    2872                                         cout << "exporting view cells ... "; 
    2873                                                                  
    2874                                  
     2906                                         
    28752907                                        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    28762908                                         
     
    28822914                                                while (!viewCells.empty() && (viewCells.back()->GetId() == -2)) 
    28832915                                                { 
    2884                                                         DEL_PTR(viewCells.back()); 
     2916                                                        //DEL_PTR(viewCells.back()); 
    28852917                                                        viewCells.pop_back(); 
    28862918                                                } 
     
    28972929                                        } 
    28982930                                 
    2899                                         cout << "finished" << endl; 
    2900                                         // not part of any leaf 
    2901                                         //CLEAR_CONTAINER(mOldViewCells); 
    2902                                         mOldViewCells.clear(); 
    2903  
    2904                                         int newVcSize = (int)mNewViewCells.size(); 
    2905                                         // add new view cells to container 
     2931                                        int newVcSize = 0; 
     2932                                        // add new view cells to container only if they don't have been  
     2933                                        // merged in the mean time 
    29062934                                        while (!mNewViewCells.empty()) 
    29072935                                        { 
    2908                                                 viewCells.push_back(mNewViewCells.back()); 
     2936                                                if (mNewViewCells.back()->GetId() != -2) 
     2937                                                { 
     2938                                                        viewCells.push_back(mNewViewCells.back()); 
     2939                                                        ++ newVcSize; 
     2940                                                } 
     2941 
    29092942                                                mNewViewCells.pop_back(); 
    29102943                                        } 
     2944 
     2945                                        // delete the view cells which were merged 
     2946                                        CLEAR_CONTAINER(mOldViewCells); 
    29112947 
    29122948                                        char s[64]; 
     
    29162952                                        if (exporter) 
    29172953                                        { 
     2954                                                cout << "exporting " << nViewCells << " merged view cells ... "; 
    29182955                                                exporter->ExportGeometry(objects); 
    2919                                                 Debug << "vc size " << (int)viewCells.size() << " merge queue size: " << (int)mMergeQueue.size() << endl; 
     2956                                                //Debug << "vc size " << (int)viewCells.size() << " merge queue size: " << (int)mMergeQueue.size() << endl; 
    29202957                                                ViewCellContainer::const_iterator it, it_end = viewCells.end(); 
    29212958                 
    2922                                                 // new view cells are on the back 
    29232959                                                int i = 0; 
    29242960                                                for (it = viewCells.begin(); it != it_end; ++ it) 
     
    29262962                                                        Material m; 
    29272963                                                        // assign special material to new view cells 
    2928                                                         if (i >= (viewCells.size() - newVcSize)) 
     2964                                                        // new view cells are on the back of container 
     2965                                                        if (i ++ >= (viewCells.size() - newVcSize)) 
    29292966                                                        { 
    29302967                                                                //m = RandomMaterial(); 
    2931                                                                 m.mDiffuseColor.r = RandomValue(0.5, 1.0); 
    2932                                                                 m.mDiffuseColor.g = RandomValue(0.5, 1.0); 
    2933                                                                 m.mDiffuseColor.b = RandomValue(0.5, 1.0); 
     2968                                                                m.mDiffuseColor.r = RandomValue(0.5f, 1.0f); 
     2969                                                                m.mDiffuseColor.g = RandomValue(0.5f, 1.0f); 
     2970                                                                m.mDiffuseColor.b = RandomValue(0.5f, 1.0f); 
    29342971                                                        } 
    29352972                                                        else 
    29362973                                                        { 
    2937                                                                 float col = RandomValue(0.1, 0.4); 
     2974                                                                float col = RandomValue(0.1f, 0.4f); 
    29382975                                                                m.mDiffuseColor.r = col; 
    29392976                                                                m.mDiffuseColor.g = col; 
     
    29442981                                                        mViewCellsManager->ExportVcGeometry(exporter, *it); 
    29452982                                                } 
     2983                                                delete exporter; 
     2984                                                cout << "finished" << endl; 
     2985                                        } 
    29462986                                         
    2947                                                 delete exporter; 
    2948                                         } 
    2949                                         cout << "finished " << endl; 
    2950  
    29512987                                } 
    29522988                        } 
    2953  
    2954                         -- nViewCells; 
    2955                         ++ mergeStats.merged; 
     2989                        mNewViewCells.clear(); 
    29562990                } 
    29572991                // merge candidate not valid, because one of the leaves was already 
     
    29642998        } 
    29652999 
    2966  
     3000        // view cells which were merged and are not part of any leaf 
     3001        CLEAR_CONTAINER(mOldViewCells); 
     3002         
    29673003        cout << "finished merge" << endl; 
    29683004        mergeStats.mergeTime = TimeDiff(startTime, GetTime()); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r557 r562  
    6060                /// how often this branch has missed the max-cost ratio 
    6161                int mMaxCostMisses; 
     62                /// if this node is a kd-node (i.e., boundaries are axis aligned 
     63                bool mIsKdNode; 
    6264                /// bounding box of current view space. 
    6365                ///AxisAlignedBox3 mBbox; 
     
    7981                mProbability(0.0), 
    8082                mGeometry(NULL), 
    81                 mMaxCostMisses(0) 
    82                 //,mIsAxisAligned(false) 
     83                mMaxCostMisses(0),  
     84                mIsKdNode(false) 
    8385                {} 
    8486                 
     
    9799                mProbability(p), 
    98100                mGeometry(geom), 
    99                 mMaxCostMisses(0) 
     101                mMaxCostMisses(0), 
     102                mIsKdNode(false) 
    100103                {} 
    101104 
     
    111114                mProbability(0), 
    112115                mGeometry(geom), 
    113                 mMaxCostMisses(0) 
     116                mMaxCostMisses(0), 
     117                mIsKdNode(false) 
    114118                {} 
    115119 
Note: See TracChangeset for help on using the changeset viewer.