Преглед изворни кода

IES Loader

Updated IES loader to use torque math functions and calls in the problem areas for mac and linux.

New F32_MIN_EX which is lower than F32_MIN (required for ies profiles)
marauder2k7 пре 1 година
родитељ
комит
ad64b4f2df

+ 14 - 12
Engine/source/gfx/bitmap/loaders/ies/ies_loader.cpp

@@ -39,8 +39,10 @@
 #include <algorithm>
 #include <functional>
 
+#include "math/mMathFn.h"
+
 IESFileInfo::IESFileInfo()
-	: _cachedIntegral(std::numeric_limits<float>::max())
+	: _cachedIntegral(F32_MAX)
 	, _error("No data loaded")
 {
 }
@@ -117,7 +119,7 @@ IESLoadHelper::load(const std::string& data, IESFileInfo& info)
 	}
 
 	this->getFloat(dataPos, dataPos, info.totalLights);
-	if (info.totalLights < 0 || info.totalLights > std::numeric_limits<short>::max())
+	if (info.totalLights < 0 || info.totalLights > F32_MAX)
 	{
 		info._error = "Light Count is not valid";
 		return false;
@@ -138,14 +140,14 @@ IESLoadHelper::load(const std::string& data, IESFileInfo& info)
 	}
 
 	this->getInt(dataPos, dataPos, info.anglesNumV);
-	if (info.anglesNumV < 0 || info.anglesNumV > std::numeric_limits<short>::max())
+   if (info.anglesNumV < 0 || info.anglesNumV > F32_MAX)
 	{
 		info._error = "VAnglesNum is not valid";
 		return false;
 	}
 
 	this->getInt(dataPos, dataPos, info.anglesNumH);
-	if (info.anglesNumH < 0 || info.anglesNumH > std::numeric_limits<short>::max())
+	if (info.anglesNumH < 0 || info.anglesNumH > F32_MAX)
 	{
 		info._error = "HAnglesNum is not valid";
 		return false;
@@ -162,8 +164,8 @@ IESLoadHelper::load(const std::string& data, IESFileInfo& info)
 	this->getFloat(dataPos, dataPos, info.futureUse);
 	this->getFloat(dataPos, dataPos, info.inputWatts);
 
-	float minSoFarV = std::numeric_limits<float>::lowest();
-	float minSoFarH = std::numeric_limits<float>::lowest();
+   float minSoFarV = F32_MIN_EX;
+   float minSoFarH = F32_MIN_EX;
 
 	info._anglesV.reserve(info.anglesNumV);
 	info._anglesH.reserve(info.anglesNumH);
@@ -358,16 +360,16 @@ IESLoadHelper::saveAsPreview(const IESFileInfo& info, std::uint8_t* data, std::u
 			float lz = -0.5f - 0.0f;
 
 			// normalize
-			float length = std::sqrt(lx * lx + ly * ly + lz * lz);
+			float length = mSqrt(lx * lx + ly * ly + lz * lz);
 			lx /= length;
 			ly /= length;
 			lz /= length;
 
-			float angle = 1.0 - std::acos(lx * 0.0 + ly * -1.0 + lz * 0.0f) / 3.141592654;
+			float angle = 1.0 - mAcos(lx * 0.0 + ly * -1.0 + lz * 0.0f) / 3.141592654;
 
 			float intensity = ies[angle * 255] * maxValue / length;
 
-			std::uint8_t value = std::min(std::max((int)std::floor(TonemapHable(intensity) / TonemapHable(maxValue) * 255.0f), 0), 255);
+			std::uint8_t value = std::min(std::max((int)mFloor(TonemapHable(intensity) / TonemapHable(maxValue) * 255.0f), 0), 255);
 
 			switch (channel)
 			{
@@ -490,8 +492,8 @@ IESLoadHelper::interpolatePoint(const IESFileInfo& info, std::uint32_t x, std::u
 float
 IESLoadHelper::interpolateBilinear(const IESFileInfo& info, float x, float y) const
 {
-	int ix = (int)std::floor(x);
-	int iy = (int)std::floor(y);
+	int ix = (int)mFloor(x);
+	int iy = (int)mFloor(y);
 
 	float fracX = x - ix;
 	float fracY = y - iy;
@@ -576,4 +578,4 @@ IESLoadHelper::getInt(const std::string& data, std::string& next, std::int32_t&
 	getLineContent(data, next, line, stopOnWhiteSpace, stopOnComma);
 	assert(!line.empty());
 	ret = std::atoi(line.c_str());
-}
+}

+ 1 - 0
Engine/source/platform/types.h

@@ -100,6 +100,7 @@ static const S32 S32_MIN = S32(-2147483647 - 1);                  ///< Constant
 static const S32 S32_MAX = S32(2147483647);                       ///< Constant Max Limit S32
 static const U32 U32_MAX = U32(0xffffffff);                       ///< Constant Max Limit U32
 
+static const F32 F32_MIN_EX = F32(-3.40282347e+38);               ///< Constant Min Limit F32
 static const F32 F32_MIN = F32(1.175494351e-38F);                 ///< Constant Min Limit F32
 static const F32 F32_MAX = F32(3.402823466e+38F);                 ///< Constant Max Limit F32
 

+ 1 - 0
Engine/source/platform/typesLinux.h

@@ -73,6 +73,7 @@ static const S32 S32_MIN = S32(-2147483647 - 1);
 static const S32 S32_MAX = S32(2147483647);
 static const U32 U32_MAX = U32(0xffffffff);
 
+static const F32 F32_MIN_EX = F32(-3.40282347e+38);
 static const F32 F32_MAX = F32(3.402823466e+38F);
 static const F32 F32_MIN = F32(1.175494351e-38F);
 

+ 1 - 0
Engine/source/platform/typesWin32.h

@@ -116,6 +116,7 @@ static const S32 S32_MIN = S32(-2147483647 - 1);                  ///< Constant
 static const S32 S32_MAX = S32(2147483647);                       ///< Constant Max Limit S32
 static const U32 U32_MAX = U32(0xffffffff);                       ///< Constant Max Limit U32
 
+static const F32 F32_MIN_EX = F32(-3.40282347e+38);               ///< Constant Min Limit F32
 static const F32 F32_MIN = F32(1.175494351e-38F);                 ///< Constant Min Limit F32
 static const F32 F32_MAX = F32(3.402823466e+38F);                 ///< Constant Max Limit F32
 

+ 1 - 0
Engine/source/platform/typesX86UNIX.h

@@ -73,6 +73,7 @@ static const S32 S32_MIN = S32(-2147483647 - 1);
 static const S32 S32_MAX = S32(2147483647);
 static const U32 U32_MAX = U32(0xffffffff);
 
+static const F32 F32_MIN_EX = F32(-3.40282347e+38);
 static const F32 F32_MAX = F32(3.402823466e+38F);
 static const F32 F32_MIN = F32(1.175494351e-38F);