*** empty log message ***

This commit is contained in:
David Rose 2000-12-07 18:56:06 +00:00
parent c2905668b8
commit 4cccd97752
15 changed files with 71 additions and 82 deletions

View File

@ -23,8 +23,8 @@ operator << (ostream &out, OmitReason omit) {
case OR_solitary: case OR_solitary:
return out << "solitary"; return out << "solitary";
case OR_repeats: case OR_coverage:
return out << "repeats"; return out << "coverage";
case OR_unknown: case OR_unknown:
return out << "unknown"; return out << "unknown";

View File

@ -30,9 +30,9 @@ enum OmitReason {
// It should be placed, but it's the only one on the palette image // It should be placed, but it's the only one on the palette image
// so far, so there's no point. // so far, so there's no point.
OR_repeats, OR_coverage,
// The texture repeats. Specifically, the UV's for the texture // The texture repeats. Specifically, the UV's for the texture
// exceed the maximum rectangle allowed by repeat_threshold. // exceed the maximum rectangle allowed by coverage_threshold.
OR_unknown, OR_unknown,
// The texture file cannot be read, so its size can't be determined. // The texture file cannot be read, so its size can't be determined.

View File

@ -287,10 +287,8 @@ write_image_info(ostream &out, int indent_level) const {
<< placement->get_texture()->get_name() << placement->get_texture()->get_name()
<< " unplaced because "; << " unplaced because ";
switch (placement->get_omit_reason()) { switch (placement->get_omit_reason()) {
case OR_repeats: case OR_coverage:
out << "repeats (" out << "coverage (" << placement->get_uv_area() << ")";
<< floor(placement->get_uv_area() * 10000.0 + 0.5) / 100.0
<< "%)";
break; break;
case OR_size: case OR_size:

View File

@ -39,7 +39,7 @@ Palettizer() {
_map_dirname = "%g"; _map_dirname = "%g";
_margin = 2; _margin = 2;
_repeat_threshold = 250.0; _coverage_threshold = 2.5;
_aggressively_clean_mapdir = true; _aggressively_clean_mapdir = true;
_force_power_2 = true; _force_power_2 = true;
_color_type = PNMFileTypeRegistry::get_ptr()->get_type_from_extension("rgb"); _color_type = PNMFileTypeRegistry::get_ptr()->get_type_from_extension("rgb");
@ -68,7 +68,7 @@ report_pi() const {
<< FilenameUnifier::make_user_filename(_rel_dirname) << "\n" << FilenameUnifier::make_user_filename(_rel_dirname) << "\n"
<< " palettize size: " << _pal_x_size << " by " << _pal_y_size << "\n" << " palettize size: " << _pal_x_size << " by " << _pal_y_size << "\n"
<< " margin: " << _margin << "\n" << " margin: " << _margin << "\n"
<< " repeat threshold: " << _repeat_threshold << "%\n" << " coverage threshold: " << _coverage_threshold << "\n"
<< " force textures to power of 2: " << yesno(_force_power_2) << "\n" << " force textures to power of 2: " << yesno(_force_power_2) << "\n"
<< " aggressively clean the map directory: " << " aggressively clean the map directory: "
<< yesno(_aggressively_clean_mapdir) << "\n" << yesno(_aggressively_clean_mapdir) << "\n"
@ -608,7 +608,7 @@ write_datagram(BamWriter *writer, Datagram &datagram) {
datagram.add_int32(_pal_x_size); datagram.add_int32(_pal_x_size);
datagram.add_int32(_pal_y_size); datagram.add_int32(_pal_y_size);
datagram.add_int32(_margin); datagram.add_int32(_margin);
datagram.add_float64(_repeat_threshold); datagram.add_float64(_coverage_threshold);
datagram.add_bool(_force_power_2); datagram.add_bool(_force_power_2);
datagram.add_bool(_aggressively_clean_mapdir); datagram.add_bool(_aggressively_clean_mapdir);
datagram.add_bool(_round_uvs); datagram.add_bool(_round_uvs);
@ -726,7 +726,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
_pal_x_size = scan.get_int32(); _pal_x_size = scan.get_int32();
_pal_y_size = scan.get_int32(); _pal_y_size = scan.get_int32();
_margin = scan.get_int32(); _margin = scan.get_int32();
_repeat_threshold = scan.get_float64(); _coverage_threshold = scan.get_float64();
_force_power_2 = scan.get_bool(); _force_power_2 = scan.get_bool();
_aggressively_clean_mapdir = scan.get_bool(); _aggressively_clean_mapdir = scan.get_bool();
_round_uvs = scan.get_bool(); _round_uvs = scan.get_bool();

View File

@ -74,7 +74,7 @@ public:
Filename _rel_dirname; Filename _rel_dirname;
int _pal_x_size, _pal_y_size; int _pal_x_size, _pal_y_size;
int _margin; int _margin;
double _repeat_threshold; double _coverage_threshold;
bool _force_power_2; bool _force_power_2;
bool _aggressively_clean_mapdir; bool _aggressively_clean_mapdir;
bool _round_uvs; bool _round_uvs;

View File

@ -338,27 +338,27 @@ get_omit() const {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: TextureImage::get_repeat_threshold // Function: TextureImage::get_coverage_threshold
// Access: Public // Access: Public
// Description: Returns the suitable repeat threshold for this // Description: Returns the appropriate coverage threshold for this
// texture. This is either the // texture. This is either the
// Palettizer::_repeat_threshold parameter, given // Palettizer::_coverage_threshold parameter, given
// globally via -r, or a particular value for this // globally via -r, or a particular value for this
// texture as supplied by the "repeat" keyword in the // texture as supplied by the "coverage" keyword in the
// .txa file. // .txa file.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
double TextureImage:: double TextureImage::
get_repeat_threshold() const { get_coverage_threshold() const {
return _request._repeat_threshold; return _request._coverage_threshold;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: TextureImage::get_margin // Function: TextureImage::get_margin
// Access: Public // Access: Public
// Description: Returns the suitable repeat threshold for this // Description: Returns the appropriate margin for this texture.
// texture. This is either the Palettizer::_margin // This is either the Palettizer::_margin parameter, or
// parameter, or a particular value for this texture as // a particular value for this texture as supplied by
// supplied by the "margin" keyword in the .txa file. // the "margin" keyword in the .txa file.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
int TextureImage:: int TextureImage::
get_margin() const { get_margin() const {

View File

@ -54,7 +54,7 @@ public:
void determine_placement_size(); void determine_placement_size();
bool get_omit() const; bool get_omit() const;
double get_repeat_threshold() const; double get_coverage_threshold() const;
int get_margin() const; int get_margin() const;
bool is_surprise() const; bool is_surprise() const;

View File

@ -290,10 +290,10 @@ determine_size() {
force_replace(); force_replace();
_omit_reason = OR_omitted; _omit_reason = OR_omitted;
} else if (get_uv_area() > _texture->get_repeat_threshold() / 100.0) { } else if (get_uv_area() > _texture->get_coverage_threshold()) {
// If the texture repeats too many times, we can't place it. // If the texture repeats too many times, we can't place it.
force_replace(); force_replace();
_omit_reason = OR_repeats; _omit_reason = OR_coverage;
} else if ((_position._x_size > pal->_pal_x_size || } else if ((_position._x_size > pal->_pal_x_size ||
_position._y_size > pal->_pal_y_size) || _position._y_size > pal->_pal_y_size) ||
@ -308,11 +308,11 @@ determine_size() {
} else if (_omit_reason == OR_omitted || } else if (_omit_reason == OR_omitted ||
_omit_reason == OR_size || _omit_reason == OR_size ||
_omit_reason == OR_repeats || _omit_reason == OR_coverage ||
_omit_reason == OR_unknown) { _omit_reason == OR_unknown) {
// On the other hand, if the texture was previously omitted // On the other hand, if the texture was previously omitted
// explicitly, or because of its size or repeat count, now it // explicitly, or because of its size or coverage, now it seems to
// seems to fit. // fit.
force_replace(); force_replace();
_omit_reason = OR_working; _omit_reason = OR_working;
@ -679,9 +679,8 @@ write_placed(ostream &out, int indent_level) {
out << " at " out << " at "
<< get_placed_x() << " " << get_placed_y() << " to " << get_placed_x() << " " << get_placed_y() << " to "
<< get_placed_x() + get_placed_x_size() << " " << get_placed_x() + get_placed_x_size() << " "
<< get_placed_y() + get_placed_y_size() << " (used " << get_placed_y() + get_placed_y_size() << " (coverage "
<< floor(get_placed_uv_area() * 10000.0 + 0.5) / 100.0 << get_placed_uv_area() << ")\n";
<< "%)\n";
} else { } else {
out << " not yet placed.\n"; out << " not yet placed.\n";
} }

View File

@ -351,7 +351,7 @@ write(ostream &out, int indent_level) const {
TexCoordd box = _max_uv - _min_uv; TexCoordd box = _max_uv - _min_uv;
double area = box[0] * box[1]; double area = box[0] * box[1];
out << " used " << floor(area * 10000.0 + 0.5) / 100.0 << "%"; out << " coverage " << area;
} }
if (_properties._format != EggTexture::F_unspecified) { if (_properties._format != EggTexture::F_unspecified) {

View File

@ -23,7 +23,7 @@ TextureRequest() {
_magfilter = EggTexture::FT_unspecified; _magfilter = EggTexture::FT_unspecified;
_omit = false; _omit = false;
_margin = 0; _margin = 0;
_repeat_threshold = 0.0; _coverage_threshold = 0.0;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -35,5 +35,5 @@ TextureRequest() {
void TextureRequest:: void TextureRequest::
pre_txa_file() { pre_txa_file() {
_margin = pal->_margin; _margin = pal->_margin;
_repeat_threshold = pal->_repeat_threshold; _coverage_threshold = pal->_coverage_threshold;
} }

View File

@ -35,7 +35,7 @@ public:
EggTexture::FilterType _magfilter; EggTexture::FilterType _magfilter;
bool _omit; bool _omit;
int _margin; int _margin;
double _repeat_threshold; double _coverage_threshold;
}; };
#endif #endif

View File

@ -65,8 +65,8 @@ read(Filename filename) {
} else if (words[0] == ":margin") { } else if (words[0] == ":margin") {
okflag = parse_margin_line(words); okflag = parse_margin_line(words);
} else if (words[0] == ":repeat") { } else if (words[0] == ":coverage") {
okflag = parse_repeat_line(words); okflag = parse_coverage_line(words);
} else if (words[0] == ":imagetype") { } else if (words[0] == ":imagetype") {
okflag = parse_imagetype_line(words); okflag = parse_imagetype_line(words);
@ -279,30 +279,28 @@ parse_margin_line(const vector_string &words) {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: TxaFile::parse_repeat_line // Function: TxaFile::parse_coverage_line
// Access: Private // Access: Private
// Description: Handles the line in a .txa file that begins with the // Description: Handles the line in a .txa file that begins with the
// keyword ":repeat" and indicates the default repeat // keyword ":coverage" and indicates the default
// threshold. // coverage threshold.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool TxaFile:: bool TxaFile::
parse_repeat_line(const vector_string &words) { parse_coverage_line(const vector_string &words) {
if (words.size() != 2) { if (words.size() != 2) {
nout << "Exactly one parameter required for :repeat, the " nout << "Exactly one parameter required for :coverage, the "
<< "percentage for the default repeat threshold.\n"; << "value for the default coverage threshold.\n";
return false; return false;
} }
string tail;
pal->_repeat_threshold = string_to_double(words[1], tail); if (!string_to_double(words[1], pal->_coverage_threshold)) {
if (!(tail.empty() || tail == "%")) { nout << "Invalid coverage threshold: " << words[1] << "\n";
// This is an invalid number.
nout << "Invalid repeat threshold: " << words[1] << "\n";
return false; return false;
} }
if (pal->_repeat_threshold <= 0.0) { if (pal->_coverage_threshold <= 0.0) {
nout << "Invalid repeat threshold: " << pal->_repeat_threshold << "\n"; nout << "Invalid coverage threshold: " << pal->_coverage_threshold << "\n";
return false; return false;
} }

View File

@ -36,7 +36,7 @@ private:
bool parse_group_line(const vector_string &words); bool parse_group_line(const vector_string &words);
bool parse_palette_line(const vector_string &words); bool parse_palette_line(const vector_string &words);
bool parse_margin_line(const vector_string &words); bool parse_margin_line(const vector_string &words);
bool parse_repeat_line(const vector_string &words); bool parse_coverage_line(const vector_string &words);
bool parse_imagetype_line(const vector_string &words); bool parse_imagetype_line(const vector_string &words);
bool parse_round_line(const vector_string &words); bool parse_round_line(const vector_string &words);
bool parse_remap_line(const vector_string &words); bool parse_remap_line(const vector_string &words);

View File

@ -29,8 +29,8 @@ TxaLine() {
_format = EggTexture::F_unspecified; _format = EggTexture::F_unspecified;
_got_margin = false; _got_margin = false;
_margin = 0; _margin = 0;
_got_repeat_threshold = false; _got_coverage_threshold = false;
_repeat_threshold = 0.0; _coverage_threshold = 0.0;
_color_type = (PNMFileType *)NULL; _color_type = (PNMFileType *)NULL;
_alpha_type = (PNMFileType *)NULL; _alpha_type = (PNMFileType *)NULL;
} }
@ -94,11 +94,11 @@ parse(const string &line) {
if (word[word.length() - 1] == '%') { if (word[word.length() - 1] == '%') {
// It's a scale percentage! // It's a scale percentage!
_size_type = ST_scale; _size_type = ST_scale;
const char *nptr = word.c_str();
char *endptr; string tail;
_scale = strtod(nptr, &endptr); _scale = string_to_double(word, tail);
if (*endptr != '%') { if (!(tail == "%")) {
nout << "Invalid scale factor: " << word << "\n"; // This is an invalid number.
return false; return false;
} }
++wi; ++wi;
@ -108,12 +108,12 @@ parse(const string &line) {
vector<int> numbers; vector<int> numbers;
while (wi != words.end() && isdigit((*wi)[0])) { while (wi != words.end() && isdigit((*wi)[0])) {
const string &word = *wi; const string &word = *wi;
const char *nptr = word.c_str(); int num;
char *endptr; if (!string_to_int(word, num)) {
numbers.push_back(strtol(nptr, &endptr, 0));
if (*endptr != '\0') {
nout << "Invalid size: " << word << "\n"; nout << "Invalid size: " << word << "\n";
return false;
} }
numbers.push_back(num);
++wi; ++wi;
} }
if (numbers.size() < 2) { if (numbers.size() < 2) {
@ -163,10 +163,7 @@ parse(const string &line) {
} }
const string &arg = (*wi); const string &arg = (*wi);
const char *nptr = arg.c_str(); if (!string_to_int(arg, _margin)) {
char *endptr;
_margin = strtol(nptr, &endptr, 10);
if (*endptr != '\0') {
nout << "Not an integer: " << arg << "\n"; nout << "Not an integer: " << arg << "\n";
return false; return false;
} }
@ -176,26 +173,23 @@ parse(const string &line) {
} }
_got_margin = true; _got_margin = true;
} else if (word == "repeat") { } else if (word == "coverage") {
++wi; ++wi;
if (wi == words.end()) { if (wi == words.end()) {
nout << "Argument required for 'repeat'.\n"; nout << "Argument required for 'coverage'.\n";
return false; return false;
} }
const string &arg = (*wi); const string &arg = (*wi);
const char *nptr = arg.c_str(); if (!string_to_double(arg, _coverage_threshold)) {
char *endptr;
_repeat_threshold = strtod(nptr, &endptr);
if (*endptr != '\0' && *endptr != '%') {
nout << "Not a number: " << arg << "\n"; nout << "Not a number: " << arg << "\n";
return false; return false;
} }
if (_repeat_threshold < 0.0) { if (_coverage_threshold <= 0.0) {
nout << "Invalid repeat threshold: " << _repeat_threshold << "\n"; nout << "Invalid coverage threshold: " << _coverage_threshold << "\n";
return false; return false;
} }
_got_repeat_threshold = true; _got_coverage_threshold = true;
} else { } else {
// Maybe it's a format name. // Maybe it's a format name.
@ -346,8 +340,8 @@ match_texture(TextureImage *texture) const {
request._margin = _margin; request._margin = _margin;
} }
if (_got_repeat_threshold) { if (_got_coverage_threshold) {
request._repeat_threshold = _repeat_threshold; request._coverage_threshold = _coverage_threshold;
} }
if (_color_type != (PNMFileType *)NULL) { if (_color_type != (PNMFileType *)NULL) {
@ -441,8 +435,8 @@ output(ostream &out) const {
out << " margin " << _margin; out << " margin " << _margin;
} }
if (_got_repeat_threshold) { if (_got_coverage_threshold) {
out << " repeat " << _repeat_threshold; out << " coverage " << _coverage_threshold;
} }
Keywords::const_iterator ki; Keywords::const_iterator ki;

View File

@ -58,8 +58,8 @@ private:
bool _got_margin; bool _got_margin;
int _margin; int _margin;
bool _got_repeat_threshold; bool _got_coverage_threshold;
double _repeat_threshold; double _coverage_threshold;
enum Keyword { enum Keyword {
KW_omit, KW_omit,