From 2ea2b40c724e5083f388eb93a8b2ac56009d09ae Mon Sep 17 00:00:00 2001 From: castano Date: Tue, 7 Sep 2010 18:08:27 +0000 Subject: [PATCH] Fix mirror sampling fixes issue 135. --- ChangeLog | 3 ++- src/nvimage/FloatImage.cpp | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7292c0..fca2564 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,8 @@ NVIDIA Texture Tools version 2.0.9 * Improve C# / .NET Wrapper * Add an XNA Game Studio 3.1 Content Processor to make it easy to utilize NVIDIA Texture Tools in XNA applications. * Fix single color DXT1a compressor. Fixes issue 134. - + * Fix mirror sampling. Fixes issue 135. + NVIDIA Texture Tools version 2.0.8 * Fix float to fixed image conversion. Patch provided by Alex Pfaffe. Fixes issue 121. * ColorBlock::isSingleColor compares only RGB channels. Fixes issue 115. diff --git a/src/nvimage/FloatImage.cpp b/src/nvimage/FloatImage.cpp index 0c004f2..9bf43c5 100644 --- a/src/nvimage/FloatImage.cpp +++ b/src/nvimage/FloatImage.cpp @@ -32,14 +32,17 @@ namespace return f - floor(f); } - static int mirror(int x, int w) - { - x = abs(x); - while (x >= w) { - x = 2 * w - x - 2; - } - return x; - } + static int mirror(int x, int w) + { + if (w == 1) return 0; + + x = abs(x); + while (x >= w) { + x = abs(w + w - x - 2); + } + + return x; + } }