Ver Fonte

*** empty log message ***

David Rose há 25 anos atrás
pai
commit
bbd59331e9

+ 10 - 0
pandatool/src/egg-palettize/destTextureImage.cxx

@@ -4,6 +4,7 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #include "destTextureImage.h"
 #include "destTextureImage.h"
+#include "sourceTextureImage.h"
 #include "texturePlacement.h"
 #include "texturePlacement.h"
 #include "textureImage.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_y_size() != get_y_size() ||
       other->get_num_channels() != get_num_channels()) {
       other->get_num_channels() != get_num_channels()) {
     copy(texture);
     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);
+    }
   }
   }
 }
 }
 
 

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

@@ -11,6 +11,9 @@
 
 
 #include <eggData.h>
 #include <eggData.h>
 #include <bamFile.h>
 #include <bamFile.h>
+#include <notify.h>
+#include <notifyCategory.h>
+#include <notifySeverity.h>
 
 
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -241,6 +244,17 @@ describe_input_file() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void EggPalettize::
 void EggPalettize::
 run() {
 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()) {
   if (!_txa_filename.exists()) {
     nout << _txa_filename << " does not exist; cannot run.\n";
     nout << _txa_filename << " does not exist; cannot run.\n";
     exit(1);
     exit(1);

+ 17 - 1
pandatool/src/egg-palettize/paletteImage.cxx

@@ -9,6 +9,7 @@
 #include "texturePlacement.h"
 #include "texturePlacement.h"
 #include "palettizer.h"
 #include "palettizer.h"
 #include "textureImage.h"
 #include "textureImage.h"
+#include "sourceTextureImage.h"
 #include "filenameUnifier.h"
 #include "filenameUnifier.h"
 
 
 #include <indent.h>
 #include <indent.h>
@@ -436,7 +437,22 @@ update_image(bool redo_all) {
        pi != _placements.end() && !needs_update; 
        pi != _placements.end() && !needs_update; 
        ++pi) {
        ++pi) {
     TexturePlacement *placement = (*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) {
   if (!needs_update) {

+ 11 - 0
pandatool/src/egg-palettize/texturePlacement.cxx

@@ -699,6 +699,17 @@ is_filled() const {
   return _is_filled;
   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
 //     Function: TexturePlacement::fill_image
 //       Access: Public
 //       Access: Public

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

@@ -78,6 +78,7 @@ public:
   void write_placed(ostream &out, int indent_level = 0);
   void write_placed(ostream &out, int indent_level = 0);
 
 
   bool is_filled() const;
   bool is_filled() const;
+  void mark_unfilled();
   void fill_image(PNMImage &image);
   void fill_image(PNMImage &image);
   void flag_error_image(PNMImage &image);
   void flag_error_image(PNMImage &image);