From d2fee083928bb0a087459a947d8e19f86b9cd657 Mon Sep 17 00:00:00 2001 From: "Asad M. Zaman" Date: Tue, 19 Dec 2006 01:41:57 +0000 Subject: [PATCH] changed opt flag behavior of egg-palettize; it now respects round_uvs --- pandatool/src/egg-palettize/eggPalettize.cxx | 3 +++ pandatool/src/palettizer/texturePlacement.cxx | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index b2f5beff03..03f47639bf 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -783,8 +783,11 @@ run() { pal->reset_images(); _all_textures = true; + /* Asad: I disagree: unless :round is set to no from textures.txa, we + should always leave the _round_uvs to default. // Also turn off the rounding-up of UV's for this purpose. pal->_round_uvs = false; + */ } if (_all_textures) { diff --git a/pandatool/src/palettizer/texturePlacement.cxx b/pandatool/src/palettizer/texturePlacement.cxx index cf3a660d42..fed65600ac 100644 --- a/pandatool/src/palettizer/texturePlacement.cxx +++ b/pandatool/src/palettizer/texturePlacement.cxx @@ -291,9 +291,14 @@ determine_size() { TexCoordd rounded_min_uv = min_uv; TexCoordd rounded_max_uv = max_uv; + //cout << get_name() << endl; + // If so requested, round the minmax out to the next _round_unit. // This cuts down on unnecessary resizing of textures within the // palettes as the egg references change in trivial amounts. + //cout << "rounded_min_uv: " << rounded_min_uv << endl; + //cout << "rounded_max_uv: " << rounded_max_uv << endl; + if (pal->_round_uvs) { rounded_max_uv[0] = ceil((rounded_max_uv[0] - pal->_round_fuzz) / pal->_round_unit) * @@ -308,6 +313,9 @@ determine_size() { rounded_min_uv[1] = floor((rounded_min_uv[1] + pal->_round_fuzz) / pal->_round_unit) * pal->_round_unit; + + //cout << "after rounded_min_uv: " << rounded_min_uv << endl; + //cout << "after rounded_max_uv: " << rounded_max_uv << endl; } // Now determine the size in pixels we require based on the UV's @@ -910,17 +918,25 @@ compute_size_from_uvs(const TexCoordd &min_uv, const TexCoordd &max_uv) { _position._max_uv = max_uv; TexCoordd range = _position._max_uv - _position._min_uv; + //cout << "range: " << range << endl; + + //cout << "_x_size texture: " << _texture->get_x_size() << endl; + //cout << "_y_size texture: " << _texture->get_y_size() << endl; _position._x_size = (int)floor(_texture->get_x_size() * range[0] + 0.5); _position._y_size = (int)floor(_texture->get_y_size() * range[1] + 0.5); + //cout << "_x_size: " << _position._x_size << endl; + //cout << "_y_size: " << _position._y_size << endl; + // We arbitrarily require at least four pixels in each dimension. // Fewer than this may be asking for trouble. _position._x_size = max(_position._x_size, 4); _position._y_size = max(_position._y_size, 4); _position._margin = _texture->get_margin(); - + //cout << "margin: " << _position._margin << endl; + // Normally, we have interior margins, but if the image size is too // small--i.e. the margin size is too great a percentage of the // image size--we'll make them exterior margins so as not to overly