From c343dece60b195140ae8283177fbe57e0a516efd Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 15 Jun 2001 19:02:03 +0000 Subject: [PATCH] fix mipmap stale bug --- pandatool/src/egg-palettize/eggPalettize.cxx | 7 +++++ pandatool/src/egg-palettize/textureImage.cxx | 26 +++++++++++++++++++ pandatool/src/egg-palettize/textureImage.h | 1 + .../src/egg-palettize/textureProperties.cxx | 15 +++++++++++ .../src/egg-palettize/textureProperties.h | 1 + 5 files changed, 50 insertions(+) diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index 0551d33f54..0af4ca6855 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -552,6 +552,13 @@ run() { state_file.close(); 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) { diff --git a/pandatool/src/egg-palettize/textureImage.cxx b/pandatool/src/egg-palettize/textureImage.cxx index 40904d22da..79e38e5117 100644 --- a/pandatool/src/egg-palettize/textureImage.cxx +++ b/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 // Access: Public @@ -323,6 +340,15 @@ post_txa_file() { // session, we need to re-place ourself in all palette groups. if (_properties != _pre_txa_properties) { 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(); + } } } diff --git a/pandatool/src/egg-palettize/textureImage.h b/pandatool/src/egg-palettize/textureImage.h index 5fb846670a..d03d25b1ca 100644 --- a/pandatool/src/egg-palettize/textureImage.h +++ b/pandatool/src/egg-palettize/textureImage.h @@ -61,6 +61,7 @@ public: const PaletteGroups &get_groups() const; TexturePlacement *get_placement(PaletteGroup *group) const; void force_replace(); + void mark_eggs_stale(); void pre_txa_file(); void post_txa_file(); diff --git a/pandatool/src/egg-palettize/textureProperties.cxx b/pandatool/src/egg-palettize/textureProperties.cxx index c35e4b627e..358c40911b 100644 --- a/pandatool/src/egg-palettize/textureProperties.cxx +++ b/pandatool/src/egg-palettize/textureProperties.cxx @@ -308,6 +308,21 @@ update_egg_tex(EggTexture *egg_tex) const { 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 // Access: Public diff --git a/pandatool/src/egg-palettize/textureProperties.h b/pandatool/src/egg-palettize/textureProperties.h index 2d52f1b319..971630c6b3 100644 --- a/pandatool/src/egg-palettize/textureProperties.h +++ b/pandatool/src/egg-palettize/textureProperties.h @@ -49,6 +49,7 @@ public: void fully_define(); 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;