Changeset 3060


Ignore:
Timestamp:
10/21/08 23:20:17 (16 years ago)
Author:
mattausch
Message:

updated render queue: as we assume incoming nodes to be sorted front to back,
no sorting is required anymore

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp

    r3054 r3060  
    1515 
    1616 
    17 inline static bool CompDist(RenderQueueBucket *b1, RenderQueueBucket *b2) 
     17/*inline static bool CompDist(RenderQueueBucket *b1, RenderQueueBucket *b2) 
    1818{ 
    1919        return (b1->mMinDistance < b2->mMinDistance); 
    20 } 
    21  
    22  
    23  
     20}*/ 
    2421RenderQueue::RenderQueue():  
    2522mState(NULL),  
    26 mMinSizeForSorting(3), 
    2723mCamera(NULL), 
    2824mNumEntries(0) 
     
    3329RenderQueue::RenderQueue(RenderState *state, Camera *cam): 
    3430mState(state),  
    35 mMinSizeForSorting(3), 
    3631mCamera(cam), 
    3732mNumEntries(0) 
     
    118113                { 
    119114                        RenderQueueBucket *bucket = new RenderQueueBucket(); 
    120                         bucket->mMinDistance = -1; 
     115                        //bucket->mMinDistance = -1; 
    121116 
    122117                        bucket->mAlphaTestEnabled = tech->IsAlphaTestEnabled(); 
     
    161156        } 
    162157 
    163         if (bucket->mMinDistance < .0f) 
    164         { 
     158        if (bucket->IsEmpty()) 
     159        { 
     160                // add to currently active buckets that will be rendered 
    165161                // assume that the incoming nodes are ordered by distance  
     162                // => active buckets are sorted by distance 
     163                mActiveBuckets.push_back(bucket); 
     164         
    166165                // => set min dist on first incoming node 
    167                 const Vector3 v = shape->GetCenter() - mCamera->GetPosition(); 
    168                  
    169                 const float dist = SqrMagnitude(v); 
    170                 bucket->mMinDistance = dist; 
    171         } 
     166                //const Vector3 v = shape->GetCenter() - mCamera->GetPosition(); 
     167                //const float dist = SqrMagnitude(v); 
     168                //bucket->mMinDistance = dist; 
     169 
     170                } 
    172171 
    173172        bucket->mShapes.push_back(shape); 
     
    177176void RenderQueue::Clear() 
    178177{ 
    179         for (size_t i = 0; i < mBuckets.size(); ++ i) 
    180         { 
    181                 mBuckets[i]->mMinDistance = -1; 
    182                 mBuckets[i]->mShapes.clear(); 
     178        for (size_t i = 0; i < mActiveBuckets.size(); ++ i) 
     179        { 
     180                //mBuckets[i]->mMinDistance = -1; 
     181                mActiveBuckets[i]->mShapes.clear(); 
    183182        } 
    184183 
    185184        mNumEntries = 0; 
     185 
     186        mActiveBuckets.clear(); 
    186187} 
    187188 
     
    196197{ 
    197198        // sort the buckets 
    198         Sort(); 
     199        //Sort(); 
    199200 
    200201        // render all buckets 
     
    236237 
    237238 
    238 void RenderQueue::Sort() 
     239/*void RenderQueue::Sort() 
    239240{ 
    240241        // sort buckets itself by distance 
    241242        sort(mBuckets.begin(), mBuckets.end(), CompDist); 
    242 } 
     243}*/ 
    243244 
    244245 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h

    r3054 r3060  
    1717struct RenderQueueBucket 
    1818{ 
     19        inline bool IsEmpty() const { return mShapes.empty();} 
     20 
    1921        //////// 
    2022        //-- the attributes used to sort the materials 
    21         /// texture parameters 
     23         
     24        // texture related parameters 
    2225        int mTexHeight; 
    2326        int mTexWidth; 
     
    3942 
    4043        /// minimal distance to the camera 
    41         float mMinDistance; 
     44        //float mMinDistance; 
    4245 
    4346        /// the shapes that belong to a bucket 
     
    4952        to minimize state changes while approximately keeping front-to-back order 
    5053        The implementation roughly follows the suggested implementation in  
    51         Tom Forsyth's article on render state changes. It requires sorting only on  
    52         bucket level and therefore has very     low overhead. 
     54        Tom Forsyth's article on render state changes. It assumes that the incoming 
     55        objecs are roughly front to back level and therefore does not require any sorting  
     56        and therefore has very  low overhead. 
    5357*/ 
    5458class RenderQueue 
     
    8892protected: 
    8993 
    90         void Sort(); 
     94        //void Sort(); 
    9195 
    9296        inline bool FitsInBucket(Shape *shape, size_t idx) const; 
     
    100104 
    101105        /////////// 
     106        //-- members 
    102107 
     108        // the current render state 
    103109        RenderState *mState; 
    104110         
    105111        Camera *mCamera; 
    106         //SceneEntityContainer mEntities; 
    107         int mMinSizeForSorting; 
    108112        /// each bucket contains objects with similar materials that don't cause a hard state change 
    109113        std::vector<RenderQueueBucket *> mBuckets; 
     114        /// this are the buckets that where touched until the last clear. They are sorted by distance 
     115        std::vector<RenderQueueBucket *> mActiveBuckets; 
    110116 
    111117        int mNumEntries; 
Note: See TracChangeset for help on using the changeset viewer.