diff --git a/pandatool/src/egg-palettize/Sources.pp b/pandatool/src/egg-palettize/Sources.pp index 5faa456f3d..8c4c254f28 100644 --- a/pandatool/src/egg-palettize/Sources.pp +++ b/pandatool/src/egg-palettize/Sources.pp @@ -11,10 +11,10 @@ attribFile.cxx attribFile.h config_egg_palettize.cxx \ eggPalettize.cxx eggPalettize.h \ imageFile.cxx imageFile.h palette.cxx palette.h sourceEgg.cxx \ - sourceEgg.h string_utils.cxx string_utils.h texture.cxx texture.h \ + sourceEgg.h string_utils.cxx string_utils.h pTexture.cxx pTexture.h \ userAttribLine.cxx userAttribLine.h - #define INSTALL_HEADERS \ + #define INSTALL_HEADERS #end bin_target diff --git a/pandatool/src/egg-palettize/attribFile.cxx b/pandatool/src/egg-palettize/attribFile.cxx index a972568ab6..272affbdc0 100644 --- a/pandatool/src/egg-palettize/attribFile.cxx +++ b/pandatool/src/egg-palettize/attribFile.cxx @@ -7,7 +7,7 @@ #include "userAttribLine.h" #include "eggPalettize.h" #include "string_utils.h" -#include "texture.h" +#include "pTexture.h" #include "palette.h" #include "sourceEgg.h" @@ -158,9 +158,9 @@ update_params(EggPalettize *prog) { void AttribFile:: get_req_sizes() { - Textures::iterator ti; + PTextures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *tex = (*ti).second; + PTexture *tex = (*ti).second; tex->clear_req(); int margin = _default_margin; @@ -185,9 +185,9 @@ get_req_sizes() { void AttribFile:: update_texture_flags() { // First, clear all the flags. - Textures::iterator ti; + PTextures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *tex = (*ti).second; + PTexture *tex = (*ti).second; tex->set_unused(true); tex->set_uses_alpha(false); } @@ -204,11 +204,11 @@ update_texture_flags() { // fine time to mark the textures' original packing state, so we can // check later to see if they've been repacked elsewhere. for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *tex = (*ti).second; + PTexture *tex = (*ti).second; tex->record_orig_state(); if (tex->unused()) { - tex->set_omit(Texture::OR_unused); + tex->set_omit(PTexture::OR_unused); } } } @@ -236,11 +236,11 @@ repack_all_textures() { // Reorder the textures in descending order by height and width for // optimal packing. - vector textures; + vector textures; get_eligible_textures(textures); // Now pack all the textures. This will create new palettes. - vector::iterator ti; + vector::iterator ti; for (ti = textures.begin(); ti != textures.end(); ++ti) { pack_texture(*ti); } @@ -259,13 +259,13 @@ repack_some_textures() { // Reorder the textures in descending order by height and width for // optimal packing. - vector textures; + vector textures; get_eligible_textures(textures); // Now pack whatever textures are currently unpacked. - vector::iterator ti; + vector::iterator ti; for (ti = textures.begin(); ti != textures.end(); ++ti) { - Texture *tex = (*ti); + PTexture *tex = (*ti); if (!tex->is_packed()) { if (pack_texture(tex)) { any_added = true; @@ -318,24 +318,24 @@ bool AttribFile:: check_packing(bool force_optimal) { bool all_ok = true; - Textures::iterator ti; + PTextures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *texture = (*ti).second; + PTexture *texture = (*ti).second; - if (texture->get_omit() == Texture::OR_none) { + if (texture->get_omit() == PTexture::OR_none) { // Here's a texture that thinks it wants to be packed. Does it? int xsize, ysize; if (!texture->get_req(xsize, ysize)) { // If we don't know the texture's size, we can't place it. nout << "Warning! Can't determine size of " << texture->get_name() << "\n"; - texture->set_omit(Texture::OR_unknown); + texture->set_omit(PTexture::OR_unknown); } else if ((xsize > _pal_xsize || ysize > _pal_ysize) || (xsize == _pal_xsize && ysize == _pal_ysize)) { // If the texture is too big for the palette (or exactly fills the // palette), we can't place it. - texture->set_omit(Texture::OR_size); + texture->set_omit(PTexture::OR_size); } else { // Ok, this texture really does want to be packed. Is it? @@ -360,7 +360,7 @@ check_packing(bool force_optimal) { } } - if (texture->get_omit() != Texture::OR_none) { + if (texture->get_omit() != PTexture::OR_none) { // Here's a texture that doesn't want to be packed. Is it? if (unpack_texture(texture)) { // It was! Not any more. @@ -381,7 +381,7 @@ check_packing(bool force_optimal) { bool AttribFile:: -pack_texture(Texture *texture) { +pack_texture(PTexture *texture) { // Now try to place it in each of our existing palettes. Palettes::iterator pi; for (pi = _palettes.begin(); pi != _palettes.end(); ++pi) { @@ -395,7 +395,7 @@ pack_texture(Texture *texture) { new Palette(_palettes.size() + 1, _pal_xsize, _pal_ysize, 0, this); if (!palette->pack_texture(texture)) { // Hmm, it didn't fit on an empty palette. Must be too big. - texture->set_omit(Texture::OR_size); + texture->set_omit(PTexture::OR_size); delete palette; return false; } @@ -405,7 +405,7 @@ pack_texture(Texture *texture) { } bool AttribFile:: -unpack_texture(Texture *texture) { +unpack_texture(PTexture *texture) { if (texture->is_packed()) { bool unpacked = texture->get_palette()->unpack_texture(texture); assert(unpacked); @@ -439,33 +439,33 @@ touch_dirty_egg_files(bool force_redo_all, } -Texture *AttribFile:: +PTexture *AttribFile:: get_texture(const string &name) { - Textures::iterator ti; + PTextures::iterator ti; ti = _textures.find(name); if (ti != _textures.end()) { return (*ti).second; } - Texture *texture = new Texture(this, name); + PTexture *texture = new PTexture(this, name); _textures[name] = texture; return texture; } void AttribFile:: -get_eligible_textures(vector &textures) { +get_eligible_textures(vector &textures) { // First, copy the texture pointers into this map structure to sort // them in descending order by size. This is a 2-d map such that // each map[ysize][xsize] is a set of texture pointers. - typedef map > > TexBySize; + typedef map > > TexBySize; TexBySize tex_by_size; int num_textures = 0; - Textures::iterator ti; + PTextures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *texture = (*ti).second; + PTexture *texture = (*ti).second; - if (texture->get_omit() == Texture::OR_none) { + if (texture->get_omit() == PTexture::OR_none) { int xsize, ysize; if (texture->get_req(xsize, ysize)) { tex_by_size[-ysize][-xsize].insert(texture); @@ -481,9 +481,9 @@ get_eligible_textures(vector &textures) { TexBySize::const_iterator t1; for (t1 = tex_by_size.begin(); t1 != tex_by_size.end(); ++t1) { - map >::const_iterator t2; + map >::const_iterator t2; for (t2 = (*t1).second.begin(); t2 != (*t1).second.end(); ++t2) { - set::const_iterator t3; + set::const_iterator t3; for (t3 = (*t2).second.begin(); t3 != (*t2).second.end(); ++t3) { textures.push_back(*t3); } @@ -531,12 +531,12 @@ bool AttribFile:: transfer_unplaced_images(bool force_redo_all) { bool okflag = true; - Textures::iterator ti; + PTextures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *texture = (*ti).second; + PTexture *texture = (*ti).second; - if (texture->get_omit() != Texture::OR_none && - texture->get_omit() != Texture::OR_unused) { + if (texture->get_omit() != PTexture::OR_none && + texture->get_omit() != PTexture::OR_unused) { // Here's a texture that needs to be moved to our mapdir. But // maybe it's already there and hasn't changed recently. if (force_redo_all || texture->needs_refresh()) { @@ -558,14 +558,14 @@ transfer_unplaced_images(bool force_redo_all) { void AttribFile:: -check_dup_textures(map &textures, +check_dup_textures(map &textures, map &dup_textures) const { - Textures::const_iterator ti; + PTextures::const_iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *texture = (*ti).second; + PTexture *texture = (*ti).second; string name = texture->get_name(); - map::iterator mi = textures.find(name); + map::iterator mi = textures.find(name); if (mi == textures.end()) { // This texture hasn't been used yet. textures[name] = texture; @@ -573,7 +573,7 @@ check_dup_textures(map &textures, } else { // This texture has already been used in another palette. The // smaller of the two is considered wasted space. - Texture *other = (*mi).second; + PTexture *other = (*mi).second; if (!other->is_really_packed() && !texture->is_really_packed()) { // No, neither one is packed, so it's not wasted space. @@ -637,9 +637,9 @@ collect_statistics(int &num_textures, int &num_placed, int &num_palettes, palette_size = 0; unplaced_size = 0; - Textures::const_iterator ti; + PTextures::const_iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *texture = (*ti).second; + PTexture *texture = (*ti).second; int xsize, ysize; int rxsize, rysize; @@ -795,7 +795,7 @@ write_pi(ostream &out) const { } out << "\npathnames\n"; - Textures::const_iterator ti; + PTextures::const_iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { (*ti).second->write_pathname(out); } @@ -818,20 +818,20 @@ write_pi(ostream &out) const { } // Sort textures in descending order by scale percent. - typedef multimap SortTextures; - SortTextures sort_textures; + typedef multimap SortPTextures; + SortPTextures sort_textures; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *texture = (*ti).second; - sort_textures.insert(SortTextures::value_type(-texture->get_scale_pct(), + PTexture *texture = (*ti).second; + sort_textures.insert(SortPTextures::value_type(-texture->get_scale_pct(), texture)); } bool any_surprises = false; out << "\ntextures\n"; - SortTextures::const_iterator sti; + SortPTextures::const_iterator sti; for (sti = sort_textures.begin(); sti != sort_textures.end(); ++sti) { - Texture *texture = (*sti).second; + PTexture *texture = (*sti).second; texture->write_size(out); any_surprises = any_surprises || !texture->matched_anything(); } @@ -841,7 +841,7 @@ write_pi(ostream &out) const { // textures. out << "\nsurprises\n"; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { - Texture *texture = (*ti).second; + PTexture *texture = (*ti).second; if (!texture->matched_anything()) { out << " " << texture->get_name() << "\n"; } @@ -938,7 +938,7 @@ parse_texture(const vector &words, istream &infile, nout << "Expected texture name and additional parameters.\n"; return false; } - Texture *texture = get_texture(twords[0]); + PTexture *texture = get_texture(twords[0]); int kw = 1; while (kw < (int)twords.size()) { @@ -980,7 +980,7 @@ parse_pathname(const vector &words, istream &infile, getline(infile, line); line = trim_right(line); line_num++; - Texture *texture = NULL; + PTexture *texture = NULL; while (!infile.eof() && !line.empty() && isspace(line[0])) { vector twords = extract_words(line); @@ -1094,7 +1094,7 @@ parse_palette(const vector &words, istream &infile, return false; } - Texture *texture = get_texture(twords[0]); + PTexture *texture = get_texture(twords[0]); if (!(twords[1] == "at")) { nout << "Expected keyword 'at'\n"; @@ -1136,7 +1136,7 @@ parse_unplaced(const vector &words, istream &infile, return false; } - Texture *texture = get_texture(words[1]); + PTexture *texture = get_texture(words[1]); if (!(words[2] == "because")) { nout << "Expected keyword 'because'\n"; @@ -1144,19 +1144,19 @@ parse_unplaced(const vector &words, istream &infile, } if (words[3] == "size") { - texture->set_omit(Texture::OR_size); + texture->set_omit(PTexture::OR_size); } else if (words[3] == "repeats") { - texture->set_omit(Texture::OR_repeats); + texture->set_omit(PTexture::OR_repeats); } else if (words[3] == "omitted") { - texture->set_omit(Texture::OR_omitted); + texture->set_omit(PTexture::OR_omitted); } else if (words[3] == "unused") { - texture->set_omit(Texture::OR_unused); + texture->set_omit(PTexture::OR_unused); } else if (words[3] == "unknown") { - texture->set_omit(Texture::OR_unknown); + texture->set_omit(PTexture::OR_unknown); } else if (words[3] == "solitary") { - texture->set_omit(Texture::OR_solitary); + texture->set_omit(PTexture::OR_solitary); } else if (words[3] == "cmdline") { - texture->set_omit(Texture::OR_cmdline); + texture->set_omit(PTexture::OR_cmdline); } else { nout << "Unknown keyword " << words[3] << "\n"; return false; diff --git a/pandatool/src/egg-palettize/attribFile.h b/pandatool/src/egg-palettize/attribFile.h index a29226139d..c32fcc44fd 100644 --- a/pandatool/src/egg-palettize/attribFile.h +++ b/pandatool/src/egg-palettize/attribFile.h @@ -14,7 +14,7 @@ #include class UserAttribLine; -class Texture; +class PTexture; class Palette; class SourceEgg; class EggPalettize; @@ -46,20 +46,20 @@ public: void finalize_palettes(); void remove_unused_lines(); bool check_packing(bool force_optimal); - bool pack_texture(Texture *texture); - bool unpack_texture(Texture *texture); + bool pack_texture(PTexture *texture); + bool unpack_texture(PTexture *texture); void touch_dirty_egg_files(bool force_redo_all, bool eggs_include_images); - Texture *get_texture(const string &name); - void get_eligible_textures(vector &textures); + PTexture *get_texture(const string &name); + void get_eligible_textures(vector &textures); SourceEgg *get_egg(Filename name); bool generate_palette_images(); bool transfer_unplaced_images(bool force_redo_all); - void check_dup_textures(map &textures, + void check_dup_textures(map &textures, map &dup_textures) const; void collect_statistics(int &num_textures, int &num_placed, @@ -77,8 +77,8 @@ private: typedef vector Palettes; Palettes _palettes; - typedef map Textures; - Textures _textures; + typedef map PTextures; + PTextures _textures; string get_pi_filename(const string &txa_filename) const; diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index 173031a7db..8a2c190d7c 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -5,7 +5,7 @@ #include "eggPalettize.h" #include "attribFile.h" -#include "texture.h" +#include "pTexture.h" #include "string_utils.h" #include "sourceEgg.h" @@ -315,7 +315,7 @@ format_space(int size_pixels, bool verbose) { void EggPalettize:: report_statistics() { // Look for textures in common. - map textures; + map textures; map dup_textures; AttribFiles::iterator afi; @@ -371,12 +371,12 @@ report_statistics() { int net_orig_size = 0; int net_resized_size = 0; int net_unplaced_size = 0; - typedef map > UnplacedReasons; + typedef map > UnplacedReasons; UnplacedReasons unplaced_reasons; - map::iterator ti; + map::iterator ti; for (ti = textures.begin(); ti != textures.end(); ++ti) { - Texture *texture = (*ti).second; + PTexture *texture = (*ti).second; int xsize, ysize; int rxsize, rysize; @@ -427,41 +427,41 @@ report_statistics() { for (uri = unplaced_reasons.begin(); uri != unplaced_reasons.end(); ++uri) { - Texture::OmitReason reason = (*uri).first; + PTexture::OmitReason reason = (*uri).first; int count = (*uri).second.first; int size = (*uri).second.second; cout << count << " textures (" << format_space(size) << ") unplaced because "; switch (reason) { - case Texture::OR_none: + case PTexture::OR_none: cout << "of no reason--textures should have been placed\n"; break; - case Texture::OR_size: + case PTexture::OR_size: cout << "size was too large for palette\n"; break; - case Texture::OR_repeats: + case PTexture::OR_repeats: cout << "repeating\n"; break; - case Texture::OR_omitted: + case PTexture::OR_omitted: cout << "explicitly omitted\n"; break; - case Texture::OR_unused: + case PTexture::OR_unused: cout << "unused by any egg file\n"; break; - case Texture::OR_unknown: + case PTexture::OR_unknown: cout << "texture file is missing\n"; break; - case Texture::OR_cmdline: + case PTexture::OR_cmdline: cout << "-x was given on command line\n"; break; - case Texture::OR_solitary: + case PTexture::OR_solitary: cout << "texture was alone on a palette\n"; break; diff --git a/pandatool/src/egg-palettize/eggPalettize.h b/pandatool/src/egg-palettize/eggPalettize.h index 8f38ccefc3..348c8a6077 100644 --- a/pandatool/src/egg-palettize/eggPalettize.h +++ b/pandatool/src/egg-palettize/eggPalettize.h @@ -13,7 +13,7 @@ #include -class Texture; +class PTexture; //////////////////////////////////////////////////////////////////// // Class : EggPalettize diff --git a/pandatool/src/egg-palettize/imageFile.h b/pandatool/src/egg-palettize/imageFile.h index e65d1ac415..8d0080bb0e 100644 --- a/pandatool/src/egg-palettize/imageFile.h +++ b/pandatool/src/egg-palettize/imageFile.h @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////////// // Class : ImageFile -// Description : This is the base class for both Palette and Texture. +// Description : This is the base class for both Palette and PTexture. //////////////////////////////////////////////////////////////////// class ImageFile { public: diff --git a/pandatool/src/egg-palettize/texture.cxx b/pandatool/src/egg-palettize/pTexture.cxx similarity index 92% rename from pandatool/src/egg-palettize/texture.cxx rename to pandatool/src/egg-palettize/pTexture.cxx index 8552325092..55c2bec096 100644 --- a/pandatool/src/egg-palettize/texture.cxx +++ b/pandatool/src/egg-palettize/pTexture.cxx @@ -1,9 +1,9 @@ -// Filename: texture.cxx +// Filename: pTexture.cxx // Created by: drose (02Sep99) // //////////////////////////////////////////////////////////////////// -#include "texture.h" +#include "pTexture.h" #include "palette.h" #include "attribFile.h" @@ -11,8 +11,8 @@ #include -Texture:: -Texture(AttribFile *af, const Filename &name) : +PTexture:: +PTexture(AttribFile *af, const Filename &name) : _name(name), _attrib_file(af) { @@ -32,12 +32,12 @@ Texture(AttribFile *af, const Filename &name) : _palette = NULL; } -Filename Texture:: +Filename PTexture:: get_name() const { return _name; } -void Texture:: +void PTexture:: add_filename(const Filename &filename) { if (!filename.exists()) { // Store the filename, even though it doesn't exist. @@ -93,19 +93,19 @@ add_filename(const Filename &filename) { } } -Filename Texture:: +Filename PTexture:: get_filename() const { Filename filename = _name; filename.set_dirname(_attrib_file->_map_dirname); return filename; } -Filename Texture:: +Filename PTexture:: get_basename() const { return _name; } -bool Texture:: +bool PTexture:: get_size(int &xsize, int &ysize) { if (!_got_size) { read_header(); @@ -120,7 +120,7 @@ get_size(int &xsize, int &ysize) { return true; } -void Texture:: +void PTexture:: set_size(int xsize, int ysize) { // If we've already read the file header, don't let anyone tell us // differently. @@ -131,7 +131,7 @@ set_size(int xsize, int ysize) { } } -bool Texture:: +bool PTexture:: get_req(int &xsize, int &ysize) { if (!_got_req) { return get_size(xsize, ysize); @@ -141,7 +141,7 @@ get_req(int &xsize, int &ysize) { return true; } -bool Texture:: +bool PTexture:: get_last_req(int &xsize, int &ysize) { if (!_got_last_req) { return get_size(xsize, ysize); @@ -151,14 +151,14 @@ get_last_req(int &xsize, int &ysize) { return true; } -void Texture:: +void PTexture:: set_last_req(int xsize, int ysize) { _last_req_xsize = xsize; _last_req_ysize = ysize; _got_last_req = true; } -void Texture:: +void PTexture:: reset_req(int xsize, int ysize) { if (_got_last_req && (_last_req_xsize != xsize || _last_req_ysize != ysize)) { @@ -172,7 +172,7 @@ reset_req(int xsize, int ysize) { _got_req = true; } -void Texture:: +void PTexture:: scale_req(double scale_pct) { if (!_got_size) { read_header(); @@ -183,7 +183,7 @@ scale_req(double scale_pct) { } } -void Texture:: +void PTexture:: clear_req() { _got_req = false; _margin = _attrib_file->_default_margin; @@ -195,7 +195,7 @@ clear_req() { } } -double Texture:: +double PTexture:: get_scale_pct() { if (!_got_size) { read_header(); @@ -209,27 +209,27 @@ get_scale_pct() { } } -int Texture:: +int PTexture:: get_margin() const { return _margin; } -void Texture:: +void PTexture:: set_margin(int margin) { _margin = margin; } -Texture::OmitReason Texture:: +PTexture::OmitReason PTexture:: get_omit() const { return _omit; } -void Texture:: +void PTexture:: set_omit(OmitReason omit) { _omit = omit; } -bool Texture:: +bool PTexture:: needs_refresh() { if (!_texture_changed) { // We consider the texture to be out-of-date if it's moved around @@ -266,42 +266,42 @@ needs_refresh() { return _texture_changed; } -void Texture:: +void PTexture:: set_changed(bool changed) { _texture_changed = changed; } -bool Texture:: +bool PTexture:: unused() const { return _unused; } -void Texture:: +void PTexture:: set_unused(bool unused) { _unused = unused; } -bool Texture:: +bool PTexture:: matched_anything() const { return _matched_anything; } -void Texture:: +void PTexture:: set_matched_anything(bool matched_anything) { _matched_anything = matched_anything; } -bool Texture:: +bool PTexture:: uses_alpha() const { return _uses_alpha; } -void Texture:: +void PTexture:: set_uses_alpha(bool uses_alpha) { _uses_alpha = uses_alpha; } -void Texture:: +void PTexture:: mark_pack_location(Palette *palette, int left, int top, int xsize, int ysize, int margin) { _is_packed = true; @@ -313,36 +313,36 @@ mark_pack_location(Palette *palette, int left, int top, _pmargin = margin; } -void Texture:: +void PTexture:: mark_unpacked() { _is_packed = false; } -bool Texture:: +bool PTexture:: is_packed() const { return _is_packed; } // Returns the same thing as is_packed(), except it doesn't consider a // texture that has been left alone on a palette to be packed. -bool Texture:: +bool PTexture:: is_really_packed() const { return _is_packed && _omit != OR_solitary; } -Palette *Texture:: +Palette *PTexture:: get_palette() const { return _is_packed ? _palette : (Palette *)NULL; } -bool Texture:: +bool PTexture:: get_packed_location(int &left, int &top) const { left = _pleft; top = _ptop; return _is_packed; } -bool Texture:: +bool PTexture:: get_packed_size(int &xsize, int &ysize, int &margin) const { xsize = _pxsize; ysize = _pysize; @@ -350,7 +350,7 @@ get_packed_size(int &xsize, int &ysize, int &margin) const { return _is_packed; } -void Texture:: +void PTexture:: record_orig_state() { // Records the current packing state, storing it aside as the state // at load time. Later, when the packing state may have changed, @@ -367,7 +367,7 @@ record_orig_state() { } } -bool Texture:: +bool PTexture:: packing_changed() const { if (_orig_is_packed != _is_packed) { return true; @@ -383,7 +383,7 @@ packing_changed() const { return false; } -void Texture:: +void PTexture:: write_size(ostream &out) { if (_omit != OR_unused) { if (!_got_size) { @@ -400,7 +400,7 @@ write_size(ostream &out) { } } -void Texture:: +void PTexture:: write_pathname(ostream &out) const { if (_got_filename && _omit != OR_unused) { if (!_file_exists) { @@ -423,7 +423,7 @@ write_pathname(ostream &out) const { } } -void Texture:: +void PTexture:: write_unplaced(ostream &out) const { if (_omit != OR_none && _omit != OR_unused) { out << "unplaced " << get_name() << " because "; @@ -457,13 +457,13 @@ write_unplaced(ostream &out) const { } } -bool Texture:: +bool PTexture:: transfer() { bool okflag = true; Filename new_filename = get_filename(); if (new_filename == _filename) { - nout << "*** Texture " << _name << " is already in the map directory!\n" + nout << "*** PTexture " << _name << " is already in the map directory!\n" << " Cannot modify texture in place!\n"; return false; } @@ -519,7 +519,7 @@ transfer() { return okflag; } -PNMImage *Texture:: +PNMImage *PTexture:: read_image() { if (!_got_filename || !_file_exists) { return NULL; @@ -535,7 +535,7 @@ read_image() { return NULL; } -void Texture:: +void PTexture:: check_size() { // Make sure the file has the size it claims to have. if (_got_size) { @@ -551,7 +551,7 @@ check_size() { } } -void Texture:: +void PTexture:: read_header() { // Open the file and read its header to determine its size. if (_got_filename && _file_exists) { @@ -563,7 +563,7 @@ read_header() { } } -bool Texture:: +bool PTexture:: read_image_header(const Filename &filename, int &xsize, int &ysize) { PNMImageHeader header; if (!header.read_header(filename)) { @@ -576,7 +576,7 @@ read_image_header(const Filename &filename, int &xsize, int &ysize) { return true; } -int Texture:: +int PTexture:: to_power_2(int value) { int x = 1; while ((x << 1) <= value) { diff --git a/pandatool/src/egg-palettize/texture.h b/pandatool/src/egg-palettize/pTexture.h similarity index 94% rename from pandatool/src/egg-palettize/texture.h rename to pandatool/src/egg-palettize/pTexture.h index 7d005955fd..052ccb0214 100644 --- a/pandatool/src/egg-palettize/texture.h +++ b/pandatool/src/egg-palettize/pTexture.h @@ -1,10 +1,10 @@ -// Filename: texture.h +// Filename: pTexture.h // Created by: drose (02Sep99) // //////////////////////////////////////////////////////////////////// -#ifndef TEXTURE_H -#define TEXTURE_H +#ifndef PTEXTURE_H +#define PTEXTURE_H #include @@ -17,10 +17,10 @@ class PNMImage; class AttribFile; //////////////////////////////////////////////////////////////////// -// Class : Texture +// Class : PTexture // Description : //////////////////////////////////////////////////////////////////// -class Texture : public ImageFile { +class PTexture : public ImageFile { public: enum OmitReason { OR_none, @@ -28,7 +28,7 @@ public: OR_cmdline, OR_solitary }; - Texture(AttribFile *af, const Filename &name); + PTexture(AttribFile *af, const Filename &name); Filename get_name() const; diff --git a/pandatool/src/egg-palettize/palette.cxx b/pandatool/src/egg-palettize/palette.cxx index 7bde306af3..4f4740ac61 100644 --- a/pandatool/src/egg-palettize/palette.cxx +++ b/pandatool/src/egg-palettize/palette.cxx @@ -4,7 +4,7 @@ //////////////////////////////////////////////////////////////////// #include "palette.h" -#include "texture.h" +#include "pTexture.h" #include "attribFile.h" #include "string_utils.h" @@ -215,7 +215,7 @@ get_size(int &xsize, int &ysize) const { void Palette:: -place_texture_at(Texture *texture, int left, int top, +place_texture_at(PTexture *texture, int left, int top, int xsize, int ysize, int margin) { TexturePlacement tp; tp._texture = texture; @@ -230,7 +230,7 @@ place_texture_at(Texture *texture, int left, int top, } bool Palette:: -pack_texture(Texture *texture) { +pack_texture(PTexture *texture) { int xsize, ysize; if (!texture->get_req(xsize, ysize)) { return false; @@ -246,7 +246,7 @@ pack_texture(Texture *texture) { } bool Palette:: -unpack_texture(Texture *texture) { +unpack_texture(PTexture *texture) { TexPlace::iterator ti; for (ti = _texplace.begin(); ti != _texplace.end(); ++ti) { if ((*ti)._texture == texture) { @@ -334,7 +334,7 @@ finalize_palette() { if (_texplace.size() == 1) { // If we packed exactly one texture, never mind. - Texture *texture = (*_texplace.begin())._texture; + PTexture *texture = (*_texplace.begin())._texture; // This is a little odd: we mark the texture as being omitted, but // we don't actually unpack it. That way it will still be @@ -342,7 +342,7 @@ finalize_palette() { // palettizations), but it will also be copied to the map // directory, and any egg files that reference it will use the // texture and not the palette. - texture->set_omit(Texture::OR_solitary); + texture->set_omit(PTexture::OR_solitary); } } @@ -371,7 +371,7 @@ generate_image() { TexPlace::const_iterator ti; for (ti = _texplace.begin(); ti != _texplace.end(); ++ti) { - Texture *texture = (*ti)._texture; + PTexture *texture = (*ti)._texture; nout << " " << texture->get_name() << "\n"; okflag = copy_texture_image(palette, *ti) && okflag; } @@ -415,7 +415,7 @@ refresh_image() { TexPlace::const_iterator ti; for (ti = _texplace.begin(); ti != _texplace.end(); ++ti) { - Texture *texture = (*ti)._texture; + PTexture *texture = (*ti)._texture; if (texture->needs_refresh()) { if (!any_changed) { nout << "Refreshing " << _filename << "\n"; diff --git a/pandatool/src/egg-palettize/palette.h b/pandatool/src/egg-palettize/palette.h index 266393de24..f8087963a6 100644 --- a/pandatool/src/egg-palettize/palette.h +++ b/pandatool/src/egg-palettize/palette.h @@ -14,7 +14,7 @@ #include -class Texture; +class PTexture; class PNMImage; class AttribFile; @@ -41,11 +41,11 @@ public: void get_size(int &xsize, int &ysize) const; - void place_texture_at(Texture *texture, int left, int top, + void place_texture_at(PTexture *texture, int left, int top, int xsize, int ysize, int margin); - bool pack_texture(Texture *texture); - bool unpack_texture(Texture *texture); + bool pack_texture(PTexture *texture); + bool unpack_texture(PTexture *texture); void optimal_resize(); @@ -63,7 +63,7 @@ private: PNMImage *resize_image(PNMImage *source) const; PNMImage *add_margins(PNMImage *source) const; - Texture *_texture; + PTexture *_texture; int _left, _top; int _xsize, _ysize, _margin; }; diff --git a/pandatool/src/egg-palettize/sourceEgg.cxx b/pandatool/src/egg-palettize/sourceEgg.cxx index 3860479749..c3527dbcc1 100644 --- a/pandatool/src/egg-palettize/sourceEgg.cxx +++ b/pandatool/src/egg-palettize/sourceEgg.cxx @@ -4,7 +4,7 @@ //////////////////////////////////////////////////////////////////// #include "sourceEgg.h" -#include "texture.h" +#include "pTexture.h" #include "eggPalettize.h" #include "string_utils.h" #include "palette.h" @@ -18,7 +18,7 @@ TypeHandle SourceEgg::_type_handle; SourceEgg::TextureRef:: -TextureRef(Texture *texture, bool repeats, bool alpha) : +TextureRef(PTexture *texture, bool repeats, bool alpha) : _texture(texture), _repeats(repeats), _alpha(alpha) @@ -31,7 +31,7 @@ SourceEgg() { } SourceEgg::TextureRef &SourceEgg:: -add_texture(Texture *texture, bool repeats, bool alpha) { +add_texture(PTexture *texture, bool repeats, bool alpha) { _texrefs.push_back(TextureRef(texture, repeats, alpha)); return _texrefs.back(); } @@ -48,17 +48,17 @@ get_textures(AttribFile &af, EggPalettize *prog) { EggTexture *eggtex = (*ti); string name = eggtex->get_basename(); - Texture *texture = af.get_texture(name); + PTexture *texture = af.get_texture(name); texture->add_filename(*eggtex); if (prog->_dont_palettize) { // If the user specified -x, it means to omit all textures // processed in this run, forever. - texture->set_omit(Texture::OR_cmdline); + texture->set_omit(PTexture::OR_cmdline); } else { // Or until we next see it without -x. - if (texture->get_omit() == Texture::OR_cmdline) { - texture->set_omit(Texture::OR_none); + if (texture->get_omit() == PTexture::OR_cmdline) { + texture->set_omit(PTexture::OR_none); } } @@ -158,19 +158,19 @@ get_textures(AttribFile &af, EggPalettize *prog) { } } -// Updates each Texture with the flags stored in the various egg +// Updates each PTexture with the flags stored in the various egg // files. Also marks textures as used. void SourceEgg:: mark_texture_flags() { TexRefs::iterator ti; for (ti = _texrefs.begin(); ti != _texrefs.end(); ++ti) { - Texture *texture = (*ti)._texture; + PTexture *texture = (*ti)._texture; texture->set_unused(false); if ((*ti)._alpha) { texture->set_uses_alpha(true); } if ((*ti)._repeats) { - texture->set_omit(Texture::OR_repeats); + texture->set_omit(PTexture::OR_repeats); } } } @@ -180,7 +180,7 @@ void SourceEgg:: update_trefs() { TexRefs::iterator ti; for (ti = _texrefs.begin(); ti != _texrefs.end(); ++ti) { - Texture *texture = (*ti)._texture; + PTexture *texture = (*ti)._texture; EggTexture *eggtex = (*ti)._eggtex; if (eggtex != NULL) { @@ -194,7 +194,7 @@ update_trefs() { */ if (!texture->is_packed() || - texture->get_omit() != Texture::OR_none) { + texture->get_omit() != PTexture::OR_none) { // This texture wasn't palettized, so just rename the // reference to the new one. eggtex->set_fullpath(texture->get_filename()); diff --git a/pandatool/src/egg-palettize/sourceEgg.h b/pandatool/src/egg-palettize/sourceEgg.h index 6247c3922e..6f813ff89c 100644 --- a/pandatool/src/egg-palettize/sourceEgg.h +++ b/pandatool/src/egg-palettize/sourceEgg.h @@ -12,7 +12,7 @@ #include -class Texture; +class PTexture; class AttribFile; class EggPalettize; class EggTexture; @@ -24,7 +24,7 @@ public: SourceEgg(); - TextureRef &add_texture(Texture *texture, bool repeats, bool alpha); + TextureRef &add_texture(PTexture *texture, bool repeats, bool alpha); void get_textures(AttribFile &af, EggPalettize *prog); void mark_texture_flags(); @@ -38,9 +38,9 @@ public: class TextureRef { public: - TextureRef(Texture *texture, bool repeats, bool alpha); + TextureRef(PTexture *texture, bool repeats, bool alpha); - Texture *_texture; + PTexture *_texture; bool _repeats; bool _alpha; diff --git a/pandatool/src/egg-palettize/userAttribLine.cxx b/pandatool/src/egg-palettize/userAttribLine.cxx index 9e48be4169..c645cf3e04 100644 --- a/pandatool/src/egg-palettize/userAttribLine.cxx +++ b/pandatool/src/egg-palettize/userAttribLine.cxx @@ -5,7 +5,7 @@ #include "userAttribLine.h" #include "string_utils.h" -#include "texture.h" +#include "pTexture.h" #include "attribFile.h" #include @@ -143,7 +143,7 @@ write(ostream &out) const { } bool UserAttribLine:: -match_texture(Texture *texture, int &margin) { +match_texture(PTexture *texture, int &margin) { // See if the texture name matches any of the filename patterns on // this line. bool matched_any = false; @@ -174,7 +174,7 @@ match_texture(Texture *texture, int &margin) { texture->reset_req(_xsize, _ysize); texture->set_margin(_msize < 0 ? margin : _msize); if (_omit) { - texture->set_omit(Texture::OR_omitted); + texture->set_omit(PTexture::OR_omitted); } return true; @@ -182,13 +182,13 @@ match_texture(Texture *texture, int &margin) { texture->scale_req(_scale_pct); texture->set_margin(_msize < 0 ? margin : _msize); if (_omit) { - texture->set_omit(Texture::OR_omitted); + texture->set_omit(PTexture::OR_omitted); } return true; case LT_name: if (_omit) { - texture->set_omit(Texture::OR_omitted); + texture->set_omit(PTexture::OR_omitted); } return true; diff --git a/pandatool/src/egg-palettize/userAttribLine.h b/pandatool/src/egg-palettize/userAttribLine.h index aa4ac80b18..7eb658542d 100644 --- a/pandatool/src/egg-palettize/userAttribLine.h +++ b/pandatool/src/egg-palettize/userAttribLine.h @@ -11,7 +11,7 @@ #include class AttribFile; -class Texture; +class PTexture; //////////////////////////////////////////////////////////////////// // Class : UserAttribLine @@ -44,7 +44,7 @@ public: void write(ostream &out) const; - bool match_texture(Texture *texture, int &margin); + bool match_texture(PTexture *texture, int &margin); private: enum LineType {