Jelajahi Sumber

fix mipmap stale bug

David Rose 24 tahun lalu
induk
melakukan
c343dece60

+ 7 - 0
pandatool/src/egg-palettize/eggPalettize.cxx

@@ -552,6 +552,13 @@ run() {
     state_file.close();
     state_file.close();
 
 
     pal = DCAST(Palettizer, obj);
     pal = DCAST(Palettizer, obj);
+
+    if (pal->_read_pi_version > pal->_pi_version) {
+      nout << FilenameUnifier::make_user_filename(state_filename)
+           << " was written by a more recent version of egg-palettize "
+           << "than this one.  You will need to update your egg-palettize.\n";
+      exit(1);
+    }
   }
   }
 
 
   if (_report_pi) {
   if (_report_pi) {

+ 26 - 0
pandatool/src/egg-palettize/textureImage.cxx

@@ -228,6 +228,23 @@ force_replace() {
   }
   }
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: TextureImage::mark_eggs_stale
+//       Access: Public
+//  Description: Marks all the egg files that reference this texture
+//               stale.  Should be called only when the texture
+//               properties change in some catastrophic way that will
+//               required every egg file referencing it to be
+//               regenerated, even if it is not palettized.
+////////////////////////////////////////////////////////////////////
+void TextureImage::
+mark_eggs_stale() {
+  Placement::iterator pi;
+  for (pi = _placement.begin(); pi != _placement.end(); ++pi) {
+    (*pi).second->mark_eggs_stale();
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: TextureImage::pre_txa_file
 //     Function: TextureImage::pre_txa_file
 //       Access: Public
 //       Access: Public
@@ -323,6 +340,15 @@ post_txa_file() {
   // session, we need to re-place ourself in all palette groups.
   // session, we need to re-place ourself in all palette groups.
   if (_properties != _pre_txa_properties) {
   if (_properties != _pre_txa_properties) {
     force_replace();
     force_replace();
+
+    // The above will mark the egg files stale when the texture is
+    // palettized (since the UV's will certainly need to be
+    // recomputed), but sometimes we need to mark the egg files stale
+    // even when the texture is not palettized (if a critical property
+    // has changed).  The following accomplishes this:
+    if (!_properties.egg_properties_match(_pre_txa_properties)) {
+      mark_eggs_stale();
+    }
   }
   }
 }
 }
 
 

+ 1 - 0
pandatool/src/egg-palettize/textureImage.h

@@ -61,6 +61,7 @@ public:
   const PaletteGroups &get_groups() const;
   const PaletteGroups &get_groups() const;
   TexturePlacement *get_placement(PaletteGroup *group) const;
   TexturePlacement *get_placement(PaletteGroup *group) const;
   void force_replace();
   void force_replace();
+  void mark_eggs_stale();
 
 
   void pre_txa_file();
   void pre_txa_file();
   void post_txa_file();
   void post_txa_file();

+ 15 - 0
pandatool/src/egg-palettize/textureProperties.cxx

@@ -308,6 +308,21 @@ update_egg_tex(EggTexture *egg_tex) const {
   egg_tex->set_magfilter(_minfilter);
   egg_tex->set_magfilter(_minfilter);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: TextureProperties::egg_properties_match
+//       Access: Public
+//  Description: Returns true if all of the properties that are
+//               reflected directly in an egg file match between this
+//               TextureProperties object and the other, or false if
+//               any of them differ.
+////////////////////////////////////////////////////////////////////
+bool TextureProperties::
+egg_properties_match(const TextureProperties &other) const {
+  return (_format == other._format &&
+          _minfilter == other._minfilter &&
+          _magfilter == other._magfilter);
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: TextureProperties::Ordering Operator
 //     Function: TextureProperties::Ordering Operator
 //       Access: Public
 //       Access: Public

+ 1 - 0
pandatool/src/egg-palettize/textureProperties.h

@@ -49,6 +49,7 @@ public:
   void fully_define();
   void fully_define();
 
 
   void update_egg_tex(EggTexture *egg_tex) const;
   void update_egg_tex(EggTexture *egg_tex) const;
+  bool egg_properties_match(const TextureProperties &other) const;
 
 
   bool operator < (const TextureProperties &other) const;
   bool operator < (const TextureProperties &other) const;
   bool operator == (const TextureProperties &other) const;
   bool operator == (const TextureProperties &other) const;