diff --git a/components/openmw-mp/Utils.cpp b/components/openmw-mp/Utils.cpp index f6bd80144..be9cc737b 100644 --- a/components/openmw-mp/Utils.cpp +++ b/components/openmw-mp/Utils.cpp @@ -91,6 +91,11 @@ bool Utils::compareDoubles(double a, double b, double epsilon) return fabs(a - b) < epsilon; } +bool Utils::compareFloats(float a, float b, float epsilon) +{ + return fabs(a - b) < epsilon; +} + // Based on https://stackoverflow.com/a/1489873 unsigned int Utils::getNumberOfDigits(int integer) { diff --git a/components/openmw-mp/Utils.hpp b/components/openmw-mp/Utils.hpp index e69ef6459..b70e621e2 100644 --- a/components/openmw-mp/Utils.hpp +++ b/components/openmw-mp/Utils.hpp @@ -28,7 +28,8 @@ namespace Utils int progressFunc(double TotalToDownload, double NowDownloaded); unsigned int getNumberOfDigits(int integer); - bool compareDoubles(double a, double b, double epsilon); + bool compareDoubles(double a, double b, double epsilon = 0.005); + bool compareFloats(float a, float b, float epsilon = 0.005f); template bool vectorContains(const std::vector &vectorChecked, const Type2 &value)