Sfoglia il codice sorgente

*** empty log message ***

David Rose 25 anni fa
parent
commit
81329682e1

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

@@ -37,6 +37,7 @@ DestTextureImage(TexturePlacement *placement) {
   _size_known = true;
   _x_size = texture->get_x_size();
   _y_size = texture->get_y_size();
+
   set_filename(placement->get_group(), texture->get_name());
 }
 

+ 9 - 3
pandatool/src/egg-palettize/eggPalettize.cxx

@@ -134,7 +134,7 @@ EggPalettize() : EggMultiFilter(true) {
      "suboptimal packing.  Including this switch forces the palettes "
      "to be rebuilt if necessary to optimize the packing, but this "
      "may invalidate other egg files which share this palette.",
-     &EggPalettize::dispatch_none, &_force_optimal);
+     &EggPalettize::dispatch_none, &_optimal);
 
   add_option
     ("nolock", "", 0, 
@@ -343,6 +343,12 @@ run() {
     FilenameUnifier::set_rel_dirname(_rel_dirname);
   }
 
+  // We only omit solitary textures from palettes if we're running in
+  // optimal mode.  Otherwise, we're likely to invalidate old egg
+  // files by changing a texture from solitary to nonsolitary state or
+  // vice-versa.
+  pal->_omit_solitary = _optimal;
+
   pal->all_params_set();
 
   Eggs::const_iterator ei;
@@ -358,7 +364,7 @@ run() {
     pal->_command_line_eggs.push_back(egg_file);
   }
 
-  if (_force_optimal) {
+  if (_optimal) {
     // If we're asking for an optimal packing, throw away the old
     // packing and start fresh.
     pal->reset_images();
@@ -374,7 +380,7 @@ run() {
     pal->process_command_line_eggs(_redo_all);
   }
 
-  if (_force_optimal) {
+  if (_optimal) {
     // If we're asking for optimal packing, this also implies we want
     // to resize the big empty palette images down.
     pal->optimal_resize();

+ 1 - 1
pandatool/src/egg-palettize/eggPalettize.h

@@ -46,7 +46,7 @@ private:
   bool _report_pi;
   bool _statistics_only;
   bool _all_textures; 
-  bool _force_optimal;
+  bool _optimal;
   bool _redo_all;
   bool _redo_eggs;
   bool _dont_lock_pi;

+ 21 - 2
pandatool/src/egg-palettize/paletteImage.cxx

@@ -191,7 +191,16 @@ get_page() const {
 ////////////////////////////////////////////////////////////////////
 bool PaletteImage::
 is_empty() const {
-  return _placements.size() < 2;
+  if (pal->_omit_solitary) {
+    // If we're omitting solitary textures, the image is considered
+    // empty even if it has one texture.
+    return _placements.size() < 2;
+
+  } else {
+    // If we're not omitting solitary textures, the image is only
+    // empty if it has no textures.
+    return _placements.empty();
+  }
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -239,6 +248,9 @@ unplace(TexturePlacement *placement) {
 //               texture on the image.  If there is, it is flagged as
 //               'solitary' so that the egg files will not needlessly
 //               reference the palettized image.
+//
+//               However, if pal->_omit_solitary is false, we
+//               generally don't change textures to solitary state.
 ////////////////////////////////////////////////////////////////////
 void PaletteImage::
 check_solitary() {
@@ -247,7 +259,14 @@ check_solitary() {
     TexturePlacement *placement = *_placements.begin();
     nassertv(placement->get_omit_reason() == OR_none ||
 	     placement->get_omit_reason() == OR_solitary);
-    placement->omit_solitary();
+
+    if (pal->_omit_solitary || placement->get_omit_reason() == OR_solitary) {
+      // We only omit the solitary texture if (a) we have
+      // omit_solitary in effect, or (b) we don't have omit_solitary
+      // in effect now, but we did before, and the texture is still
+      // flagged as solitary from that previous pass.
+      placement->omit_solitary();
+    }
 
   } else {
     // Zero or multiple.

+ 3 - 0
pandatool/src/egg-palettize/palettizer.cxx

@@ -40,6 +40,7 @@ Palettizer() {
   _map_dirname = "%g";
   _shadow_dirname = "shadow";
   _margin = 2;
+  _omit_solitary = false;
   _coverage_threshold = 2.5;
   _aggressively_clean_mapdir = true;
   _force_power_2 = true;
@@ -644,6 +645,7 @@ write_datagram(BamWriter *writer, Datagram &datagram) {
   datagram.add_int32(_pal_x_size);
   datagram.add_int32(_pal_y_size);
   datagram.add_int32(_margin);
+  datagram.add_bool(_omit_solitary);
   datagram.add_float64(_coverage_threshold);
   datagram.add_bool(_force_power_2);
   datagram.add_bool(_aggressively_clean_mapdir);
@@ -775,6 +777,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
   _pal_x_size = scan.get_int32();
   _pal_y_size = scan.get_int32();
   _margin = scan.get_int32();
+  _omit_solitary = scan.get_bool();
   _coverage_threshold = scan.get_float64();
   _force_power_2 = scan.get_bool();
   _aggressively_clean_mapdir = scan.get_bool();

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

@@ -76,6 +76,7 @@ public:
   Filename _rel_dirname;
   int _pal_x_size, _pal_y_size;
   int _margin;
+  bool _omit_solitary;
   double _coverage_threshold;
   bool _force_power_2;
   bool _aggressively_clean_mapdir;