diff --git a/pandatool/src/egg-palettize/destTextureImage.cxx b/pandatool/src/egg-palettize/destTextureImage.cxx index dfb302ac17..d49262795d 100644 --- a/pandatool/src/egg-palettize/destTextureImage.cxx +++ b/pandatool/src/egg-palettize/destTextureImage.cxx @@ -4,6 +4,7 @@ //////////////////////////////////////////////////////////////////// #include "destTextureImage.h" +#include "sourceTextureImage.h" #include "texturePlacement.h" #include "textureImage.h" @@ -65,6 +66,15 @@ copy_if_stale(const DestTextureImage *other, TextureImage *texture) { other->get_y_size() != get_y_size() || other->get_num_channels() != get_num_channels()) { copy(texture); + + } else { + // Also check the timestamps. + SourceTextureImage *source = texture->get_preferred_source(); + + if (source != (SourceTextureImage *)NULL && + source->get_filename().compare_timestamps(get_filename()) > 0) { + copy(texture); + } } } diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index ef70872973..f7e6ab44f7 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -11,6 +11,9 @@ #include #include +#include +#include +#include #include @@ -241,6 +244,17 @@ describe_input_file() { //////////////////////////////////////////////////////////////////// void EggPalettize:: run() { + // Fiddle with the loader severity, so we don't confuse the user + // with spurious "reading" and "writing" messages about the state + // file. If the severity is currently NS_info (the default), set it + // to NS_warning instead. + Notify *notify = Notify::ptr(); + NotifyCategory *loader_cat = notify->get_category(":loader"); + if (loader_cat != (NotifyCategory *)NULL && + loader_cat->get_severity() == NS_info) { + loader_cat->set_severity(NS_warning); + } + if (!_txa_filename.exists()) { nout << _txa_filename << " does not exist; cannot run.\n"; exit(1); diff --git a/pandatool/src/egg-palettize/paletteImage.cxx b/pandatool/src/egg-palettize/paletteImage.cxx index c934c6c98b..2cc480039c 100644 --- a/pandatool/src/egg-palettize/paletteImage.cxx +++ b/pandatool/src/egg-palettize/paletteImage.cxx @@ -9,6 +9,7 @@ #include "texturePlacement.h" #include "palettizer.h" #include "textureImage.h" +#include "sourceTextureImage.h" #include "filenameUnifier.h" #include @@ -436,7 +437,22 @@ update_image(bool redo_all) { pi != _placements.end() && !needs_update; ++pi) { TexturePlacement *placement = (*pi); - needs_update = !placement->is_filled(); + + if (!placement->is_filled()) { + needs_update = true; + + } else { + SourceTextureImage *source = + placement->get_texture()->get_preferred_source(); + + if (source != (SourceTextureImage *)NULL && + source->get_filename().compare_timestamps(get_filename()) > 0) { + // The source image is newer than the palette image; we need to + // regenerate. + placement->mark_unfilled(); + needs_update = true; + } + } } if (!needs_update) { diff --git a/pandatool/src/egg-palettize/texturePlacement.cxx b/pandatool/src/egg-palettize/texturePlacement.cxx index ee5ac12461..22000c639c 100644 --- a/pandatool/src/egg-palettize/texturePlacement.cxx +++ b/pandatool/src/egg-palettize/texturePlacement.cxx @@ -699,6 +699,17 @@ is_filled() const { return _is_filled; } +//////////////////////////////////////////////////////////////////// +// Function: TexturePlacement::mark_unfilled +// Access: Public +// Description: Marks the texture as unfilled, so that it will need +// to be copied into the palette image again. +//////////////////////////////////////////////////////////////////// +void TexturePlacement:: +mark_unfilled() { + _is_filled = false; +} + //////////////////////////////////////////////////////////////////// // Function: TexturePlacement::fill_image // Access: Public diff --git a/pandatool/src/egg-palettize/texturePlacement.h b/pandatool/src/egg-palettize/texturePlacement.h index 62264dcef8..dc14124ab2 100644 --- a/pandatool/src/egg-palettize/texturePlacement.h +++ b/pandatool/src/egg-palettize/texturePlacement.h @@ -78,6 +78,7 @@ public: void write_placed(ostream &out, int indent_level = 0); bool is_filled() const; + void mark_unfilled(); void fill_image(PNMImage &image); void flag_error_image(PNMImage &image);