From ffd0c214df83b7fcdb0be8421da78d31b9a3a1f3 Mon Sep 17 00:00:00 2001 From: castano Date: Tue, 7 Sep 2010 18:08:53 +0000 Subject: [PATCH] Fix mirror sampling in trunk. Fixes issue 135. --- trunk/src/nvimage/FloatImage.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trunk/src/nvimage/FloatImage.cpp b/trunk/src/nvimage/FloatImage.cpp index f2bf44f..9ef4099 100644 --- a/trunk/src/nvimage/FloatImage.cpp +++ b/trunk/src/nvimage/FloatImage.cpp @@ -21,10 +21,13 @@ namespace { static int mirror(int x, int w) { + if (w == 1) return 0; + x = abs(x); while (x >= w) { - x = 2 * w - x - 2; + x = abs(w + w - x - 2); } + return x; } }