dmsovetov / nvidia-texture-tools

Automatically exported from code.google.com/p/nvidia-texture-tools
Other
0 stars 0 forks source link

1 pixel textures causing a endless loop. #65

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Not sure if this is a general limitation, but while switching over to the
new lib my converter hangs on textures that are 1 pixel in width or height.

Thats caused by:
line 243 in FloatImage.h
"uint FloatImage::indexMirror(int x, int y) const"

The while loops can not return on a size of 1 pixel, if in default
WrapMode_Mirror.

Original issue reported on code.google.com by andyieg....@googlemail.com on 23 Sep 2008 at 10:20

GoogleCodeExporter commented 8 years ago
Thanks for the bug report!

There are two solutions:

if (m_width == 1) x = 0;
if (m_height == 1) y = 0;

Or to modify the loop as follows:

x = abs(x);
while (x >= m_width) {
    x = abs(m_width + m_width - x - 1);
}

The second option duplicates the colors of the borders. For example when width 
= 4,
then mirror(3) and mirror(4) return both 3.

I prefer the first option. I've checked this in the 2.0 branch, and will be 
part of
the next 2.0.4 bug fix release.

Original comment by cast...@gmail.com on 24 Sep 2008 at 12:38