From af77df23f54f03668ca61e697ac7fc0c0e8f18a2 Mon Sep 17 00:00:00 2001 From: doylet Date: Wed, 3 Sep 2025 21:14:57 +1000 Subject: [PATCH] Switch math from init to from nomenclamenture --- Source/Base/dn_base.h | 12 +-- Source/Extra/dn_math.cpp | 172 ++++++++++++++++++++++---------------- Source/Extra/dn_math.h | 47 +++++++---- Source/Extra/dn_tests.cpp | 30 +++---- 4 files changed, 149 insertions(+), 112 deletions(-) diff --git a/Source/Base/dn_base.h b/Source/Base/dn_base.h index e5ad087..5c00c98 100644 --- a/Source/Base/dn_base.h +++ b/Source/Base/dn_base.h @@ -95,12 +95,12 @@ #define DN_Gigabytes(val) ((DN_U64)1024 * DN_Megabytes(val)) // NOTE: Time ////////////////////////////////////////////////////////////////////////////////////// -#define DN_SecondsToMs(val) ((val) * 1000) -#define DN_MinutesToSec(val) ((val) * 60ULL) -#define DN_HoursToSec(val) (DN_MinutesToSec(val) * 60ULL) -#define DN_DaysToSec(val) (DN_HoursToSec(val) * 24ULL) -#define DN_WeeksToSec(val) (DN_DaysToSec(val) * 7ULL) -#define DN_YearsToSec(val) (DN_WeeksToSec(val) * 52ULL) +#define DN_SecondsToMs(val) ((val) * 1000) +#define DN_MinutesToSec(val) ((val) * 60ULL) +#define DN_HoursToSec(val) (DN_MinutesToSec(val) * 60ULL) +#define DN_DaysToSec(val) (DN_HoursToSec(val) * 24ULL) +#define DN_WeeksToSec(val) (DN_DaysToSec(val) * 7ULL) +#define DN_YearsToSec(val) (DN_WeeksToSec(val) * 52ULL) // NOTE: Debug Break /////////////////////////////////////////////////////////////////////////////// #if !defined(DN_DebugBreak) diff --git a/Source/Extra/dn_math.cpp b/Source/Extra/dn_math.cpp index 2f8ef26..b48525c 100644 --- a/Source/Extra/dn_math.cpp +++ b/Source/Extra/dn_math.cpp @@ -41,55 +41,55 @@ DN_API bool operator>(DN_V2I32 lhs, DN_V2I32 rhs) DN_API DN_V2I32 operator-(DN_V2I32 lhs, DN_V2I32 rhs) { - DN_V2I32 result = DN_V2I32_Init2N(lhs.x - rhs.x, lhs.y - rhs.y); + DN_V2I32 result = DN_V2I32_From2N(lhs.x - rhs.x, lhs.y - rhs.y); return result; } DN_API DN_V2I32 operator-(DN_V2I32 lhs) { - DN_V2I32 result = DN_V2I32_Init2N(-lhs.x, -lhs.y); + DN_V2I32 result = DN_V2I32_From2N(-lhs.x, -lhs.y); return result; } DN_API DN_V2I32 operator+(DN_V2I32 lhs, DN_V2I32 rhs) { - DN_V2I32 result = DN_V2I32_Init2N(lhs.x + rhs.x, lhs.y + rhs.y); + DN_V2I32 result = DN_V2I32_From2N(lhs.x + rhs.x, lhs.y + rhs.y); return result; } DN_API DN_V2I32 operator*(DN_V2I32 lhs, DN_V2I32 rhs) { - DN_V2I32 result = DN_V2I32_Init2N(lhs.x * rhs.x, lhs.y * rhs.y); + DN_V2I32 result = DN_V2I32_From2N(lhs.x * rhs.x, lhs.y * rhs.y); return result; } DN_API DN_V2I32 operator*(DN_V2I32 lhs, DN_F32 rhs) { - DN_V2I32 result = DN_V2I32_Init2N(lhs.x * rhs, lhs.y * rhs); + DN_V2I32 result = DN_V2I32_From2N(lhs.x * rhs, lhs.y * rhs); return result; } DN_API DN_V2I32 operator*(DN_V2I32 lhs, int32_t rhs) { - DN_V2I32 result = DN_V2I32_Init2N(lhs.x * rhs, lhs.y * rhs); + DN_V2I32 result = DN_V2I32_From2N(lhs.x * rhs, lhs.y * rhs); return result; } DN_API DN_V2I32 operator/(DN_V2I32 lhs, DN_V2I32 rhs) { - DN_V2I32 result = DN_V2I32_Init2N(lhs.x / rhs.x, lhs.y / rhs.y); + DN_V2I32 result = DN_V2I32_From2N(lhs.x / rhs.x, lhs.y / rhs.y); return result; } DN_API DN_V2I32 operator/(DN_V2I32 lhs, DN_F32 rhs) { - DN_V2I32 result = DN_V2I32_Init2N(lhs.x / rhs, lhs.y / rhs); + DN_V2I32 result = DN_V2I32_From2N(lhs.x / rhs, lhs.y / rhs); return result; } DN_API DN_V2I32 operator/(DN_V2I32 lhs, int32_t rhs) { - DN_V2I32 result = DN_V2I32_Init2N(lhs.x / rhs, lhs.y / rhs); + DN_V2I32 result = DN_V2I32_From2N(lhs.x / rhs, lhs.y / rhs); return result; } @@ -143,19 +143,19 @@ DN_API DN_V2I32 &operator+=(DN_V2I32 &lhs, DN_V2I32 rhs) DN_API DN_V2I32 DN_V2I32_Min(DN_V2I32 a, DN_V2I32 b) { - DN_V2I32 result = DN_V2I32_Init2N(DN_Min(a.x, b.x), DN_Min(a.y, b.y)); + DN_V2I32 result = DN_V2I32_From2N(DN_Min(a.x, b.x), DN_Min(a.y, b.y)); return result; } DN_API DN_V2I32 DN_V2I32_Max(DN_V2I32 a, DN_V2I32 b) { - DN_V2I32 result = DN_V2I32_Init2N(DN_Max(a.x, b.x), DN_Max(a.y, b.y)); + DN_V2I32 result = DN_V2I32_From2N(DN_Max(a.x, b.x), DN_Max(a.y, b.y)); return result; } DN_API DN_V2I32 DN_V2I32_Abs(DN_V2I32 a) { - DN_V2I32 result = DN_V2I32_Init2N(DN_Abs(a.x), DN_Abs(a.y)); + DN_V2I32 result = DN_V2I32_From2N(DN_Abs(a.x), DN_Abs(a.y)); return result; } @@ -198,49 +198,49 @@ DN_API bool operator>(DN_V2U16 lhs, DN_V2U16 rhs) DN_API DN_V2U16 operator-(DN_V2U16 lhs, DN_V2U16 rhs) { - DN_V2U16 result = DN_V2U16_Init2N(lhs.x - rhs.x, lhs.y - rhs.y); + DN_V2U16 result = DN_V2U16_From2N(lhs.x - rhs.x, lhs.y - rhs.y); return result; } DN_API DN_V2U16 operator+(DN_V2U16 lhs, DN_V2U16 rhs) { - DN_V2U16 result = DN_V2U16_Init2N(lhs.x + rhs.x, lhs.y + rhs.y); + DN_V2U16 result = DN_V2U16_From2N(lhs.x + rhs.x, lhs.y + rhs.y); return result; } DN_API DN_V2U16 operator*(DN_V2U16 lhs, DN_V2U16 rhs) { - DN_V2U16 result = DN_V2U16_Init2N(lhs.x * rhs.x, lhs.y * rhs.y); + DN_V2U16 result = DN_V2U16_From2N(lhs.x * rhs.x, lhs.y * rhs.y); return result; } DN_API DN_V2U16 operator*(DN_V2U16 lhs, DN_F32 rhs) { - DN_V2U16 result = DN_V2U16_Init2N(lhs.x * rhs, lhs.y * rhs); + DN_V2U16 result = DN_V2U16_From2N(lhs.x * rhs, lhs.y * rhs); return result; } DN_API DN_V2U16 operator*(DN_V2U16 lhs, int32_t rhs) { - DN_V2U16 result = DN_V2U16_Init2N(lhs.x * rhs, lhs.y * rhs); + DN_V2U16 result = DN_V2U16_From2N(lhs.x * rhs, lhs.y * rhs); return result; } DN_API DN_V2U16 operator/(DN_V2U16 lhs, DN_V2U16 rhs) { - DN_V2U16 result = DN_V2U16_Init2N(lhs.x / rhs.x, lhs.y / rhs.y); + DN_V2U16 result = DN_V2U16_From2N(lhs.x / rhs.x, lhs.y / rhs.y); return result; } DN_API DN_V2U16 operator/(DN_V2U16 lhs, DN_F32 rhs) { - DN_V2U16 result = DN_V2U16_Init2N(lhs.x / rhs, lhs.y / rhs); + DN_V2U16 result = DN_V2U16_From2N(lhs.x / rhs, lhs.y / rhs); return result; } DN_API DN_V2U16 operator/(DN_V2U16 lhs, int32_t rhs) { - DN_V2U16 result = DN_V2U16_Init2N(lhs.x / rhs, lhs.y / rhs); + DN_V2U16 result = DN_V2U16_From2N(lhs.x / rhs, lhs.y / rhs); return result; } @@ -332,106 +332,106 @@ DN_API bool operator>(DN_V2F32 lhs, DN_V2F32 rhs) // NOTE: DN_V2F32 operator- ////////////////////////////////////////////////////////////////////////// DN_API DN_V2F32 operator-(DN_V2F32 lhs) { - DN_V2F32 result = DN_V2F32_Init2N(-lhs.x, -lhs.y); + DN_V2F32 result = DN_V2F32_From2N(-lhs.x, -lhs.y); return result; } DN_API DN_V2F32 operator-(DN_V2F32 lhs, DN_V2F32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x - rhs.x, lhs.y - rhs.y); + DN_V2F32 result = DN_V2F32_From2N(lhs.x - rhs.x, lhs.y - rhs.y); return result; } DN_API DN_V2F32 operator-(DN_V2F32 lhs, DN_V2I32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x - rhs.x, lhs.y - rhs.y); + DN_V2F32 result = DN_V2F32_From2N(lhs.x - rhs.x, lhs.y - rhs.y); return result; } DN_API DN_V2F32 operator-(DN_V2F32 lhs, DN_F32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x - rhs, lhs.y - rhs); + DN_V2F32 result = DN_V2F32_From2N(lhs.x - rhs, lhs.y - rhs); return result; } DN_API DN_V2F32 operator-(DN_V2F32 lhs, int32_t rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x - rhs, lhs.y - rhs); + DN_V2F32 result = DN_V2F32_From2N(lhs.x - rhs, lhs.y - rhs); return result; } // NOTE: DN_V2F32 operator+ ////////////////////////////////////////////////////////////////////////// DN_API DN_V2F32 operator+(DN_V2F32 lhs, DN_V2F32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x + rhs.x, lhs.y + rhs.y); + DN_V2F32 result = DN_V2F32_From2N(lhs.x + rhs.x, lhs.y + rhs.y); return result; } DN_API DN_V2F32 operator+(DN_V2F32 lhs, DN_V2I32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x + rhs.x, lhs.y + rhs.y); + DN_V2F32 result = DN_V2F32_From2N(lhs.x + rhs.x, lhs.y + rhs.y); return result; } DN_API DN_V2F32 operator+(DN_V2F32 lhs, DN_F32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x + rhs, lhs.y + rhs); + DN_V2F32 result = DN_V2F32_From2N(lhs.x + rhs, lhs.y + rhs); return result; } DN_API DN_V2F32 operator+(DN_V2F32 lhs, int32_t rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x + rhs, lhs.y + rhs); + DN_V2F32 result = DN_V2F32_From2N(lhs.x + rhs, lhs.y + rhs); return result; } // NOTE: DN_V2F32 operator* ////////////////////////////////////////////////////////////////////////// DN_API DN_V2F32 operator*(DN_V2F32 lhs, DN_V2F32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x * rhs.x, lhs.y * rhs.y); + DN_V2F32 result = DN_V2F32_From2N(lhs.x * rhs.x, lhs.y * rhs.y); return result; } DN_API DN_V2F32 operator*(DN_V2F32 lhs, DN_V2I32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x * rhs.x, lhs.y * rhs.y); + DN_V2F32 result = DN_V2F32_From2N(lhs.x * rhs.x, lhs.y * rhs.y); return result; } DN_API DN_V2F32 operator*(DN_V2F32 lhs, DN_F32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x * rhs, lhs.y * rhs); + DN_V2F32 result = DN_V2F32_From2N(lhs.x * rhs, lhs.y * rhs); return result; } DN_API DN_V2F32 operator*(DN_V2F32 lhs, int32_t rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x * rhs, lhs.y * rhs); + DN_V2F32 result = DN_V2F32_From2N(lhs.x * rhs, lhs.y * rhs); return result; } // NOTE: DN_V2F32 operator/ ////////////////////////////////////////////////////////////////////////// DN_API DN_V2F32 operator/(DN_V2F32 lhs, DN_V2F32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x / rhs.x, lhs.y / rhs.y); + DN_V2F32 result = DN_V2F32_From2N(lhs.x / rhs.x, lhs.y / rhs.y); return result; } DN_API DN_V2F32 operator/(DN_V2F32 lhs, DN_V2I32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x / rhs.x, lhs.y / rhs.y); + DN_V2F32 result = DN_V2F32_From2N(lhs.x / rhs.x, lhs.y / rhs.y); return result; } DN_API DN_V2F32 operator/(DN_V2F32 lhs, DN_F32 rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x / rhs, lhs.y / rhs); + DN_V2F32 result = DN_V2F32_From2N(lhs.x / rhs, lhs.y / rhs); return result; } DN_API DN_V2F32 operator/(DN_V2F32 lhs, int32_t rhs) { - DN_V2F32 result = DN_V2F32_Init2N(lhs.x / rhs, lhs.y / rhs); + DN_V2F32 result = DN_V2F32_From2N(lhs.x / rhs, lhs.y / rhs); return result; } @@ -537,19 +537,19 @@ DN_API DN_V2F32 &operator+=(DN_V2F32 &lhs, int32_t rhs) DN_API DN_V2F32 DN_V2F32_Min(DN_V2F32 a, DN_V2F32 b) { - DN_V2F32 result = DN_V2F32_Init2N(DN_Min(a.x, b.x), DN_Min(a.y, b.y)); + DN_V2F32 result = DN_V2F32_From2N(DN_Min(a.x, b.x), DN_Min(a.y, b.y)); return result; } DN_API DN_V2F32 DN_V2F32_Max(DN_V2F32 a, DN_V2F32 b) { - DN_V2F32 result = DN_V2F32_Init2N(DN_Max(a.x, b.x), DN_Max(a.y, b.y)); + DN_V2F32 result = DN_V2F32_From2N(DN_Max(a.x, b.x), DN_Max(a.y, b.y)); return result; } DN_API DN_V2F32 DN_V2F32_Abs(DN_V2F32 a) { - DN_V2F32 result = DN_V2F32_Init2N(DN_Abs(a.x), DN_Abs(a.y)); + DN_V2F32 result = DN_V2F32_From2N(DN_Abs(a.x), DN_Abs(a.y)); return result; } @@ -600,7 +600,7 @@ DN_API DN_F32 DN_V2F32_Dot(DN_V2F32 a, DN_V2F32 b) return result; } -DN_API DN_F32 DN_V2F32_LengthSq_V2x2(DN_V2F32 lhs, DN_V2F32 rhs) +DN_API DN_F32 DN_V2F32_LengthSq2V2(DN_V2F32 lhs, DN_V2F32 rhs) { // NOTE: Pythagoras's theorem (a^2 + b^2 = c^2) without the square root DN_F32 a = rhs.x - lhs.x; @@ -610,9 +610,16 @@ DN_API DN_F32 DN_V2F32_LengthSq_V2x2(DN_V2F32 lhs, DN_V2F32 rhs) return result; } -DN_API DN_F32 DN_V2F32_Length_V2x2(DN_V2F32 lhs, DN_V2F32 rhs) +DN_API bool DN_V2F32_LengthSqIsWithin2V2(DN_V2F32 lhs, DN_V2F32 rhs, DN_F32 within_amount_sq) { - DN_F32 result_squared = DN_V2F32_LengthSq_V2x2(lhs, rhs); + DN_F32 dist = DN_V2F32_LengthSq2V2(lhs, rhs); + bool result = dist <= within_amount_sq; + return result; +} + +DN_API DN_F32 DN_V2F32_Length2V2(DN_V2F32 lhs, DN_V2F32 rhs) +{ + DN_F32 result_squared = DN_V2F32_LengthSq2V2(lhs, rhs); DN_F32 result = DN_SqrtF32(result_squared); return result; } @@ -657,7 +664,7 @@ DN_API DN_V2F32 DN_V2F32_Perpendicular(DN_V2F32 a) // x' = -y // y' = +x - DN_V2F32 result = DN_V2F32_Init2N(-a.y, a.x); + DN_V2F32 result = DN_V2F32_From2N(-a.y, a.x); return result; } @@ -666,7 +673,7 @@ DN_API DN_V2F32 DN_V2F32_Reflect(DN_V2F32 in, DN_V2F32 surface) DN_V2F32 normal = DN_V2F32_Perpendicular(surface); DN_V2F32 normal_norm = DN_V2F32_Normalise(normal); DN_F32 signed_dist = DN_V2F32_Dot(in, normal_norm); - DN_V2F32 result = DN_V2F32_Init2N(in.x, in.y + (-signed_dist * 2.f)); + DN_V2F32 result = DN_V2F32_From2N(in.x, in.y + (-signed_dist * 2.f)); return result; } @@ -717,55 +724,55 @@ DN_API bool operator>(DN_V3F32 lhs, DN_V3F32 rhs) DN_API DN_V3F32 operator-(DN_V3F32 lhs, DN_V3F32 rhs) { - DN_V3F32 result = DN_V3F32_Init3F32(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); + DN_V3F32 result = DN_V3F32_From3N(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); return result; } DN_API DN_V3F32 operator-(DN_V3F32 lhs) { - DN_V3F32 result = DN_V3F32_Init3F32(-lhs.x, -lhs.y, -lhs.z); + DN_V3F32 result = DN_V3F32_From3N(-lhs.x, -lhs.y, -lhs.z); return result; } DN_API DN_V3F32 operator+(DN_V3F32 lhs, DN_V3F32 rhs) { - DN_V3F32 result = DN_V3F32_Init3F32(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); + DN_V3F32 result = DN_V3F32_From3N(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); return result; } DN_API DN_V3F32 operator*(DN_V3F32 lhs, DN_V3F32 rhs) { - DN_V3F32 result = DN_V3F32_Init3F32(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); + DN_V3F32 result = DN_V3F32_From3N(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); return result; } DN_API DN_V3F32 operator*(DN_V3F32 lhs, DN_F32 rhs) { - DN_V3F32 result = DN_V3F32_Init3F32(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs); + DN_V3F32 result = DN_V3F32_From3N(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs); return result; } DN_API DN_V3F32 operator*(DN_V3F32 lhs, int32_t rhs) { - DN_V3F32 result = DN_V3F32_Init3F32(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs); + DN_V3F32 result = DN_V3F32_From3N(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs); return result; } DN_API DN_V3F32 operator/(DN_V3F32 lhs, DN_V3F32 rhs) { - DN_V3F32 result = DN_V3F32_Init3F32(lhs.x / rhs.x, lhs.y / rhs.y, lhs.z / rhs.z); + DN_V3F32 result = DN_V3F32_From3N(lhs.x / rhs.x, lhs.y / rhs.y, lhs.z / rhs.z); return result; } DN_API DN_V3F32 operator/(DN_V3F32 lhs, DN_F32 rhs) { - DN_V3F32 result = DN_V3F32_Init3F32(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs); + DN_V3F32 result = DN_V3F32_From3N(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs); return result; } DN_API DN_V3F32 operator/(DN_V3F32 lhs, int32_t rhs) { - DN_V3F32 result = DN_V3F32_Init3F32(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs); + DN_V3F32 result = DN_V3F32_From3N(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs); return result; } @@ -840,6 +847,25 @@ DN_API DN_V3F32 DN_V3_Normalise(DN_V3F32 a) #if !defined(DN_NO_V4) // NOTE: DN_V4 ///////////////////////////////////////////////////////////////////////////////////// +DN_API DN_V4F32 DN_V4F32_FromRGBU32(DN_U32 u32) +{ + DN_U8 r = (DN_U8)(((u32 << 8) & DN_V4_R_MASK_U32) >> 24); + DN_U8 g = (DN_U8)(((u32 << 8) & DN_V4_G_MASK_U32) >> 16); + DN_U8 b = (DN_U8)(((u32 << 8) & DN_V4_B_MASK_U32) >> 8); + DN_V4F32 result = DN_V4F32_FromRGBU8(r, g, b); + return result; +} + +DN_API DN_V4F32 DN_V4F32_FromRGBAU32(DN_U32 u32) +{ + DN_U8 r = (DN_U8)((u32 & DN_V4_R_MASK_U32) >> 24); + DN_U8 g = (DN_U8)((u32 & DN_V4_G_MASK_U32) >> 16); + DN_U8 b = (DN_U8)((u32 & DN_V4_B_MASK_U32) >> 8); + DN_U8 a = (DN_U8)((u32 & DN_V4_A_MASK_U32) >> 0); + DN_V4F32 result = DN_V4F32_FromRGBAU8(r, g, b, a); + return result; +} + DN_API bool operator==(DN_V4F32 lhs, DN_V4F32 rhs) { bool result = (lhs.x == rhs.x) && (lhs.y == rhs.y) && (lhs.z == rhs.z) && (lhs.w == rhs.w); @@ -878,43 +904,43 @@ DN_API bool operator>(DN_V4F32 lhs, DN_V4F32 rhs) DN_API DN_V4F32 operator-(DN_V4F32 lhs, DN_V4F32 rhs) { - DN_V4F32 result = DN_V4F32_Init4N(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); + DN_V4F32 result = DN_V4F32_From4N(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); return result; } DN_API DN_V4F32 operator-(DN_V4F32 lhs) { - DN_V4F32 result = DN_V4F32_Init4N(-lhs.x, -lhs.y, -lhs.z, -lhs.w); + DN_V4F32 result = DN_V4F32_From4N(-lhs.x, -lhs.y, -lhs.z, -lhs.w); return result; } DN_API DN_V4F32 operator+(DN_V4F32 lhs, DN_V4F32 rhs) { - DN_V4F32 result = DN_V4F32_Init4N(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z, lhs.w + rhs.w); + DN_V4F32 result = DN_V4F32_From4N(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z, lhs.w + rhs.w); return result; } DN_API DN_V4F32 operator*(DN_V4F32 lhs, DN_V4F32 rhs) { - DN_V4F32 result = DN_V4F32_Init4N(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); + DN_V4F32 result = DN_V4F32_From4N(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); return result; } DN_API DN_V4F32 operator*(DN_V4F32 lhs, DN_F32 rhs) { - DN_V4F32 result = DN_V4F32_Init4N(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs, lhs.w * rhs); + DN_V4F32 result = DN_V4F32_From4N(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs, lhs.w * rhs); return result; } DN_API DN_V4F32 operator*(DN_V4F32 lhs, int32_t rhs) { - DN_V4F32 result = DN_V4F32_Init4N(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs, lhs.w * rhs); + DN_V4F32 result = DN_V4F32_From4N(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs, lhs.w * rhs); return result; } DN_API DN_V4F32 operator/(DN_V4F32 lhs, DN_F32 rhs) { - DN_V4F32 result = DN_V4F32_Init4N(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs, lhs.w / rhs); + DN_V4F32 result = DN_V4F32_From4N(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs, lhs.w / rhs); return result; } @@ -1395,7 +1421,7 @@ DN_API bool DN_Rect_Intersects(DN_Rect a, DN_Rect b) DN_API DN_Rect DN_Rect_Intersection(DN_Rect a, DN_Rect b) { - DN_Rect result = DN_Rect_Init2V2(a.pos, DN_V2F32_Init1N(0)); + DN_Rect result = DN_Rect_From2V2(a.pos, DN_V2F32_From1N(0)); if (DN_Rect_Intersects(a, b)) { DN_V2F32 a_min = a.pos; DN_V2F32 a_max = a.pos + a.size; @@ -1408,7 +1434,7 @@ DN_API DN_Rect DN_Rect_Intersection(DN_Rect a, DN_Rect b) min.y = DN_Max(a_min.y, b_min.y); max.x = DN_Min(a_max.x, b_max.x); max.y = DN_Min(a_max.y, b_max.y); - result = DN_Rect_Init2V2(min, max - min); + result = DN_Rect_From2V2(min, max - min); } return result; } @@ -1425,7 +1451,7 @@ DN_API DN_Rect DN_Rect_Union(DN_Rect a, DN_Rect b) min.y = DN_Min(a_min.y, b_min.y); max.x = DN_Max(a_max.x, b_max.x); max.y = DN_Max(a_max.y, b_max.y); - DN_Rect result = DN_Rect_Init2V2(min, max - min); + DN_Rect result = DN_Rect_From2V2(min, max - min); return result; } @@ -1450,7 +1476,7 @@ DN_API DN_Rect DN_Rect_CutLeftClip(DN_Rect *rect, DN_F32 amount, DN_RectCutClip DN_F32 result_max_x = min_x + amount; if (clip) result_max_x = DN_Min(result_max_x, max_x); - DN_Rect result = DN_Rect_Init4N(min_x, rect->pos.y, result_max_x - min_x, rect->size.h); + DN_Rect result = DN_Rect_From4N(min_x, rect->pos.y, result_max_x - min_x, rect->size.h); rect->pos.x = result_max_x; rect->size.w = max_x - result_max_x; return result; @@ -1463,7 +1489,7 @@ DN_API DN_Rect DN_Rect_CutRightClip(DN_Rect *rect, DN_F32 amount, DN_RectCutClip DN_F32 result_min_x = max_x - amount; if (clip) result_min_x = DN_Max(result_min_x, 0); - DN_Rect result = DN_Rect_Init4N(result_min_x, rect->pos.y, max_x - result_min_x, rect->size.h); + DN_Rect result = DN_Rect_From4N(result_min_x, rect->pos.y, max_x - result_min_x, rect->size.h); rect->size.w = result_min_x - min_x; return result; } @@ -1475,7 +1501,7 @@ DN_API DN_Rect DN_Rect_CutTopClip(DN_Rect *rect, DN_F32 amount, DN_RectCutClip c DN_F32 result_max_y = min_y + amount; if (clip) result_max_y = DN_Min(result_max_y, max_y); - DN_Rect result = DN_Rect_Init4N(rect->pos.x, min_y, rect->size.w, result_max_y - min_y); + DN_Rect result = DN_Rect_From4N(rect->pos.x, min_y, rect->size.w, result_max_y - min_y); rect->pos.y = result_max_y; rect->size.h = max_y - result_max_y; return result; @@ -1488,7 +1514,7 @@ DN_API DN_Rect DN_Rect_CutBottomClip(DN_Rect *rect, DN_F32 amount, DN_RectCutCli DN_F32 result_min_y = max_y - amount; if (clip) result_min_y = DN_Max(result_min_y, 0); - DN_Rect result = DN_Rect_Init4N(rect->pos.x, result_min_y, rect->size.w, max_y - result_min_y); + DN_Rect result = DN_Rect_From4N(rect->pos.x, result_min_y, rect->size.w, max_y - result_min_y); rect->size.h = result_min_y - min_y; return result; } @@ -1509,32 +1535,32 @@ DN_API DN_Rect DN_RectCut_Cut(DN_RectCut rect_cut, DN_V2F32 size, DN_RectCutClip DN_API DN_V2F32 DN_Rect_InterpolatedPoint(DN_Rect rect, DN_V2F32 t01) { - DN_V2F32 result = DN_V2F32_Init2N(rect.pos.w + (rect.size.w * t01.x), + DN_V2F32 result = DN_V2F32_From2N(rect.pos.w + (rect.size.w * t01.x), rect.pos.h + (rect.size.h * t01.y)); return result; } DN_API DN_V2F32 DN_Rect_TopLeft(DN_Rect rect) { - DN_V2F32 result = DN_Rect_InterpolatedPoint(rect, DN_V2F32_Init2N(0, 0)); + DN_V2F32 result = DN_Rect_InterpolatedPoint(rect, DN_V2F32_From2N(0, 0)); return result; } DN_API DN_V2F32 DN_Rect_TopRight(DN_Rect rect) { - DN_V2F32 result = DN_Rect_InterpolatedPoint(rect, DN_V2F32_Init2N(1, 0)); + DN_V2F32 result = DN_Rect_InterpolatedPoint(rect, DN_V2F32_From2N(1, 0)); return result; } DN_API DN_V2F32 DN_Rect_BottomLeft(DN_Rect rect) { - DN_V2F32 result = DN_Rect_InterpolatedPoint(rect, DN_V2F32_Init2N(0, 1)); + DN_V2F32 result = DN_Rect_InterpolatedPoint(rect, DN_V2F32_From2N(0, 1)); return result; } DN_API DN_V2F32 DN_Rect_BottomRight(DN_Rect rect) { - DN_V2F32 result = DN_Rect_InterpolatedPoint(rect, DN_V2F32_Init2N(1, 1)); + DN_V2F32 result = DN_Rect_InterpolatedPoint(rect, DN_V2F32_From2N(1, 1)); return result; } #endif // !defined(DN_NO_RECT) diff --git a/Source/Extra/dn_math.h b/Source/Extra/dn_math.h index 1934f1e..35a452d 100644 --- a/Source/Extra/dn_math.h +++ b/Source/Extra/dn_math.h @@ -117,8 +117,8 @@ struct DN_RaycastLineIntersectV2Result // NOTE: DN_V2 ///////////////////////////////////////////////////////////////////////////////////// #define DN_V2I32_Zero DN_LITERAL(DN_V2I32){{(int32_t)(0), (int32_t)(0)}} #define DN_V2I32_One DN_LITERAL(DN_V2I32){{(int32_t)(1), (int32_t)(1)}} -#define DN_V2I32_Init1N(x) DN_LITERAL(DN_V2I32){{(int32_t)(x), (int32_t)(x)}} -#define DN_V2I32_Init2N(x, y) DN_LITERAL(DN_V2I32){{(int32_t)(x), (int32_t)(y)}} +#define DN_V2I32_From1N(x) DN_LITERAL(DN_V2I32){{(int32_t)(x), (int32_t)(x)}} +#define DN_V2I32_From2N(x, y) DN_LITERAL(DN_V2I32){{(int32_t)(x), (int32_t)(y)}} #define DN_V2I32_InitV2(xy) DN_LITERAL(DN_V2I32){{(int32_t)(xy).x, (int32_t)(xy).y}} DN_API bool operator!= (DN_V2I32 lhs, DN_V2I32 rhs); @@ -151,8 +151,8 @@ DN_API DN_V2I32 DN_V2I32_Abs (DN_V2I32 a); #define DN_V2U16_Zero DN_LITERAL(DN_V2U16){{(uint16_t)(0), (uint16_t)(0)}} #define DN_V2U16_One DN_LITERAL(DN_V2U16){{(uint16_t)(1), (uint16_t)(1)}} -#define DN_V2U16_Init1N(x) DN_LITERAL(DN_V2U16){{(uint16_t)(x), (uint16_t)(x)}} -#define DN_V2U16_Init2N(x, y) DN_LITERAL(DN_V2U16){{(uint16_t)(x), (uint16_t)(y)}} +#define DN_V2U16_From1N(x) DN_LITERAL(DN_V2U16){{(uint16_t)(x), (uint16_t)(x)}} +#define DN_V2U16_From2N(x, y) DN_LITERAL(DN_V2U16){{(uint16_t)(x), (uint16_t)(y)}} DN_API bool operator!= (DN_V2U16 lhs, DN_V2U16 rhs); DN_API bool operator== (DN_V2U16 lhs, DN_V2U16 rhs); @@ -179,9 +179,9 @@ DN_API DN_V2U16 & operator+= (DN_V2U16& lhs, #define DN_V2F32_Zero DN_LITERAL(DN_V2F32){{(DN_F32)(0), (DN_F32)(0)}} #define DN_V2F32_One DN_LITERAL(DN_V2F32){{(DN_F32)(1), (DN_F32)(1)}} -#define DN_V2F32_Init1N(x) DN_LITERAL(DN_V2F32){{(DN_F32)(x), (DN_F32)(x)}} -#define DN_V2F32_Init2N(x, y) DN_LITERAL(DN_V2F32){{(DN_F32)(x), (DN_F32)(y)}} -#define DN_V2F32_InitV2I32(xy) DN_LITERAL(DN_V2F32){{(DN_F32)(xy).x, (DN_F32)(xy).y}} +#define DN_V2F32_From1N(x) DN_LITERAL(DN_V2F32){{(DN_F32)(x), (DN_F32)(x)}} +#define DN_V2F32_From2N(x, y) DN_LITERAL(DN_V2F32){{(DN_F32)(x), (DN_F32)(y)}} +#define DN_V2F32_FromV2I32(xy) DN_LITERAL(DN_V2F32){{(DN_F32)(xy).x, (DN_F32)(xy).y}} DN_API bool operator!= (DN_V2F32 lhs, DN_V2F32 rhs); DN_API bool operator== (DN_V2F32 lhs, DN_V2F32 rhs); @@ -235,8 +235,9 @@ DN_API DN_V2F32 DN_V2F32_Min (DN_V2F32 a, DN DN_API DN_V2F32 DN_V2F32_Max (DN_V2F32 a, DN_V2F32 b); DN_API DN_V2F32 DN_V2F32_Abs (DN_V2F32 a); DN_API DN_F32 DN_V2F32_Dot (DN_V2F32 a, DN_V2F32 b); -DN_API DN_F32 DN_V2F32_LengthSq_V2x2 (DN_V2F32 lhs, DN_V2F32 rhs); -DN_API DN_F32 DN_V2F32_Length_V2x2 (DN_V2F32 lhs, DN_V2F32 rhs); +DN_API DN_F32 DN_V2F32_LengthSq2V2 (DN_V2F32 lhs, DN_V2F32 rhs); +DN_API bool DN_V2F32_LengthSqIsWithin2V2 (DN_V2F32 lhs, DN_V2F32 rhs, DN_F32 within_amount_sq); +DN_API DN_F32 DN_V2F32_Length2V2 (DN_V2F32 lhs, DN_V2F32 rhs); DN_API DN_F32 DN_V2F32_LengthSq (DN_V2F32 lhs); DN_API DN_F32 DN_V2F32_Length (DN_V2F32 lhs); DN_API DN_V2F32 DN_V2F32_Normalise (DN_V2F32 a); @@ -246,9 +247,9 @@ DN_API DN_F32 DN_V2F32_Area (DN_V2F32 a); #endif // !defined(DN_NO_V2) #if !defined(DN_NO_V3) // NOTE: DN_V3 ///////////////////////////////////////////////////////////////////////////////////// -#define DN_V3F32_Init1N(x) DN_LITERAL(DN_V3F32){{(DN_F32)(x), (DN_F32)(x), (DN_F32)(x)}} -#define DN_V3F32_Init3F32(x, y, z) DN_LITERAL(DN_V3F32){{(DN_F32)(x), (DN_F32)(y), (DN_F32)(z)}} -#define DN_V3F32_InitV2F32_1F32(xy, z) DN_LITERAL(DN_V3F32){{(DN_F32)(xy.x), (DN_F32)(xy.y), (DN_F32)(z)}} +#define DN_V3F32_From1N(x) DN_LITERAL(DN_V3F32){{(DN_F32)(x), (DN_F32)(x), (DN_F32)(x)}} +#define DN_V3F32_From3N(x, y, z) DN_LITERAL(DN_V3F32){{(DN_F32)(x), (DN_F32)(y), (DN_F32)(z)}} +#define DN_V3F32_FromV2F32And1N(xy, z) DN_LITERAL(DN_V3F32){{(DN_F32)(xy.x), (DN_F32)(xy.y), (DN_F32)(z)}} DN_API bool operator== (DN_V3F32 lhs, DN_V3F32 rhs); DN_API bool operator!= (DN_V3F32 lhs, DN_V3F32 rhs); @@ -278,10 +279,20 @@ DN_API DN_F32 DN_V3F32_Length (DN_V3F32 a); DN_API DN_V3F32 DN_V3F32_Normalise (DN_V3F32 a); #endif // !defined(DN_NO_V3) #if !defined(DN_NO_V4) +DN_U32 const DN_V4_R_MASK_U32 = 0xFF000000; +DN_U32 const DN_V4_G_MASK_U32 = 0x00FF0000; +DN_U32 const DN_V4_B_MASK_U32 = 0x0000FF00; +DN_U32 const DN_V4_A_MASK_U32 = 0x000000FF; + // NOTE: DN_V4 ///////////////////////////////////////////////////////////////////////////////////// -#define DN_V4F32_Init1N(x) DN_LITERAL(DN_V4F32){{(DN_F32)(x), (DN_F32)(x), (DN_F32)(x), (DN_F32)(x)}} -#define DN_V4F32_Init4N(x, y, z, w) DN_LITERAL(DN_V4F32){{(DN_F32)(x), (DN_F32)(y), (DN_F32)(z), (DN_F32)(w)}} -#define DN_V4F32_InitV3_1N(xyz, w) DN_LITERAL(DN_V4F32){{xyz.x, xyz.y, xyz.z, w}} +#define DN_V4F32_From1N(x) DN_LITERAL(DN_V4F32){{(DN_F32)(x), (DN_F32)(x), (DN_F32)(x), (DN_F32)(x)}} +#define DN_V4F32_From4N(x, y, z, w) DN_LITERAL(DN_V4F32){{(DN_F32)(x), (DN_F32)(y), (DN_F32)(z), (DN_F32)(w)}} +#define DN_V4F32_FromV3And1N(xyz, w) DN_LITERAL(DN_V4F32){{xyz.x, xyz.y, xyz.z, w}} +#define DN_V4F32_FromRGBAU8(r, g, b, a) DN_LITERAL(DN_V4F32){r / 255.f, g / 255.f, b / 255.f, a / 255.f} +#define DN_V4F32_FromRGBU8(r, g, b) DN_LITERAL(DN_V4F32){r / 255.f, g / 255.f, b / 255.f, 1.f} +DN_API DN_V4F32 DN_V4F32_FromRGBU32(DN_U32 u32); +DN_API DN_V4F32 DN_V4F32_FromRGBAU32(DN_U32 u32); +#define DN_V4F32_FromV4Alpha(v4, alpha) DN_V4F32_FromV3And1N(v4.xyz, alpha) DN_API bool operator== (DN_V4F32 lhs, DN_V4F32 rhs); DN_API bool operator!= (DN_V4F32 lhs, DN_V4F32 rhs); DN_API bool operator<= (DN_V4F32 lhs, DN_V4F32 rhs); @@ -299,10 +310,10 @@ DN_API DN_V4F32 & operator*= (DN_V4F32 &lhs, DN_API DN_V4F32 & operator*= (DN_V4F32 &lhs, int32_t rhs); DN_API DN_V4F32 & operator-= (DN_V4F32 &lhs, DN_V4F32 rhs); DN_API DN_V4F32 & operator+= (DN_V4F32 &lhs, DN_V4F32 rhs); +DN_API DN_F32 DN_V4F32_Dot (DN_V4F32 a, DN_V4F32 b); #endif // !defined(DN_NO_V4) #if !defined(DN_NO_M4) // NOTE: DN_M4 ///////////////////////////////////////////////////////////////////////////////////// -DN_API DN_F32 DN_V4F32Dot (DN_V4F32 a, DN_V4F32 b); DN_API DN_M4 DN_M4_Identity (); DN_API DN_M4 DN_M4_ScaleF (DN_F32 x, DN_F32 y, DN_F32 z); DN_API DN_M4 DN_M4_Scale (DN_V3F32 xyz); @@ -336,8 +347,8 @@ DN_API DN_V2F32 DN_M2x3_Mul2F32 (DN_M2x3 m1, DN DN_API DN_V2F32 DN_M2x3_MulV2 (DN_M2x3 m1, DN_V2F32 v2); #if !defined(DN_NO_RECT) // NOTE: DN_Rect /////////////////////////////////////////////////////////////////////////////////// -#define DN_Rect_Init2V2(pos, size) DN_LITERAL(DN_Rect){(pos), (size)} -#define DN_Rect_Init4N(x, y, w, h) DN_LITERAL(DN_Rect){DN_LITERAL(DN_V2F32){{x, y}}, DN_LITERAL(DN_V2F32){{w, h}}} +#define DN_Rect_From2V2(pos, size) DN_LITERAL(DN_Rect){(pos), (size)} +#define DN_Rect_From4N(x, y, w, h) DN_LITERAL(DN_Rect){DN_LITERAL(DN_V2F32){{x, y}}, DN_LITERAL(DN_V2F32){{w, h}}} DN_API bool operator== (const DN_Rect& lhs, const DN_Rect& rhs); DN_API DN_V2F32 DN_Rect_Center (DN_Rect rect); diff --git a/Source/Extra/dn_tests.cpp b/Source/Extra/dn_tests.cpp index 5c8b79b..8876858 100644 --- a/Source/Extra/dn_tests.cpp +++ b/Source/Extra/dn_tests.cpp @@ -1969,8 +1969,8 @@ static DN_UTCore DN_Tests_Rect() DN_UT_LogF(&result, "DN_Rect\n"); { for (DN_UT_Test(&result, "No intersection")) { - DN_Rect a = DN_Rect_Init2V2(DN_V2F32_Init1N(0), DN_V2F32_Init2N(100, 100)); - DN_Rect b = DN_Rect_Init2V2(DN_V2F32_Init2N(200, 0), DN_V2F32_Init2N(200, 200)); + DN_Rect a = DN_Rect_From2V2(DN_V2F32_From1N(0), DN_V2F32_From2N(100, 100)); + DN_Rect b = DN_Rect_From2V2(DN_V2F32_From2N(200, 0), DN_V2F32_From2N(200, 200)); DN_Rect ab = DN_Rect_Intersection(a, b); DN_V2F32 ab_max = ab.pos + ab.size; @@ -1984,8 +1984,8 @@ static DN_UTCore DN_Tests_Rect() } for (DN_UT_Test(&result, "A's min intersects B")) { - DN_Rect a = DN_Rect_Init2V2(DN_V2F32_Init2N(50, 50), DN_V2F32_Init2N(100, 100)); - DN_Rect b = DN_Rect_Init2V2(DN_V2F32_Init2N(0, 0), DN_V2F32_Init2N(100, 100)); + DN_Rect a = DN_Rect_From2V2(DN_V2F32_From2N(50, 50), DN_V2F32_From2N(100, 100)); + DN_Rect b = DN_Rect_From2V2(DN_V2F32_From2N(0, 0), DN_V2F32_From2N(100, 100)); DN_Rect ab = DN_Rect_Intersection(a, b); DN_V2F32 ab_max = ab.pos + ab.size; @@ -1999,8 +1999,8 @@ static DN_UTCore DN_Tests_Rect() } for (DN_UT_Test(&result, "B's min intersects A")) { - DN_Rect a = DN_Rect_Init2V2(DN_V2F32_Init2N(0, 0), DN_V2F32_Init2N(100, 100)); - DN_Rect b = DN_Rect_Init2V2(DN_V2F32_Init2N(50, 50), DN_V2F32_Init2N(100, 100)); + DN_Rect a = DN_Rect_From2V2(DN_V2F32_From2N(0, 0), DN_V2F32_From2N(100, 100)); + DN_Rect b = DN_Rect_From2V2(DN_V2F32_From2N(50, 50), DN_V2F32_From2N(100, 100)); DN_Rect ab = DN_Rect_Intersection(a, b); DN_V2F32 ab_max = ab.pos + ab.size; @@ -2014,8 +2014,8 @@ static DN_UTCore DN_Tests_Rect() } for (DN_UT_Test(&result, "A's max intersects B")) { - DN_Rect a = DN_Rect_Init2V2(DN_V2F32_Init2N(-50, -50), DN_V2F32_Init2N(100, 100)); - DN_Rect b = DN_Rect_Init2V2(DN_V2F32_Init2N(0, 0), DN_V2F32_Init2N(100, 100)); + DN_Rect a = DN_Rect_From2V2(DN_V2F32_From2N(-50, -50), DN_V2F32_From2N(100, 100)); + DN_Rect b = DN_Rect_From2V2(DN_V2F32_From2N(0, 0), DN_V2F32_From2N(100, 100)); DN_Rect ab = DN_Rect_Intersection(a, b); DN_V2F32 ab_max = ab.pos + ab.size; @@ -2029,8 +2029,8 @@ static DN_UTCore DN_Tests_Rect() } for (DN_UT_Test(&result, "B's max intersects A")) { - DN_Rect a = DN_Rect_Init2V2(DN_V2F32_Init2N(0, 0), DN_V2F32_Init2N(100, 100)); - DN_Rect b = DN_Rect_Init2V2(DN_V2F32_Init2N(-50, -50), DN_V2F32_Init2N(100, 100)); + DN_Rect a = DN_Rect_From2V2(DN_V2F32_From2N(0, 0), DN_V2F32_From2N(100, 100)); + DN_Rect b = DN_Rect_From2V2(DN_V2F32_From2N(-50, -50), DN_V2F32_From2N(100, 100)); DN_Rect ab = DN_Rect_Intersection(a, b); DN_V2F32 ab_max = ab.pos + ab.size; @@ -2044,8 +2044,8 @@ static DN_UTCore DN_Tests_Rect() } for (DN_UT_Test(&result, "B contains A")) { - DN_Rect a = DN_Rect_Init2V2(DN_V2F32_Init2N(25, 25), DN_V2F32_Init2N(25, 25)); - DN_Rect b = DN_Rect_Init2V2(DN_V2F32_Init2N(0, 0), DN_V2F32_Init2N(100, 100)); + DN_Rect a = DN_Rect_From2V2(DN_V2F32_From2N(25, 25), DN_V2F32_From2N(25, 25)); + DN_Rect b = DN_Rect_From2V2(DN_V2F32_From2N(0, 0), DN_V2F32_From2N(100, 100)); DN_Rect ab = DN_Rect_Intersection(a, b); DN_V2F32 ab_max = ab.pos + ab.size; @@ -2059,8 +2059,8 @@ static DN_UTCore DN_Tests_Rect() } for (DN_UT_Test(&result, "A contains B")) { - DN_Rect a = DN_Rect_Init2V2(DN_V2F32_Init2N(0, 0), DN_V2F32_Init2N(100, 100)); - DN_Rect b = DN_Rect_Init2V2(DN_V2F32_Init2N(25, 25), DN_V2F32_Init2N(25, 25)); + DN_Rect a = DN_Rect_From2V2(DN_V2F32_From2N(0, 0), DN_V2F32_From2N(100, 100)); + DN_Rect b = DN_Rect_From2V2(DN_V2F32_From2N(25, 25), DN_V2F32_From2N(25, 25)); DN_Rect ab = DN_Rect_Intersection(a, b); DN_V2F32 ab_max = ab.pos + ab.size; @@ -2074,7 +2074,7 @@ static DN_UTCore DN_Tests_Rect() } for (DN_UT_Test(&result, "A equals B")) { - DN_Rect a = DN_Rect_Init2V2(DN_V2F32_Init2N(0, 0), DN_V2F32_Init2N(100, 100)); + DN_Rect a = DN_Rect_From2V2(DN_V2F32_From2N(0, 0), DN_V2F32_From2N(100, 100)); DN_Rect b = a; DN_Rect ab = DN_Rect_Intersection(a, b);