From 6cc81cdc0506332e135464fd577bc54bccff1650 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 16 Mar 2015 13:54:19 +0100 Subject: [PATCH] (Image) Optimized GetMaxLevel Former-commit-id: cdddd29020a6f82e6095ad30447eb0b6e9f2d8cf --- src/Nazara/Utility/Image.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index ff0cca3f9..7b3f43bda 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -1322,13 +1322,8 @@ void NzImage::Copy(nzUInt8* destination, const nzUInt8* source, nzUInt8 bpp, uns nzUInt8 NzImage::GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth) { - static const float invLog2 = 1.f/std::log(2.f); - - unsigned int widthLevel = static_cast(invLog2 * std::log(static_cast(width))); - unsigned int heightLevel = static_cast(invLog2 * std::log(static_cast(height))); - unsigned int depthLevel = static_cast(invLog2 * std::log(static_cast(depth))); - - return std::max(std::max(std::max(widthLevel, heightLevel), depthLevel), 1U); + // Le niveau maximal est le niveau requis pour la plus grande taille + return std::max(NzIntegralLog2(std::max({width, height, depth})), 1U); } nzUInt8 NzImage::GetMaxLevel(nzImageType type, unsigned int width, unsigned int height, unsigned int depth)