Daniele Bartolini 10 lat temu
rodzic
commit
e2743793af

+ 3 - 4
src/core/filesystem/disk_file.cpp

@@ -8,6 +8,7 @@
 #include "log.h"
 #include "math_utils.h"
 #include "memory.h"
+#include <algorithm>
 
 namespace crown
 {
@@ -85,10 +86,8 @@ bool DiskFile::copy_to(File& file, uint32_t size)
 
 	while (tot_read_bytes < size)
 	{
-		uint32_t read_bytes;
-		uint32_t expected_read_bytes = min(size - tot_read_bytes, chunksize);
-
-		read_bytes = _file.read(buff, expected_read_bytes);
+		uint32_t expected_read_bytes = std::min(size - tot_read_bytes, chunksize);
+		uint32_t read_bytes = _file.read(buff, expected_read_bytes);
 
 		if (read_bytes < expected_read_bytes)
 		{

+ 4 - 9
src/core/math/math_utils.h

@@ -5,7 +5,6 @@
 
 #pragma once
 
-#include "error.h"
 #include "types.h"
 #include <math.h>
 
@@ -24,23 +23,19 @@ inline bool fequal(float a, float b, float precision = FLOAT_PRECISION)
 	return ((b <= (a + precision)) && (b >= (a - precision)));
 }
 
-template <typename T>
-inline T min(const T& a, const T& b)
+inline float fmin(float a, float b)
 {
 	return a < b ? a : b;
 }
 
-template <typename T>
-inline T max(const T& a, const T& b)
+inline float fmax(float a, float b)
 {
 	return a < b ? b : a;
 }
 
-template <typename T>
-inline T clamp(const T& min, const T& max, const T& val)
+inline float fclamp(float min, float max, float val)
 {
-	CE_ASSERT(min < max, "Min must be < max");
-	return val > max ? max : val < min ? min : val;
+	return fmin(fmax(min, val), max);
 }
 
 inline float to_rad(float deg)

+ 3 - 2
src/resource/texture_resource.cpp

@@ -11,6 +11,7 @@
 #include "resource_manager.h"
 #include "log.h"
 #include "compile_options.h"
+#include <algorithm>
 
 namespace crown
 {
@@ -204,8 +205,8 @@ namespace texture_resource
 				return;
 			}
 
-			width = max(1u, width >> 1);
-			height = max(1u, height >> 1);
+			width = std::max(1u, width >> 1);
+			height = std::max(1u, height >> 1);
 			cur_mip++;
 			src += size;
 		}