Browse Source

fix RenderAttrib corruption

David Rose 17 years ago
parent
commit
ee89d48297
2 changed files with 12 additions and 10 deletions
  1. 9 8
      panda/src/pgraph/textureAttrib.cxx
  2. 3 2
      panda/src/pgraph/textureAttrib.h

+ 9 - 8
panda/src/pgraph/textureAttrib.cxx

@@ -504,10 +504,10 @@ compare_to_impl(const RenderAttrib *other) const {
   check_sorted();
   check_sorted();
   ta->check_sorted();
   ta->check_sorted();
 
 
-  OnStages::const_iterator si = _on_stages.begin();
-  OnStages::const_iterator osi = ta->_on_stages.begin();
+  OnStages::const_iterator si = _on_ptr_stages.begin();
+  OnStages::const_iterator osi = ta->_on_ptr_stages.begin();
 
 
-  while (si != _on_stages.end() && osi != ta->_on_stages.end()) {
+  while (si != _on_ptr_stages.end() && osi != ta->_on_ptr_stages.end()) {
     TextureStage *stage = (*si)._stage;
     TextureStage *stage = (*si)._stage;
     TextureStage *other_stage = (*osi)._stage;
     TextureStage *other_stage = (*osi)._stage;
 
 
@@ -525,10 +525,10 @@ compare_to_impl(const RenderAttrib *other) const {
     ++osi;
     ++osi;
   }
   }
 
 
-  if (si != _on_stages.end()) {
+  if (si != _on_ptr_stages.end()) {
     return 1;
     return 1;
   }
   }
-  if (osi != ta->_on_stages.end()) {
+  if (osi != ta->_on_ptr_stages.end()) {
     return -1;
     return -1;
   }
   }
 
 
@@ -941,7 +941,8 @@ sort_on_stages() {
   // It's important that this assignment not be based on the whims of
   // It's important that this assignment not be based on the whims of
   // render order--it mustn't change arbitrarily--so we must first
   // render order--it mustn't change arbitrarily--so we must first
   // sort the on_stages list into pointer order for this purpose.
   // sort the on_stages list into pointer order for this purpose.
-  sort(_on_stages.begin(), _on_stages.end(), CompareTextureStagePointer());
+  _on_ptr_stages = _on_stages;
+  sort(_on_ptr_stages.begin(), _on_ptr_stages.end(), CompareTextureStagePointer());
 
 
   typedef pmap<const InternalName *, int> UsedTexcoordIndex;
   typedef pmap<const InternalName *, int> UsedTexcoordIndex;
   UsedTexcoordIndex used_texcoord_index;
   UsedTexcoordIndex used_texcoord_index;
@@ -950,7 +951,7 @@ sort_on_stages() {
   TexcoordMap tc_map;
   TexcoordMap tc_map;
 
 
   OnStages::const_iterator si;
   OnStages::const_iterator si;
-  for (si = _on_stages.begin(); si != _on_stages.end(); ++si) {
+  for (si = _on_ptr_stages.begin(); si != _on_ptr_stages.end(); ++si) {
     TextureStage *stage = (*si)._stage;
     TextureStage *stage = (*si)._stage;
     if (stage->is_fixed_function()) {
     if (stage->is_fixed_function()) {
       const InternalName *name = stage->get_texcoord_name();
       const InternalName *name = stage->get_texcoord_name();
@@ -966,7 +967,7 @@ sort_on_stages() {
     }
     }
   }
   }
 
 
-  // Now we can sort the on_stages map into render order.
+  // Now we can sort the on_stages list into render order.
   sort(_on_stages.begin(), _on_stages.end(), CompareTextureStageSort());
   sort(_on_stages.begin(), _on_stages.end(), CompareTextureStageSort());
 
 
   _sort_seq = TextureStage::get_sort_seq();
   _sort_seq = TextureStage::get_sort_seq();

+ 3 - 2
panda/src/pgraph/textureAttrib.h

@@ -118,8 +118,9 @@ private:
   };
   };
 
 
   typedef pvector<OnStageNode> OnStages;
   typedef pvector<OnStageNode> OnStages;
-  OnStages _on_stages;
-  OnStages _on_ff_stages;
+  OnStages _on_stages;      // list of all "on" stages, sorted in render order.
+  OnStages _on_ptr_stages;  // above, sorted in pointer order.
+  OnStages _on_ff_stages;   // fixed-function stages only, in render order.
   vector_int _ff_tc_index;
   vector_int _ff_tc_index;
   unsigned int _next_implicit_sort;
   unsigned int _next_implicit_sort;