Ignore:
Timestamp:
08/20/07 12:51:12 (17 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp

    r2539 r2542  
    106106                                        int nodesTested = 0; 
    107107 
    108 #if 1 
    109                                         // test a certain ratio of random candidates 
    110                                         HierarchyNodeContainer mynodes; 
    111                                         mHierarchyInterface->CollectLeaves(node, mynodes); 
    112  
    113                                         const int p = mRandomCandidates * RAND_MAX / (int)mynodes.size(); 
    114  
    115                                         HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 
    116  
    117                                         for (nit = mynodes.begin(); nit != nit_end; ++ nit) 
     108                                        if(1) 
    118109                                        { 
    119                                                 HierarchyNode *leaf = *nit; 
    120  
    121                                                 if (rand() > p) 
    122                                                         continue; 
     110                                                // test a certain ratio of random candidates 
     111                                                HierarchyNodeContainer mynodes; 
     112                                                mHierarchyInterface->CollectLeaves(node, mynodes); 
     113 
     114                                                const int p = mRandomCandidates * RAND_MAX / (int)mynodes.size(); 
     115 
     116                                                HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 
     117 
     118                                                for (nit = mynodes.begin(); nit != nit_end; ++ nit) 
     119                                                { 
     120                                                        HierarchyNode *leaf = *nit; 
     121 
     122                                                        if (rand() > p) 
     123                                                                continue; 
     124 
     125                                                        bool intersects = false; 
     126                                                        const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 
     127 
     128                                                        // don't test in these cases ... 
     129                                                        if (frustumCulled || intersects) 
     130                                                                continue; 
     131 
     132                                                        ++ nodesTested; 
     133 
     134                                                        mHierarchyInterface->SetNodeVisible(leaf, false); 
     135 
     136                                                        // update node's visited flag: this is important as we are not testing 
     137                                                        // all nodes in the hierarchy in this mode 
     138                                                        mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
     139                                                        // issue the query 
     140                                                        mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves); 
     141                                                } 
     142 
     143                                                //std::stringstream d; d << "rc: " << mRandomCandidates << " tested: " << nodesTested << " of " << (int)mynodes.size(); 
     144                                                //CullingLogManager::GetSingleton()->LogMessage(d.str()); 
     145                                        } 
     146                                        else 
     147                                        { 
     148                                                // always test one random candidate 
     149                                                HierarchyNode *leaf = mHierarchyInterface->GetRandomLeaf(node); 
    123150 
    124151                                                bool intersects = false; 
    125152                                                const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 
    126153 
    127                                                 // don't test in these cases ... 
    128                                                 if (frustumCulled || intersects) 
     154                                                if (frustumCulled || intersects) // don't test in these cases ... 
    129155                                                        continue; 
    130                  
     156 
    131157                                                ++ nodesTested; 
    132                                                  
     158 
    133159                                                mHierarchyInterface->SetNodeVisible(leaf, false); 
    134160 
     
    137163                                                mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
    138164                                                // issue the query 
    139                                                 mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves); 
     165                                                mHierarchyInterface->IssueNodeOcclusionQuery(leaf, mTestGeometryForVisibleLeaves); 
    140166                                        } 
    141167 
    142                                         //std::stringstream d; d << "rc: " << mRandomCandidates << " tested: " << nodesTested << " of " << (int)mynodes.size(); 
    143                                         //CullingLogManager::GetSingleton()->LogMessage(d.str()); 
    144  
    145 #else 
    146                                         // always test one random candidate 
    147                                         HierarchyNode *leaf = mHierarchyInterface->GetRandomLeaf(node); 
    148                                          
    149                                         bool intersects = false; 
    150                                         const bool frustumCulled = !mHierarchyInterface->CheckFrustumVisible(leaf, intersects); 
    151  
    152                                         if (frustumCulled || intersects) // don't test in these cases ... 
    153                                                 continue; 
    154  
    155                                         ++ nodesTested; 
    156  
    157                                         mHierarchyInterface->SetNodeVisible(leaf, false); 
    158  
    159                                         // update node's visited flag: this is important as we are not testing 
    160                                         // all nodes in the hierarchy in this mode 
    161                                         mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
    162                                         // issue the query 
    163                                         mHierarchyInterface->IssueNodeOcclusionQuery(leaf, mTestGeometryForVisibleLeaves); 
    164  
    165 #endif 
    166                                          
     168                                        // render the whole subtree 
    167169                                        mHierarchyInterface->RenderNodeRecursive(node); 
    168170 
Note: See TracChangeset for help on using the changeset viewer.