Changeset 3060
- Timestamp:
- 10/21/08 23:20:17 (16 years ago)
- 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 15 15 16 16 17 inline static bool CompDist(RenderQueueBucket *b1, RenderQueueBucket *b2)17 /*inline static bool CompDist(RenderQueueBucket *b1, RenderQueueBucket *b2) 18 18 { 19 19 return (b1->mMinDistance < b2->mMinDistance); 20 } 21 22 23 20 }*/ 24 21 RenderQueue::RenderQueue(): 25 22 mState(NULL), 26 mMinSizeForSorting(3),27 23 mCamera(NULL), 28 24 mNumEntries(0) … … 33 29 RenderQueue::RenderQueue(RenderState *state, Camera *cam): 34 30 mState(state), 35 mMinSizeForSorting(3),36 31 mCamera(cam), 37 32 mNumEntries(0) … … 118 113 { 119 114 RenderQueueBucket *bucket = new RenderQueueBucket(); 120 bucket->mMinDistance = -1;115 //bucket->mMinDistance = -1; 121 116 122 117 bucket->mAlphaTestEnabled = tech->IsAlphaTestEnabled(); … … 161 156 } 162 157 163 if (bucket->mMinDistance < .0f) 164 { 158 if (bucket->IsEmpty()) 159 { 160 // add to currently active buckets that will be rendered 165 161 // assume that the incoming nodes are ordered by distance 162 // => active buckets are sorted by distance 163 mActiveBuckets.push_back(bucket); 164 166 165 // => 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 } 172 171 173 172 bucket->mShapes.push_back(shape); … … 177 176 void RenderQueue::Clear() 178 177 { 179 for (size_t i = 0; i < m Buckets.size(); ++ i)180 { 181 mBuckets[i]->mMinDistance = -1;182 m Buckets[i]->mShapes.clear();178 for (size_t i = 0; i < mActiveBuckets.size(); ++ i) 179 { 180 //mBuckets[i]->mMinDistance = -1; 181 mActiveBuckets[i]->mShapes.clear(); 183 182 } 184 183 185 184 mNumEntries = 0; 185 186 mActiveBuckets.clear(); 186 187 } 187 188 … … 196 197 { 197 198 // sort the buckets 198 Sort();199 //Sort(); 199 200 200 201 // render all buckets … … 236 237 237 238 238 void RenderQueue::Sort()239 /*void RenderQueue::Sort() 239 240 { 240 241 // sort buckets itself by distance 241 242 sort(mBuckets.begin(), mBuckets.end(), CompDist); 242 } 243 }*/ 243 244 244 245 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
r3054 r3060 17 17 struct RenderQueueBucket 18 18 { 19 inline bool IsEmpty() const { return mShapes.empty();} 20 19 21 //////// 20 22 //-- the attributes used to sort the materials 21 /// texture parameters 23 24 // texture related parameters 22 25 int mTexHeight; 23 26 int mTexWidth; … … 39 42 40 43 /// minimal distance to the camera 41 float mMinDistance;44 //float mMinDistance; 42 45 43 46 /// the shapes that belong to a bucket … … 49 52 to minimize state changes while approximately keeping front-to-back order 50 53 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. 53 57 */ 54 58 class RenderQueue … … 88 92 protected: 89 93 90 void Sort();94 //void Sort(); 91 95 92 96 inline bool FitsInBucket(Shape *shape, size_t idx) const; … … 100 104 101 105 /////////// 106 //-- members 102 107 108 // the current render state 103 109 RenderState *mState; 104 110 105 111 Camera *mCamera; 106 //SceneEntityContainer mEntities;107 int mMinSizeForSorting;108 112 /// each bucket contains objects with similar materials that don't cause a hard state change 109 113 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; 110 116 111 117 int mNumEntries;
Note: See TracChangeset
for help on using the changeset viewer.