From cc0d75400abf3804598cd316e2652159d92af88a Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sun, 21 Oct 2012 14:07:23 -0400 Subject: [PATCH] Fix two bugs that took a surprisingly long time to find. --- BPTCEncoder/src/BC7Compressor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BPTCEncoder/src/BC7Compressor.cpp b/BPTCEncoder/src/BC7Compressor.cpp index 6289471..ca23a36 100755 --- a/BPTCEncoder/src/BC7Compressor.cpp +++ b/BPTCEncoder/src/BC7Compressor.cpp @@ -679,6 +679,7 @@ double BC7CompressionMode::OptimizeEndpointsForCluster(const RGBACluster &cluste bestPbitCombo = nPbitCombo; bestError = error; + lastVisitedState = 0; visitedStates[lastVisitedState].p1 = np1; visitedStates[lastVisitedState].p2 = np2; visitedStates[lastVisitedState].pBitCombo = nPbitCombo; @@ -925,7 +926,8 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto const uint8 a2b = ::QuantizeChannel(uint8(a2), (((char)0x80) >> (GetAlphaChannelPrecision() - 1))); // Compute error - for(int i = 0; i < kMaxNumDataPoints; i++) { + alphaError = 0.0; + for(int i = 0; i < kMaxNumDataPoints; i++) { uint8 val = uint8(alphaVals[i]); @@ -1737,7 +1739,7 @@ namespace BC7C error += 1.0; } #else - error += c.QuantizedError(Min, Max, 2, 0xFFFFFFFF, RGBAVector(w[0], w[1], w[2], w[3])); + error += c.QuantizedError(Min, Max, 4, 0xFFFFFFFF, RGBAVector(w[0], w[1], w[2], w[3])); #endif return error; }