@@ -78,8 +78,25 @@ class RenderBasicSysTrans :
7878 }
7979
8080private:
81+ class SortedObject
82+ {
83+ public:
84+ std::string mName ;
85+ GLuint mSortedID ;
86+
87+ SortedObject () :
88+ mName (" " ),
89+ mSortedID (NULL )
90+ {}
91+
92+ SortedObject (std::string name, GLuint ID) :
93+ mName (name),
94+ mSortedID (ID)
95+ {}
96+ };
97+
8198 Core::Geometry::Vector prevDir = Core::Geometry::Vector(0.0 );
82- GLuint sortedID = NULL ;
99+ std::vector<SortedObject> sortedObjects ;
83100
84101 class DepthIndex {
85102 public:
@@ -196,7 +213,7 @@ class RenderBasicSysTrans :
196213 camera.front ().data .worldToView [1 ][2 ],
197214 camera.front ().data .worldToView [2 ][2 ]);
198215
199- if (sortedID == NULL )
216+ if (sortedObjects. size () <= 0 )
200217 {
201218 prevDir = dir;
202219 }
@@ -213,18 +230,34 @@ class RenderBasicSysTrans :
213230 }
214231 case RenderState::TransparencySortType::UPDATE_SORT:
215232 {
233+ unsigned int index = 0 ;
234+ bool indexed = false ;
235+ for (int i = 0 ; i < sortedObjects.size (); ++i)
236+ {
237+ if (sortedObjects[i].mName == pass.front ().ibo .name )
238+ {
239+ indexed = true ;
240+ index = i;
241+ }
242+ }
243+ if (!indexed)
244+ {
245+ index = sortedObjects.size ();
246+ sortedObjects.push_back (SortedObject (pass.front ().ibo .name , NULL ));
247+ }
248+
216249 Core::Geometry::Vector diff = prevDir - dir;
217250 float distance = sqrtf (Core::Geometry::Dot (diff, diff));
218- if (distance >= 1.23 || sortedID == NULL )
251+ if (distance >= 1.23 || sortedObjects[index]. mSortedID == NULL )
219252 {
220- if (sortedID != NULL )
253+ if (sortedObjects[index]. mSortedID != NULL )
221254 {
222- iboMan.front ().instance ->removeInMemoryIBO (sortedID );
255+ iboMan.front ().instance ->removeInMemoryIBO (sortedObjects[index]. mSortedID );
223256 }
224257 prevDir = dir;
225- sortedID = sortObjects (dir, ibo, pass, iboMan);
258+ sortedObjects[index]. mSortedID = sortObjects (dir, ibo, pass, iboMan);
226259 }
227- iboID = sortedID ;
260+ iboID = sortedObjects[index]. mSortedID ;
228261 // ::cout << "update" << std::endl;
229262 break ;
230263 }
0 commit comments