mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
*** empty log message ***
This commit is contained in:
parent
97b57df1b7
commit
e5ab0ddc8f
@ -84,6 +84,16 @@ EggPalettize() : EggMultiFilter(true) {
|
||||
"this will be replaced with the \"dir\" string associated with a "
|
||||
"palette group.",
|
||||
&EggPalettize::dispatch_string, &_got_map_dirname, &_map_dirname);
|
||||
add_option
|
||||
("ds", "dirname", 0,
|
||||
"The directory to write palette shadow images to. These are working "
|
||||
"copies of the palette images, useful when the palette image type is "
|
||||
"a lossy-compression type like JPEG; you can avoid generational loss "
|
||||
"of quality on the palette images with each pass through the palettes "
|
||||
"by storing these extra shadow images in a lossless image type. This "
|
||||
"directory is only used if the :shadowtype keyword appears in the .txa "
|
||||
"file.",
|
||||
&EggPalettize::dispatch_filename, &_got_shadow_dirname, &_shadow_dirname);
|
||||
add_option
|
||||
("dr", "dirname", 0,
|
||||
"The directory to make map filenames relative to when writing egg "
|
||||
@ -325,11 +335,16 @@ run() {
|
||||
if (_got_map_dirname) {
|
||||
pal->_map_dirname = _map_dirname;
|
||||
}
|
||||
if (_got_shadow_dirname) {
|
||||
pal->_shadow_dirname = _shadow_dirname;
|
||||
}
|
||||
if (_got_rel_dirname) {
|
||||
pal->_rel_dirname = _rel_dirname;
|
||||
FilenameUnifier::set_rel_dirname(_rel_dirname);
|
||||
}
|
||||
|
||||
pal->all_params_set();
|
||||
|
||||
Eggs::const_iterator ei;
|
||||
for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
|
||||
EggData *egg_data = (*ei);
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
Filename _txa_filename;
|
||||
string _map_dirname;
|
||||
bool _got_map_dirname;
|
||||
Filename _shadow_dirname;
|
||||
bool _got_shadow_dirname;
|
||||
Filename _rel_dirname;
|
||||
bool _got_rel_dirname;
|
||||
string _default_groupname;
|
||||
|
@ -30,6 +30,23 @@ ImageFile() {
|
||||
_y_size = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ImageFile::make_shadow_image
|
||||
// Access: Public
|
||||
// Description: Sets up the ImageFile as a "shadow image" of a
|
||||
// particular PaletteImage. This is a temporary
|
||||
// ImageFile that's used to read and write the shadow
|
||||
// palette image, which is used to keep a working copy
|
||||
// of the palette.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ImageFile::
|
||||
make_shadow_image(const string &basename) {
|
||||
_properties._color_type = pal->_shadow_color_type;
|
||||
_properties._alpha_type = pal->_shadow_alpha_type;
|
||||
|
||||
set_filename(pal->_shadow_dirname, basename);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ImageFile::is_size_known
|
||||
// Access: Public
|
||||
@ -147,6 +164,20 @@ set_filename(PaletteGroup *group, const string &basename) {
|
||||
++pi;
|
||||
}
|
||||
|
||||
set_filename(dirname, basename);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ImageFile::set_filename
|
||||
// Access: Public
|
||||
// Description: Sets the filename, and if applicable, the
|
||||
// alpha_filename, from the indicated basename. The
|
||||
// extension appropriate to the image file type
|
||||
// specified in _color_type (and _alpha_type) is
|
||||
// automatically applied.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ImageFile::
|
||||
set_filename(const string &dirname, const string &basename) {
|
||||
_filename = Filename(dirname, basename);
|
||||
|
||||
if (_properties._color_type != (PNMFileType *)NULL) {
|
||||
@ -155,7 +186,7 @@ set_filename(PaletteGroup *group, const string &basename) {
|
||||
}
|
||||
|
||||
if (_properties._alpha_type != (PNMFileType *)NULL) {
|
||||
_alpha_filename = _filename.get_fullpath_wo_extension() + "_alpha";
|
||||
_alpha_filename = _filename.get_fullpath_wo_extension() + "_a";
|
||||
_alpha_filename.set_extension
|
||||
(_properties._alpha_type->get_suggested_extension());
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ class ImageFile : public TypedWriteable {
|
||||
public:
|
||||
ImageFile();
|
||||
|
||||
void make_shadow_image(const string &basename);
|
||||
|
||||
bool is_size_known() const;
|
||||
int get_x_size() const;
|
||||
int get_y_size() const;
|
||||
@ -38,6 +40,7 @@ public:
|
||||
void update_properties(const TextureProperties &properties);
|
||||
|
||||
void set_filename(PaletteGroup *group, const string &basename);
|
||||
void set_filename(const string &dirname, const string &basename);
|
||||
const Filename &get_filename() const;
|
||||
const Filename &get_alpha_filename() const;
|
||||
bool exists() const;
|
||||
|
@ -335,6 +335,23 @@ reset_images() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PaletteGroup::setup_shadow_images
|
||||
// Access: Public
|
||||
// Description: Ensures that each PaletteImage's _shadow_image has
|
||||
// the correct filename and image types, based on what
|
||||
// was supplied on the command line and in the .txa
|
||||
// file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PaletteGroup::
|
||||
setup_shadow_images() {
|
||||
Pages::iterator pai;
|
||||
for (pai = _pages.begin(); pai != _pages.end(); ++pai) {
|
||||
PalettePage *page = (*pai).second;
|
||||
page->setup_shadow_images();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PaletteGroup::update_images
|
||||
// Access: Public
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
void write_image_info(ostream &out, int indent_level = 0) const;
|
||||
void optimal_resize();
|
||||
void reset_images();
|
||||
void setup_shadow_images();
|
||||
void update_images(bool redo_all);
|
||||
|
||||
private:
|
||||
|
@ -165,7 +165,10 @@ PaletteImage(PalettePage *page, int index) :
|
||||
name << page->get_group()->get_name() << "_palette_"
|
||||
<< page->get_name() << "_" << index + 1;
|
||||
|
||||
set_filename(page->get_group(), name.str());
|
||||
_basename = name.str();
|
||||
|
||||
set_filename(page->get_group(), _basename);
|
||||
_shadow_image.make_shadow_image(_basename);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -308,8 +311,7 @@ resize_image(int x_size, int y_size) {
|
||||
// We already know we're going to be generating a new image from
|
||||
// scratch after this.
|
||||
_cleared_regions.clear();
|
||||
unlink();
|
||||
_new_image = true;
|
||||
remove_image();
|
||||
|
||||
// First, Save the current placement list, while simultaneously
|
||||
// clearing it.
|
||||
@ -399,8 +401,19 @@ reset_image() {
|
||||
|
||||
_placements.clear();
|
||||
_cleared_regions.clear();
|
||||
unlink();
|
||||
_new_image = true;
|
||||
remove_image();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PaletteImage::setup_shadow_image
|
||||
// Access: Public
|
||||
// Description: Ensures the _shadow_image has the correct filename
|
||||
// and image types, based on what was supplied on the
|
||||
// command line and in the .txa file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PaletteImage::
|
||||
setup_shadow_image() {
|
||||
_shadow_image.make_shadow_image(_basename);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -416,15 +429,13 @@ update_image(bool redo_all) {
|
||||
if (is_empty() && pal->_aggressively_clean_mapdir) {
|
||||
// If the palette image is 'empty', ensure that it doesn't exist.
|
||||
// No need to clutter up the map directory.
|
||||
unlink();
|
||||
_new_image = true;
|
||||
remove_image();
|
||||
return;
|
||||
}
|
||||
|
||||
if (redo_all) {
|
||||
// If we're redoing everything, throw out the old image anyway.
|
||||
unlink();
|
||||
_new_image = true;
|
||||
remove_image();
|
||||
}
|
||||
|
||||
// Do we need to update?
|
||||
@ -479,6 +490,10 @@ update_image(bool redo_all) {
|
||||
}
|
||||
|
||||
write(_image);
|
||||
|
||||
if (pal->_shadow_color_type != (PNMFileType *)NULL) {
|
||||
_shadow_image.write(_image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -560,9 +575,15 @@ get_image() {
|
||||
}
|
||||
|
||||
if (!_new_image) {
|
||||
if (read(_image)) {
|
||||
_got_image = true;
|
||||
return;
|
||||
if (pal->_shadow_color_type != (PNMFileType *)NULL) {
|
||||
if (_shadow_image.read(_image)) {
|
||||
_got_image = true;
|
||||
}
|
||||
} else {
|
||||
if (read(_image)) {
|
||||
_got_image = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,6 +604,20 @@ get_image() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PaletteImage::remove_image
|
||||
// Access: Private
|
||||
// Description: Deletes the image file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PaletteImage::
|
||||
remove_image() {
|
||||
unlink();
|
||||
if (pal->_shadow_color_type != (PNMFileType *)NULL) {
|
||||
_shadow_image.unlink();
|
||||
}
|
||||
_new_image = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PaletteImage::register_with_read_factory
|
||||
// Access: Public, Static
|
||||
@ -620,10 +655,16 @@ write_datagram(BamWriter *writer, Datagram &datagram) {
|
||||
|
||||
writer->write_pointer(datagram, _page);
|
||||
datagram.add_uint32(_index);
|
||||
datagram.add_string(_basename);
|
||||
datagram.add_bool(_new_image);
|
||||
|
||||
// We don't write _got_image or _image. These are loaded
|
||||
// per-session.
|
||||
|
||||
// We don't write _shadow_image. This is just a runtime convenience
|
||||
// for specifying the name of the shadow file, and we redefine this
|
||||
// per-session (which allows us to pick up a new
|
||||
// pal->_shadow_dirname if it changes).
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -665,7 +706,7 @@ complete_pointers(vector_typedWriteable &plist, BamReader *manager) {
|
||||
// allocate and return a new object with all the data
|
||||
// read.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TypedWriteable* PaletteImage::
|
||||
TypedWriteable *PaletteImage::
|
||||
make_PaletteImage(const FactoryParams ¶ms) {
|
||||
PaletteImage *me = new PaletteImage;
|
||||
BamReader *manager;
|
||||
@ -702,5 +743,6 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
manager->read_pointer(scan, this); // _page
|
||||
|
||||
_index = scan.get_uint32();
|
||||
_basename = scan.get_string();
|
||||
_new_image = scan.get_bool();
|
||||
}
|
||||
|
@ -44,12 +44,14 @@ public:
|
||||
|
||||
void write_placements(ostream &out, int indent_level = 0) const;
|
||||
void reset_image();
|
||||
void setup_shadow_image();
|
||||
void update_image(bool redo_all);
|
||||
|
||||
private:
|
||||
bool find_hole(int &x, int &y, int x_size, int y_size) const;
|
||||
TexturePlacement *find_overlap(int x, int y, int x_size, int y_size) const;
|
||||
void get_image();
|
||||
void remove_image();
|
||||
|
||||
// The ClearedRegion object keeps track of TexturePlacements that
|
||||
// were recently removed and thus need to be set to black.
|
||||
@ -77,11 +79,14 @@ private:
|
||||
|
||||
PalettePage *_page;
|
||||
int _index;
|
||||
string _basename;
|
||||
|
||||
bool _new_image;
|
||||
bool _got_image;
|
||||
PNMImage _image;
|
||||
|
||||
ImageFile _shadow_image;
|
||||
|
||||
// The TypedWriteable interface follows.
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
|
@ -203,6 +203,23 @@ reset_images() {
|
||||
_images.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PalettePage::setup_shadow_images
|
||||
// Access: Public
|
||||
// Description: Ensures that each PaletteImage's _shadow_image has
|
||||
// the correct filename and image types, based on what
|
||||
// was supplied on the command line and in the .txa
|
||||
// file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PalettePage::
|
||||
setup_shadow_images() {
|
||||
Images::iterator ii;
|
||||
for (ii = _images.begin(); ii != _images.end(); ++ii) {
|
||||
PaletteImage *image = (*ii);
|
||||
image->setup_shadow_image();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PalettePage::update_images
|
||||
// Access: Public
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
void write_image_info(ostream &out, int indent_level = 0) const;
|
||||
void optimal_resize();
|
||||
void reset_images();
|
||||
void setup_shadow_images();
|
||||
void update_images(bool redo_all);
|
||||
|
||||
private:
|
||||
|
@ -183,6 +183,10 @@ read_txa_file(const Filename &txa_filename) {
|
||||
group->clear_depends();
|
||||
}
|
||||
|
||||
// Also reset _shadow_color_type.
|
||||
_shadow_color_type = (PNMFileType *)NULL;
|
||||
_shadow_alpha_type = (PNMFileType *)NULL;
|
||||
|
||||
if (!_txa_file.read(txa_filename)) {
|
||||
exit(1);
|
||||
}
|
||||
@ -201,6 +205,23 @@ read_txa_file(const Filename &txa_filename) {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Palettizer::all_params_set
|
||||
// Access: Public
|
||||
// Description: Called after all command line parameters have been
|
||||
// set up, this is a hook to do whatever initialization
|
||||
// is necessary.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Palettizer::
|
||||
all_params_set() {
|
||||
// Make sure the palettes have their shadow images set up properly.
|
||||
Groups::iterator gi;
|
||||
for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
|
||||
PaletteGroup *group = (*gi).second;
|
||||
group->setup_shadow_images();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Palettizer::process_command_line_eggs
|
||||
// Access: Public
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
|
||||
void report_pi() const;
|
||||
void read_txa_file(const Filename &txa_filename);
|
||||
void all_params_set();
|
||||
void process_command_line_eggs(bool force_texture_read);
|
||||
void process_all(bool force_texture_read);
|
||||
void optimal_resize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user