Changeset 2772 for GTP


Ignore:
Timestamp:
06/18/08 18:02:05 (16 years ago)
Author:
mattausch
Message:

added randomization of the first invokation

Location:
GTP/trunk/App/Demos/Vis/CHC_revisited
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.h

    r2771 r2772  
    345345        */ 
    346346        virtual ~BvhInterior() { if (mBack) delete mBack; if (mFront) delete mFront;} 
    347         /** Returns split axis of this interior node. 
    348         */ 
    349         //inline int GetAxis() { return (int)mAxis; } 
    350         /** Returns position of the split axis. 
    351         */ 
    352         //inline float GetPosition() {return (float)mPosition;} 
    353347 
    354348 
    355349protected: 
    356350 
    357         /// the position of the split plane 
    358         //float mPosition; 
    359          
    360351        BvhNode *mBack; 
    361352        BvhNode *mFront; 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/CHCPlusPlusTraverser.cpp

    r2771 r2772  
    1010CHCPlusPlusTraverser::CHCPlusPlusTraverser() 
    1111{ 
     12} 
     13 
     14 
     15void CHCPlusPlusTraverser::HandleQueryResult(OcclusionQuery *query) 
     16{ 
     17        // wait until result available 
     18        int visiblePixels = query->GetQueryResult(); 
     19 
     20        int visible = visiblePixels > mVisibilityThreshold; 
     21 
     22        BvhNode *node = query->GetFrontNode(); 
     23 
     24        if (visible) 
     25        { 
     26                // node was previously invisible 
     27                if (!node->IsVisible()) 
     28                        node->SetAssumedVisibleFrameId(mFrameId + mAssumedVisibleFrames); 
     29                else 
     30                        // randomize first invokation 
     31                        node->SetAssumedVisibleFrameId(mFrameId + Random(mAssumedVisibleFrames + 1)); 
     32 
     33                mBvh->MakeParentsVisible(node); 
     34                TraverseNode(node); 
     35        } 
     36        else 
     37        { 
     38                ++ mStats.mNumQueryCulledNodes; 
     39        } 
     40 
     41        node->SetVisible(visible); 
    1242} 
    1343 
     
    3565                        mQueryQueue.pop(); 
    3666 
    37                         // wait until result available 
    38                         int visiblePixels = query->GetQueryResult(); 
    39  
    40                         if (visiblePixels > mVisibilityThreshold) 
    41                         { 
    42                                 BvhNode *node = query->GetFrontNode(); 
    43  
    44                                 node->SetVisible(true); 
    45                                 mBvh->MakeParentsVisible(node); 
    46                                 TraverseNode(node); 
    47                         } 
    48                         else 
    49                         { 
    50                                 ++ mStats.mNumQueryCulledNodes; 
    51                         } 
     67                        HandleQueryResult(query); 
    5268                }        
    5369 
     
    7894                                        // identify nodes that we cannot skip queries for 
    7995                                        const bool testFeasible = (!wasVisible || (node->IsVirtualLeaf() && (node->GetAssumedVisibleFrameId() <= mFrameId))); 
    80                                                   
    8196 
    8297                                        // update node's visited flag 
     
    86101                                        if (testFeasible) 
    87102                                        { 
    88                                                 // reset node's visibility classification  
    89                                                 node->SetVisible(false); 
    90  
    91103                                                if (!wasVisible) 
    92104                                                { 
     
    129141        } 
    130142 
     143 
    131144        ////////////// 
    132145        //-- issue remaining previously visible node queries 
     
    146159                mQueryQueue.pop(); 
    147160 
    148                 // wait until result available 
    149                 int visiblePixels = query->GetQueryResult(); 
    150  
    151                 if (visiblePixels > mVisibilityThreshold) 
    152                 { 
    153                         BvhNode *node = query->GetFrontNode(); 
    154  
    155                         node->SetVisible(true); 
    156                         mBvh->MakeParentsVisible(node); 
    157                 } 
    158                 else 
    159                 { 
    160                         ++ mStats.mNumQueryCulledNodes; 
    161                 } 
     161                HandleQueryResult(query); 
    162162        } 
    163163} 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/CHCPlusPlusTraverser.h

    r2771 r2772  
    2626 
    2727        void IssueMultiQueries(); 
     28        /** Handles the result of an occlusion query. 
     29        */ 
     30        void HandleQueryResult(OcclusionQuery *query); 
    2831 
    2932 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.h

    r2765 r2772  
    3131         
    3232        unsigned int GetQueryId() const; 
    33         /** Returns the first added node. 
     33        /** Returns the first node of the multiquery 
    3434        */ 
    3535        inline BvhNode *GetFrontNode() const { return mNodes[0]; } 
     
    4040        */ 
    4141        inline void AddNode(BvhNode *node) { mNodes.push_back(node); } 
     42        /** Convenience method that sets up a single node query. 
     43        */ 
     44        inline void SetNode(BvhNode *node) { Reset(); AddNode(node); } 
    4245 
    43  
     46         
    4447protected: 
    4548 
     
    4750         
    4851         
    49         //////////// 
     52        /////// 
    5053        //-- members 
    5154 
    52         float mPFail; 
     55        //float mPFail; 
    5356        /// all nodes that are tested with the same query 
    5457        BvhNodeContainer mNodes;  
    5558        // the query associated with this test 
    5659        unsigned int mQueryId; 
    57         /// type of the query 
    58         bool mIsVisibleQuery; 
    5960}; 
    6061 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp

    r2771 r2772  
    128128 
    129129        OcclusionQuery *query = mQueryHandler.RequestQuery(); 
    130         query->Reset(); 
    131         query->AddNode(node); 
     130 
     131        query->SetNode(node); 
    132132 
    133133        query->BeginQuery(); 
    134134 
    135135        if (wasVisible) 
    136         { 
    137                 node->SetAssumedVisibleFrameId(mFrameId + 10); 
    138136                ++ mStats.mNumPreviouslyVisibleNodeQueries; 
    139         } 
    140137 
    141138        // if this node is a previous visible leaf: 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/common.cpp

    r2764 r2772  
    5959 
    6060 
    61 void Randomize(const unsigned int seed) 
     61void Randomize(unsigned int seed) 
    6262{ 
    6363        srand(seed); 
Note: See TracChangeset for help on using the changeset viewer.