From f3120ca780ffe04231db495e67b4ff3853b5eb41 Mon Sep 17 00:00:00 2001 From: Chris Galvan Date: Tue, 25 Jan 2022 09:58:00 -0600 Subject: [PATCH] Made some float constants more explicit and updated the pixel index calculation logic to be more concise Signed-off-by: Chris Galvan --- .../Source/RPI.Reflect/Image/StreamingImageAsset.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp index 1ed900b2b8..dc9f0bbaa6 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp @@ -151,7 +151,7 @@ namespace AZ auto actualMem = reinterpret_cast(mem); AZ::s8 signedMax = std::numeric_limits::max(); AZ::s8 signedMin = aznumeric_cast(-signedMax); - return ScaleValue(AZStd::max(actualMem[index], signedMin), signedMin, signedMax, -1, 1); + return ScaleValue(AZStd::max(actualMem[index], signedMin), signedMin, signedMax, -1.0f, 1.0f); } case AZ::RHI::Format::D16_UNORM: case AZ::RHI::Format::R16_UNORM: @@ -166,7 +166,7 @@ namespace AZ auto actualMem = reinterpret_cast(mem); AZ::s16 signedMax = std::numeric_limits::max(); AZ::s16 signedMin = aznumeric_cast(-signedMax); - return ScaleValue(AZStd::max(actualMem[index], signedMin), signedMin, signedMax, -1, 1); + return ScaleValue(AZStd::max(actualMem[index], signedMin), signedMin, signedMax, -1.0f, 1.0f); } case AZ::RHI::Format::R16_FLOAT: { @@ -391,7 +391,7 @@ namespace AZ { for (uint32_t x = topLeft.first; x <= bottomRight.first; ++x) { - size_t imageDataIndex = (y * width * pixelSize) + (x * pixelSize); + size_t imageDataIndex = (y * width + x) * pixelSize; auto& outValue = outValues[outValuesIndex++]; outValue = Internal::RetrieveFloatValue(imageData.data(), imageDataIndex, imageDescriptor.m_format); @@ -418,7 +418,7 @@ namespace AZ { for (uint32_t x = topLeft.first; x <= bottomRight.first; ++x) { - size_t imageDataIndex = (y * width * pixelSize) + (x * pixelSize); + size_t imageDataIndex = (y * width + x) * pixelSize; auto& outValue = outValues[outValuesIndex++]; outValue = Internal::RetrieveUintValue(imageData.data(), imageDataIndex, imageDescriptor.m_format); @@ -445,7 +445,7 @@ namespace AZ { for (uint32_t x = topLeft.first; x <= bottomRight.first; ++x) { - size_t imageDataIndex = (y * width * pixelSize) + (x * pixelSize); + size_t imageDataIndex = (y * width + x) * pixelSize; auto& outValue = outValues[outValuesIndex++]; outValue = Internal::RetrieveIntValue(imageData.data(), imageDataIndex, imageDescriptor.m_format);