From 2dcb33f39fef0fafbefc833508dbe11f8530c397 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 1 May 2024 13:34:40 +0900 Subject: [PATCH] Add default constructor for SC_SACD_Generic_Box --- src/sc_sacd.cpp | 6 ++++++ src/sc_sacd.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/sc_sacd.cpp b/src/sc_sacd.cpp index 765444f..2713cdc 100644 --- a/src/sc_sacd.cpp +++ b/src/sc_sacd.cpp @@ -191,6 +191,12 @@ std::vector SC_SACD_Get_Box_MinMax( // Private Helpers END // ============================================================================= +SC_SACD_Generic_Box SC_SACD_Generic_Box_Default() { + return { + 0.0F, 0.0F, 0.0F, 2.0F, 2.0F, 2.0F, SC_SACD_Mat4_Identity(), + }; +} + int SC_SACD_AABB_Box_Collision(const SC_SACD_AABB_Box *a, const SC_SACD_AABB_Box *b) { float ax_min = a->x - a->width / 2.0F; diff --git a/src/sc_sacd.h b/src/sc_sacd.h index 7ba1c7e..3f9ed07 100644 --- a/src/sc_sacd.h +++ b/src/sc_sacd.h @@ -44,6 +44,7 @@ typedef struct SC_SACD_EXPORT SC_SACD_AABB_Box { float depth; } SC_SACD_AABB_Box; +/// Must not be zero initialized. Use SC_SACD_Generix_Box_Default() instead. typedef struct SC_SACD_EXPORT SC_SACD_Generic_Box { /// Coordinates are to center of box. float x; @@ -66,6 +67,9 @@ typedef struct SC_SACD_EXPORT SC_SACD_Sphere { float radius; } SC_SACD_Sphere; +/// Returns a box at origin with width/height/depth of 2 each. +SC_SACD_EXPORT SC_SACD_Generic_Box SC_SACD_Generic_Box_Default(void); + /// Returns non-zero if there is collision. SC_SACD_EXPORT int SC_SACD_AABB_Box_Collision(const SC_SACD_AABB_Box *a, const SC_SACD_AABB_Box *b);