*** 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:
return out << "solitary";
case OR_repeats:
return out << "repeats";
case OR_coverage:
return out << "coverage";
case OR_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
// so far, so there's no point.
OR_repeats,
OR_coverage,
// 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,
// 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()
<< " unplaced because ";
switch (placement->get_omit_reason()) {
case OR_repeats:
out << "repeats ("
<< floor(placement->get_uv_area() * 10000.0 + 0.5) / 100.0
<< "%)";
case OR_coverage:
out << "coverage (" << placement->get_uv_area() << ")";
break;
case OR_size:

View File

@ -39,7 +39,7 @@ Palettizer() {
_map_dirname = "%g";
_margin = 2;
_repeat_threshold = 250.0;
_coverage_threshold = 2.5;
_aggressively_clean_mapdir = true;
_force_power_2 = true;
_color_type = PNMFileTypeRegistry::get_ptr()->get_type_from_extension("rgb");
@ -68,7 +68,7 @@ report_pi() const {
<< FilenameUnifier::make_user_filename(_rel_dirname) << "\n"
<< " palettize size: " << _pal_x_size << " by " << _pal_y_size << "\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"
<< " aggressively clean the map directory: "
<< 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_y_size);
datagram.add_int32(_margin);
datagram.add_float64(_repeat_threshold);
datagram.add_float64(_coverage_threshold);
datagram.add_bool(_force_power_2);
datagram.add_bool(_aggressively_clean_mapdir);
datagram.add_bool(_round_uvs);
@ -726,7 +726,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
_pal_x_size = scan.get_int32();
_pal_y_size = scan.get_int32();
_margin = scan.get_int32();
_repeat_threshold = scan.get_float64();
_coverage_threshold = scan.get_float64();
_force_power_2 = scan.get_bool();
_aggressively_clean_mapdir = scan.get_bool();
_round_uvs = scan.get_bool();

View File

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

View File

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

View File

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

View File

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

View File

@ -351,7 +351,7 @@ write(ostream &out, int indent_level) const {
TexCoordd box = _max_uv - _min_uv;
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) {

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ private:
bool parse_group_line(const vector_string &words);
bool parse_palette_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_round_line(const vector_string &words);
bool parse_remap_line(const vector_string &words);

View File

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

View File

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