Changeset 2556 for GTP/trunk


Ignore:
Timestamp:
10/08/07 13:57:35 (17 years ago)
Author:
mattausch
Message:

implemented part of chc++

Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC
Files:
4 edited

Legend:

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

    r2555 r2556  
    240240        //////// 
    241241        //-- the actual query test 
     242 
    242243        query->BeginQuery(); 
    243244 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreSolidBoundingBox.cpp

    r2532 r2556  
    8484void SolidBoundingBox::SetupBoundingBoxVertices(const AxisAlignedBox& aab)  
    8585{ 
    86         const Vector3& min = aab.getMinimum(); 
    87     const Vector3& max = aab.getMaximum(); 
     86        const Vector3& minV = aab.getMinimum(); 
     87    const Vector3& maxV = aab.getMaximum(); 
    8888 
    8989        // fill the vertex buffer: 12 lines with 2 endpoints each make up a box 
     
    9393    float* pPos = static_cast<float*>(vbuf->lock(HardwareBuffer::HBL_DISCARD)); 
    9494 
    95         *pPos++ = min.x; *pPos++ = max.y; *pPos++ = min.z;  
    96         *pPos++ = max.x; *pPos++ = max.y; *pPos++ = min.z;  
    97         *pPos++ = max.x; *pPos++ = min.y; *pPos++ = min.z;  
    98         *pPos++ = min.x; *pPos++ = min.y; *pPos++ = min.z;  
     95        pPos[0]  = minV.x; pPos[1]  = maxV.y; pPos[2]  = minV.z;  
     96        pPos[3]  = maxV.x; pPos[4]  = maxV.y; pPos[5]  = minV.z;  
     97        pPos[6]  = maxV.x; pPos[7]  = minV.y; pPos[8]  = minV.z;  
     98        pPos[9]  = minV.x; pPos[10]  = minV.y; pPos[11] = minV.z;  
    9999                 
    100         *pPos++ = min.x; *pPos++ = max.y; *pPos++ = max.z;  
    101         *pPos++ = max.x; *pPos++ = max.y; *pPos++ = max.z;  
    102         *pPos++ = max.x; *pPos++ = min.y; *pPos++ = max.z;  
    103         *pPos++ = min.x; *pPos++ = min.y; *pPos++ = max.z; 
     100        pPos[12] = minV.x; pPos[13] = maxV.y; pPos[14] = maxV.z;  
     101        pPos[15] = maxV.x; pPos[16] = maxV.y; pPos[17] = maxV.z;  
     102        pPos[18] = maxV.x; pPos[19] = minV.y; pPos[20] = maxV.z;  
     103        pPos[21] = minV.x; pPos[22] = minV.y; pPos[23] = maxV.z; 
    104104 
    105105    vbuf->unlock(); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp

    r2555 r2556  
    191191{ 
    192192        // parent was tested invisible in this frame 
    193     return (  
     193    const bool nodeInvalid = (  
    194194                    mHierarchyInterface->GetParent(node) &&  
    195195                    (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId()) &&  
    196196                    !mHierarchyInterface->IsNodeVisible(mHierarchyInterface->GetParent(node)) 
    197197           ); 
     198 
     199         
     200        if (nodeInvalid) 
     201        { 
     202                CullingLogManager::GetSingleton()->LogMessage("node invalid"); 
     203        } 
     204 
     205        return nodeInvalid; 
    198206} 
    199207//----------------------------------------------------------------------- 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingPlusPlusManager.cpp

    r2555 r2556  
    1010 
    1111 
    12 static const bool CULL_INVALID_NODES = false; 
     12static const bool CULL_INVALID_NODES = true; 
     13//static const bool CULL_INVALID_NODES = false; 
     14static const int MAX_INVISIBLE_NODES_SIZE = 20; 
    1315 
    1416//----------------------------------------------------------------------- 
    1517CoherentHierarchicalCullingPlusPlusManager::CoherentHierarchicalCullingPlusPlusManager(): 
    16 mAssumedVisibility(0), mMaxInvisibleNodesSize(50) 
     18mAssumedVisibility(0), mMaxInvisibleNodesSize(MAX_INVISIBLE_NODES_SIZE) 
    1719{ 
    1820} 
     
    2022CoherentHierarchicalCullingPlusPlusManager::CoherentHierarchicalCullingPlusPlusManager( 
    2123                                                                                                                const unsigned int assumedVisibility): 
    22 mAssumedVisibility(assumedVisibility), mMaxInvisibleNodesSize(50) 
     24mAssumedVisibility(assumedVisibility), mMaxInvisibleNodesSize(MAX_INVISIBLE_NODES_SIZE) 
    2325{ 
    2426} 
     
    4345        //-- PART 1: process finished occlusion queries 
    4446 
    45         while (!mHierarchyInterface->GetQueue()->empty() || !mQueryQueue.empty() || 
    46                    !mInvisibleNodes.empty() || !mVisibleNodes.empty()) 
     47        while (!mHierarchyInterface->GetQueue()->empty() || !mQueryQueue.empty() 
     48                   || !mInvisibleNodes.empty()  
     49                   //|| !mVisibleNodes.empty() 
     50                   ) 
    4751        { 
    4852                ////////// 
    4953                //-- only wait for result if there are no nodes to process 
    50  
     54#if 0 
     55                bool resultAvailable = true; 
     56                while (!mQueryQueue.empty() &&  
     57                           (NodeInvalid(mQueryQueue.front().first) || 
     58                            mQueryQueue.front().second->GetQueryResult( 
     59                                             visiblePixels, mHierarchyInterface->GetQueue()->empty()))) 
     60#else 
    5161                bool resultAvailable = false; 
     62 
    5263                while ( 
    5364                           !mQueryQueue.empty() &&  
     
    5667                           (resultAvailable = mQueryQueue.front().second->GetQueryResult(visiblePixels, false))) 
    5768                           ) 
     69#endif 
    5870                { 
    5971                        HierarchyNode *node = mQueryQueue.front().first; 
     
    6476 
    6577                        // during the wait time issue nodes from visible queue 
    66                         while (!mVisibleNodes.empty() && !resultAvailable) 
     78                        while (1 && !mVisibleNodes.empty() && !resultAvailable) 
    6779                        { 
    6880                                HierarchyNode *vn = mVisibleNodes.front(); 
     
    175187                                        else 
    176188                                        { 
    177                                                 mVisibleNodes.push(node); 
    178                                                 //IssueQuery(node, false); 
     189                                                // mVisibleNodes.push(node); 
     190                                                IssueQuery(node, false); 
    179191                                        } 
    180192                                } 
     
    194206                } 
    195207 
    196                  
     208                  // issue rest of nodes from nodes from invisible queue 
    197209                if (mHierarchyInterface->GetQueue()->empty() && !mInvisibleNodes.empty()) 
    198210                { 
     
    209221 
    210222        // issue rest of nodes from nodes from visible queue 
    211                 if (mHierarchyInterface->GetQueue()->empty() && mQueryQueue.empty() && !mVisibleNodes.empty()) 
    212                 { 
    213                         if (0) 
    214                         { 
    215                                 std::stringstream d; 
    216                                 d << "vis nodes: " << (int)mVisibleNodes.size(); 
    217                                 CullingLogManager::GetSingleton()->LogMessage(d.str()); 
    218                         } 
    219  
     223                if (0 && mHierarchyInterface->GetQueue()->empty() && mQueryQueue.empty() && !mVisibleNodes.empty()) 
     224                { 
    220225                        while (!mVisibleNodes.empty()) 
    221226                        { 
     
    227232 
    228233 
    229         if (0) 
     234        if (0 && !mVisibleNodes.empty()) 
    230235        { 
    231236                std::stringstream d; 
     
    234239        } 
    235240         
    236         // render rest 
     241    // render rest 
    237242        mHierarchyInterface->RenderQueue(); 
     243 
     244        // issue rest of nodes from nodes from visible queue 
     245        while (!mVisibleNodes.empty()) 
     246        { 
     247                IssueQuery(mVisibleNodes.front(), false); 
     248                mVisibleNodes.pop(); 
     249        } 
     250 
     251        int i = 0; 
     252 
     253        while (!mQueryQueue.empty() &&  
     254                    mQueryQueue.front().second->GetQueryResult(visiblePixels, true)) 
     255        { 
     256                ++ i; 
     257 
     258                HierarchyNode *node = mQueryQueue.front().first; 
     259                mQueryQueue.pop(); 
     260 
     261                // tested visible 
     262                if (visiblePixels > mVisibilityThreshold) 
     263                { 
     264                        // assing the #frames the node is assumed to stay visible 
     265                        AssignAssumedVisibility(node); 
     266                        mHierarchyInterface->PullUpVisibility(node); 
     267                } 
     268                else 
     269                {        
     270                        mHierarchyInterface->SetNodeVisible(node, false); 
     271 
     272                        ++ mNumQueryCulledNodes; 
     273 
     274                        if (mVisualizeCulledNodes) 
     275                                mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); 
     276                } 
     277 
     278                // update node's visited flag 
     279                mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());    
     280        } 
     281 
     282        if (0) 
     283        { 
     284                std::stringstream d; 
     285                d << "tested: " << i << " nodes"; 
     286                CullingLogManager::GetSingleton()->LogMessage(d.str()); 
     287        } 
    238288} 
    239289//----------------------------------------------------------------------- 
     
    265315 
    266316        // parent was tested invisible in this frame 
    267     return (  
    268                     mHierarchyInterface->GetParent(node) &&  
    269                     (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId()) &&  
    270                     !mHierarchyInterface->IsNodeVisible(mHierarchyInterface->GetParent(node)) 
    271            ); 
     317    const bool nodeInvalid = (  
     318                 mHierarchyInterface->GetParent(node) &&  
     319                 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId()) &&  
     320                 !mHierarchyInterface->IsNodeVisible(mHierarchyInterface->GetParent(node)) 
     321         ); 
     322 
     323        /*if (nodeInvalid) 
     324                CullingLogManager::GetSingleton()->LogMessage("node invalid"); 
     325        */ 
     326 
     327        return nodeInvalid; 
    272328} 
    273329//----------------------------------------------------------------------- 
     
    296352                IssueQuery(*nit, false); 
    297353 
     354        //for (int i = (int)nodes.size() - 1; i >= 0; -- i) 
     355        //      IssueQuery(nodes[i], false); 
     356 
    298357        nodes.clear(); 
    299358} 
Note: See TracChangeset for help on using the changeset viewer.