Ignore:
Timestamp:
12/02/05 02:02:07 (19 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r441 r442  
    218218/****************************************************************/ 
    219219 
    220 VspBspTree::VspBspTree(BspViewCell *viewCell):  
    221 mRootCell(viewCell),  
    222 mRoot(NULL),  
    223 mStoreLeavesWithRays(false), 
    224 mPvsUseLen(true) 
    225 { 
     220VspBspTree::VspBspTree():  
     221mRoot(NULL), 
     222mPvsUseArea(true) 
     223{ 
     224        mRootCell = new BspViewCell(); 
     225 
    226226        Randomize(); // initialise random generator for heuristics 
    227227 
     
    349349{ 
    350350        DEL_PTR(mRoot); 
     351        DEL_PTR(mRootCell); 
    351352} 
    352353 
     
    485486 
    486487        VspBspTraversalData tData(mRoot, polys, 0, mRootCell, rays,  
    487                                                    ComputePvsSize(*rays)); 
     488                                                   ComputePvsSize(*rays), cell->GetArea(), cell); 
    488489 
    489490        tStack.push(tData); 
     
    515516                (((int)data.mRays->size() <= mTermMinRays) || 
    516517                 (data.mPvs <= mTermMinPvs) || 
     518                 (data.mArea <= mTermMinArea) || 
    517519                 (data.mDepth >= mTermMaxDepth) || 
    518520                 (data.GetAvgRayContribution() < mTermMaxRayContribution)); 
     
    547549                DEL_PTR(tData.mPolygons); 
    548550                DEL_PTR(tData.mRays); 
    549                 //DEL_PTR(tData.mGeometry); 
     551                DEL_PTR(tData.mGeometry); 
    550552                 
    551553                return leaf; 
     
    556558         
    557559        VspBspTraversalData tFrontData(NULL, new PolygonContainer(), tData.mDepth + 1, mRootCell,  
    558                                                                 new RayInfoContainer(), 0); 
     560                                                                new RayInfoContainer(), 0, 0, new VspBspNodeGeometry()); 
    559561        VspBspTraversalData tBackData(NULL, new PolygonContainer(), tData.mDepth + 1, mRootCell,  
    560                                                            new RayInfoContainer(), 0); 
     562                                                           new RayInfoContainer(), 0, 0, new VspBspNodeGeometry()); 
    561563 
    562564        // create new interior node and two leaf nodes 
     
    582584        DEL_PTR(tData.mPolygons); 
    583585        DEL_PTR(tData.mRays); 
    584         //DEL_PTR(tData.mGeometry);              
     586        DEL_PTR(tData.mGeometry);                
    585587 
    586588        return interior; 
     
    615617        frontData.mPvs = ComputePvsSize(*frontData.mRays); 
    616618        backData.mPvs = ComputePvsSize(*backData.mRays); 
     619 
     620        // split geometry and compute area 
     621        if (1) 
     622        { 
     623                tData.mGeometry->SplitGeometry(*frontData.mGeometry,  
     624                                                                           *backData.mGeometry,  
     625                                                                           *this,  
     626                                                                           interior->mPlane); 
     627         
     628                 
     629                frontData.mArea = frontData.mGeometry->GetArea(); 
     630                backData.mArea = backData.mGeometry->GetArea(); 
     631        } 
    617632 
    618633        // compute accumulated ray length 
     
    9911006        float pBack = 0; 
    9921007 
     1008        const bool pvsUseLen = false; 
     1009 
    9931010        if (mSplitPlaneStrategy & PVS) 
     1011        { 
    9941012                // create unique ids for pvs heuristics 
    9951013                GenerateUniqueIdsForPvs(); 
    9961014         
     1015                if (mPvsUseArea) // use front and back cell areas to approximate volume 
     1016                {        
     1017                        // construct child geometry with regard to the candidate split plane 
     1018                        VspBspNodeGeometry frontCell; 
     1019                        VspBspNodeGeometry backCell; 
     1020 
     1021                        data.mGeometry->SplitGeometry(frontCell, backCell, *this, candidatePlane); 
     1022                 
     1023                        pFront = frontCell.GetArea(); 
     1024                        pBack = backCell.GetArea(); 
     1025 
     1026                        pOverall = data.mArea; 
     1027                } 
     1028        } 
    9971029                         
    9981030        RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 
     
    10261058                        AddObjToPvs(ray->mOriginObject, cf, frontPvs, backPvs); 
    10271059                         
    1028                         float len = 1; 
    1029  
    1030                         if (mPvsUseLen) // use front and back cell areas to approximate volume 
    1031                                 len = (*rit).SqrSegmentLength(); 
     1060                        // use number or length of rays to approximate volume 
     1061                        if (!mPvsUseArea) 
     1062                        { 
     1063                                float len = 1; 
     1064 
     1065                                if (pvsUseLen) // use length of rays 
     1066                                        len = (*rit).SqrSegmentLength(); 
    10321067                         
    1033                         pOverall += len; 
    1034  
    1035                         // use length of rays to approximate volume 
    1036                         if (cf == 1) 
    1037                                 pFront += len; 
    1038                         if (cf == -1) 
    1039                                 pBack += len; 
    1040                         if (cf == 0) 
    1041                         { 
    1042                                 if (mPvsUseLen) 
     1068                                pOverall += len; 
     1069 
     1070                                if (cf == 1) 
     1071                                        pFront += len; 
     1072                                if (cf == -1) 
     1073                                        pBack += len; 
     1074                                if (cf == 0) 
    10431075                                { 
    1044                                         float newLen = len *  
    1045                                                 ((*rit).GetMaxT() - (*rit).mRay->mT) /  
    1046                                                 ((*rit).GetMaxT() - (*rit).GetMinT()); 
    1047  
    1048                                  
    1049                                         if (candidatePlane.Side((*rit).ExtrapOrigin()) <= 0) 
     1076                                        // use length of rays to approximate volume 
     1077                                        if (pvsUseLen)  
    10501078                                        { 
    1051                                                 pBack += newLen; 
    1052                                                 pFront += len - newLen; 
     1079                                                float newLen = len *  
     1080                                                        ((*rit).GetMaxT() - (*rit).mRay->mT) /  
     1081                                                        ((*rit).GetMaxT() - (*rit).GetMinT()); 
     1082                 
     1083                                                if (candidatePlane.Side((*rit).ExtrapOrigin()) <= 0) 
     1084                                                { 
     1085                                                        pBack += newLen; 
     1086                                                        pFront += len - newLen; 
     1087                                                } 
     1088                                                else 
     1089                                                { 
     1090                                                        pFront += newLen; 
     1091                                                        pBack += len - newLen; 
     1092                                                } 
    10531093                                        } 
    10541094                                        else 
    10551095                                        { 
    1056                                                 pFront += newLen; 
    1057                                                 pBack += len - newLen; 
     1096                                                ++ pFront; 
     1097                                                ++ pBack; 
    10581098                                        } 
    10591099                                } 
    1060                                 else 
    1061                                 { 
    1062                                         ++ pFront; 
    1063                                         ++ pBack; 
    1064                                 } 
    10651100                        } 
    10661101                } 
     
    10831118                // give penalty to unbalanced split 
    10841119                if (0) 
    1085                 if (((pFront * 0.2 + Limits::Small) > pBack) || (pFront < (pBack * 0.2 + Limits::Small))) 
     1120                if (((pFront * 0.2 + Limits::Small) > pBack) ||  
     1121                        (pFront < (pBack * 0.2 + Limits::Small))) 
    10861122                        val += 0.5; 
    10871123        } 
     
    11991235                ++ mStat.maxRayContribNodes; 
    12001236         
     1237        if (data.mGeometry->GetArea() <= mTermMinArea)  
     1238                ++ mStat.minAreaNodes; 
    12011239 
    12021240#ifdef _DEBUG 
     
    19842022        app << "===== END OF VspBspViewCells statistics ==========\n"; 
    19852023} 
     2024 
     2025BspViewCell *VspBspTree::GetRootCell() const 
     2026{ 
     2027        return mRootCell; 
     2028} 
Note: See TracChangeset for help on using the changeset viewer.