Browse Source

add TextureStageCollection::sort()

David Rose 20 years ago
parent
commit
3c39318b34

+ 14 - 0
panda/src/pgraph/textureStageCollection.cxx

@@ -19,6 +19,8 @@
 #include "textureStageCollection.h"
 
 #include "indent.h"
+#include "indirectLess.h"
+#include <algorithm>
 
 ////////////////////////////////////////////////////////////////////
 //     Function: TextureStageCollection::Constructor
@@ -253,6 +255,18 @@ operator [] (int index) const {
   return _texture_stages[index];
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: TextureStageCollection::sort
+//       Access: Published
+//  Description: Sorts the TextureStages in this collection into order
+//               by TextureStage::sort(), from lowest to highest.
+////////////////////////////////////////////////////////////////////
+void TextureStageCollection::
+sort() {
+  ::sort(_texture_stages.begin(), _texture_stages.end(),
+         IndirectLess<TextureStage>());
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: TextureStageCollection::output
 //       Access: Published

+ 2 - 0
panda/src/pgraph/textureStageCollection.h

@@ -48,6 +48,8 @@ PUBLISHED:
   TextureStage *get_texture_stage(int index) const;
   TextureStage *operator [] (int index) const;
 
+  void sort();
+
   void output(ostream &out) const;
   void write(ostream &out, int indent_level = 0) const;