Fixed a minor bug in heightfield size detection.

This commit is contained in:
rdb 2008-05-09 12:52:35 +00:00
parent 146233c46d
commit 4f6dc278d5
1 changed files with 6 additions and 6 deletions

View File

@ -361,9 +361,9 @@ set_heightfield(const Filename &filename, PNMFileType *ftype) {
if (image.read(filename, ftype)) {
_is_dirty = true;
_heightfield = PNMImage(
max(3, (int) pow(2.0, ceil(log(float(max(2, image.get_x_size())))
max(3, (int) pow(2.0, ceil(log(float(max(2, image.get_x_size() - 1)))
/ log(2.0))) + 1),
max(3, (int) pow(2.0, ceil(log(float(max(2, image.get_y_size())))
max(3, (int) pow(2.0, ceil(log(float(max(2, image.get_y_size() - 1)))
/ log(2.0))) + 1));
// Make sure not to apply gaussian when it's already the right size
if (_heightfield.get_x_size() == image.get_x_size() &&
@ -381,9 +381,9 @@ set_heightfield(const Filename &filename, PNMFileType *ftype) {
INLINE bool GeoMipTerrain::
set_heightfield(const PNMImage &image) {
_heightfield = PNMImage(
max(3, (int) pow(2.0, ceil(log(float(max(2, image.get_x_size())))
max(3, (int) pow(2.0, ceil(log(float(max(2, image.get_x_size() - 1)))
/ log(2.0))) + 1),
max(3, (int) pow(2.0, ceil(log(float(max(2, image.get_y_size())))
max(3, (int) pow(2.0, ceil(log(float(max(2, image.get_y_size() - 1)))
/ log(2.0))) + 1));
// Make sure not to apply gaussian when it's already the right size
if (_heightfield.get_x_size() == image.get_x_size() &&
@ -400,9 +400,9 @@ set_heightfield(const PNMImage &image) {
INLINE bool GeoMipTerrain::
set_heightfield(const Texture *tex) {
_heightfield = PNMImage(
max(3, (int) pow(2.0, ceil(log(float(max(2, tex->get_x_size())))
max(3, (int) pow(2.0, ceil(log(float(max(2, tex->get_x_size() - 1)))
/ log(2.0))) + 1),
max(3, (int) pow(2.0, ceil(log(float(max(2, tex->get_y_size())))
max(3, (int) pow(2.0, ceil(log(float(max(2, tex->get_y_size() - 1)))
/ log(2.0))) + 1));
PNMImage image;
tex->store(image);