Changeset 338


Ignore:
Timestamp:
10/18/05 11:17:29 (19 years ago)
Author:
mattausch
Message:

fixed bug in balanced view cell criterium
started merge view cells functionality

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj

    r309 r338  
    6565                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" 
    6666                                RuntimeLibrary="2" 
     67                                DisableLanguageExtensions="FALSE" 
     68                                ForceConformanceInForLoopScope="FALSE" 
    6769                                RuntimeTypeInfo="TRUE" 
    6870                                UsePrecompiledHeader="0" 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r333 r338  
    3030        int limit = maxViewCells > 0 ? Min((int)objects.size(), maxViewCells) : (int)objects.size(); 
    3131 
    32         for (int i = 0; i < limit; ++i) 
     32        for (int i = 0; i < limit; ++ i) 
    3333        { 
    3434                Intersectable *object = objects[i]; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r337 r338  
    10991099        int totalViewCells = 0; 
    11001100 
     1101        // needed for balanced view cells criterium 
    11011102        ViewCell::NewMail(); 
    1102          
     1103        int backId = ViewCell::mailID; 
     1104        ViewCell::NewMail(); 
     1105        int frontId = ViewCell::mailID; 
     1106        ViewCell::NewMail(); 
     1107        int frontAndBackId = ViewCell::mailID; 
     1108 
    11031109        PolygonContainer::const_iterator it, it_end = polys.end(); 
    11041110 
     
    11351141                        MeshInstance *viewCell = (*it)->mParent; 
    11361142                 
    1137                         if (!viewCell->Mailed()) 
     1143                        // assure that we only count a view cell  
     1144                        // once for the front and once for the back side of the plane 
     1145                        if (classification == Plane3::FRONT_SIDE) 
    11381146                        { 
    1139                                 viewCell->Mail(); 
    1140                                 sumBalancedViewCells += sBalancedTreeTable[classification]; 
    1141  
    1142                                 ++ totalViewCells; 
     1147                                if ((viewCell->mailbox != frontId) &&  
     1148                                        (viewCell->mailbox != frontAndBackId)) 
     1149                                { 
     1150                                        sumBalancedViewCells += 1.0; 
     1151 
     1152                                        if (viewCell->mailbox != backId) 
     1153                                                viewCell->mailbox = frontId; 
     1154                                        else 
     1155                                                viewCell->mailbox = frontAndBackId; 
     1156                                         
     1157                                        ++ totalViewCells; 
     1158                                } 
     1159                        } 
     1160                        else if (classification == Plane3::BACK_SIDE) 
     1161                        { 
     1162                                if ((viewCell->mailbox != backId) && 
     1163                                    (viewCell->mailbox != frontAndBackId)) 
     1164                                { 
     1165                                        sumBalancedViewCells -= 1.0; 
     1166 
     1167                                        if (viewCell->mailbox != frontId) 
     1168                                                viewCell->mailbox = backId; 
     1169                                        else 
     1170                                                viewCell->mailbox = frontAndBackId;  
     1171 
     1172                                        ++ totalViewCells; 
     1173                                } 
    11431174                        } 
    11441175                } 
     
    15491580} 
    15501581 
     1582int BspTree::MergeViewCells() 
     1583{ 
     1584        stack<BspNode *> nodeStack; 
     1585        nodeStack.push(mRoot); 
     1586 
     1587        ViewCell::NewMail(); 
     1588 
     1589        while (!nodeStack.empty())  
     1590        { 
     1591                BspNode *node = nodeStack.top(); 
     1592                nodeStack.pop(); 
     1593 
     1594                if (node->IsLeaf())  
     1595                { 
     1596                } 
     1597                else  
     1598                { 
     1599                        BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     1600 
     1601                        nodeStack.push(interior->mFront); 
     1602                        nodeStack.push(interior->mBack); 
     1603                } 
     1604        } 
     1605        return 0; 
     1606} 
     1607 
    15511608void BspTree::SetGenerateViewCells(int generateViewCells) 
    15521609{ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r336 r338  
    348348        int CastRay(Ray &ray); 
    349349 
    350         /** Set true if view cells shall be generated in each leaf. 
     350        /** Merges view cells based on some criteria (e.g., empty view cells or 
     351                view cells which have a very similar PVS can be merged to one larger 
     352                view cell farther up in the BSP tree. 
     353                @returns the number of merged view cells 
     354        */ 
     355        int MergeViewCells(); 
     356 
     357        /** Set to true if new view cells shall be generated in each leaf. 
    351358        */ 
    352359        void SetGenerateViewCells(int generateViewCells); 
Note: See TracChangeset for help on using the changeset viewer.