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