From 3d87e2f885005fca3c980eedd1f6fd5de38c01dd Mon Sep 17 00:00:00 2001 From: Kearwood Gilbert Date: Sun, 17 May 2026 14:23:26 -0700 Subject: [PATCH] Bump to c++20 Remove KRMIN, KRMAX, and KRCLAMP helpers. --- CMakeLists.txt | 2 +- src/aabb.cpp | 3 ++- src/krhelpers.h | 3 --- src/vector2.cpp | 4 ++-- src/vector2i.cpp | 4 ++-- src/vector3.cpp | 4 ++-- src/vector3i.cpp | 4 ++-- src/vector4.cpp | 4 ++-- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 327fc49..f24f5ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.16) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/src/aabb.cpp b/src/aabb.cpp index 7bb4101..45216c8 100644 --- a/src/aabb.cpp +++ b/src/aabb.cpp @@ -32,6 +32,7 @@ #include "../include/hydra.h" #include "assert.h" #include "krhelpers.h" +#include namespace hydra { @@ -386,7 +387,7 @@ void AABB::encapsulate(const Vector3& v) Vector3 AABB::nearestPoint(const Vector3& v) const { - return Vector3::Create(KRCLAMP(v.x, min.x, max.x), KRCLAMP(v.y, min.y, max.y), KRCLAMP(v.z, min.z, max.z)); + return Vector3::Create(std::clamp(v.x, min.x, max.x), std::clamp(v.y, min.y, max.y), std::clamp(v.z, min.z, max.z)); } } // namespace hydra diff --git a/src/krhelpers.h b/src/krhelpers.h index 6c6e46d..4d390ca 100644 --- a/src/krhelpers.h +++ b/src/krhelpers.h @@ -33,9 +33,6 @@ #include "../include/hydra.h" -#define KRMIN(x,y) ((x) < (y) ? (x) : (y)) -#define KRMAX(x,y) ((x) > (y) ? (x) : (y)) -#define KRCLAMP(x, min, max) (KRMAX(KRMIN(x, max), min)) #define KRALIGN(x) ((x + 3) & ~0x03) float const PI = 3.141592653589793f; diff --git a/src/vector2.cpp b/src/vector2.cpp index 3b1f599..80d3e0d 100644 --- a/src/vector2.cpp +++ b/src/vector2.cpp @@ -291,12 +291,12 @@ float Vector2::Dot(const Vector2& v1, const Vector2& v2) Vector2 Vector2::Min(const Vector2& v1, const Vector2& v2) { - return Vector2::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y)); + return Vector2::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y)); } Vector2 Vector2::Max(const Vector2& v1, const Vector2& v2) { - return Vector2::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y)); + return Vector2::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y)); } } // namepsace hydra diff --git a/src/vector2i.cpp b/src/vector2i.cpp index e6ec99f..0d3ba8d 100644 --- a/src/vector2i.cpp +++ b/src/vector2i.cpp @@ -285,12 +285,12 @@ int Vector2i::Dot(const Vector2i& v1, const Vector2i& v2) Vector2i Vector2i::Min(const Vector2i& v1, const Vector2i& v2) { - return Vector2i::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y)); + return Vector2i::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y)); } Vector2i Vector2i::Max(const Vector2i& v1, const Vector2i& v2) { - return Vector2i::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y)); + return Vector2i::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y)); } } // namepsace hydra diff --git a/src/vector3.cpp b/src/vector3.cpp index 156af71..26bb67c 100644 --- a/src/vector3.cpp +++ b/src/vector3.cpp @@ -458,12 +458,12 @@ float Vector3::Dot(const Vector3& v1, const Vector3& v2) Vector3 Vector3::Min(const Vector3& v1, const Vector3& v2) { - return Vector3::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y), KRMIN(v1.z, v2.z)); + return Vector3::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y), std::min(v1.z, v2.z)); } Vector3 Vector3::Max(const Vector3& v1, const Vector3& v2) { - return Vector3::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y), KRMAX(v1.z, v2.z)); + return Vector3::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y), std::max(v1.z, v2.z)); } bool Vector3::operator >(const Vector3& b) const diff --git a/src/vector3i.cpp b/src/vector3i.cpp index 421f08e..1563340 100644 --- a/src/vector3i.cpp +++ b/src/vector3i.cpp @@ -373,12 +373,12 @@ int Vector3i::Dot(const Vector3i& v1, const Vector3i& v2) Vector3i Vector3i::Min(const Vector3i& v1, const Vector3i& v2) { - return Vector3i::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y), KRMIN(v1.z, v2.z)); + return Vector3i::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y), std::min(v1.z, v2.z)); } Vector3i Vector3i::Max(const Vector3i& v1, const Vector3i& v2) { - return Vector3i::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y), KRMAX(v1.z, v2.z)); + return Vector3i::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y), std::max(v1.z, v2.z)); } bool Vector3i::operator >(const Vector3i& b) const diff --git a/src/vector4.cpp b/src/vector4.cpp index 203abd4..e209df7 100644 --- a/src/vector4.cpp +++ b/src/vector4.cpp @@ -351,12 +351,12 @@ float Vector4::Dot(const Vector4& v1, const Vector4& v2) Vector4 Vector4::Min(const Vector4& v1, const Vector4& v2) { - return Vector4::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y), KRMIN(v1.z, v2.z), KRMIN(v1.w, v2.w)); + return Vector4::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y), std::min(v1.z, v2.z), std::min(v1.w, v2.w)); } Vector4 Vector4::Max(const Vector4& v1, const Vector4& v2) { - return Vector4::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y), KRMAX(v1.z, v2.z), KRMAX(v1.w, v2.w)); + return Vector4::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y), std::max(v1.z, v2.z), std::max(v1.w, v2.w)); } bool Vector4::operator >(const Vector4& b) const