From 7b9f25ca5c7617d215edecb87e880fa7800fdefb Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 2 May 2024 12:31:55 +0900 Subject: [PATCH 1/3] Add check in Sphere/Box collision for same center --- src/sc_sacd.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sc_sacd.cpp b/src/sc_sacd.cpp index 2713cdc..7f6a218 100644 --- a/src/sc_sacd.cpp +++ b/src/sc_sacd.cpp @@ -296,6 +296,12 @@ int SC_SACD_Sphere_Box_Collision(const SC_SACD_Sphere *sphere, SC_SACD_Vec3 sphere_pos{sphere->x, sphere->y, sphere->z}; SC_SACD_Vec3 sphere_box_normal = SC_SACD_Vec3{box->x, box->y, box->z} - sphere_pos; + if (sphere_box_normal.x < 0.0001F && sphere_box_normal.x > -0.0001F && + sphere_box_normal.y < 0.0001F && sphere_box_normal.y > -0.0001F && + sphere_box_normal.z < 0.0001F && sphere_box_normal.z > -0.0001F) { + // Sphere center is box center. + return 1; + } sphere_box_normal = sphere_box_normal / std::sqrt(SC_SACD_Dot_Product(sphere_box_normal, sphere_box_normal)); From ff091c233ea86619a0a45a44838cc3c65873a8b7 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 2 May 2024 12:33:22 +0900 Subject: [PATCH 2/3] Version 2.0.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 840d6fc..acda12f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(SC_3D_CollisionDetectionHelpers_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/src/sc_ add_library(SC_3D_CollisionDetectionHelpers ${SC_3D_CollisionDetectionHelpers_SOURCES}) -set_target_properties(SC_3D_CollisionDetectionHelpers PROPERTIES VERSION 2.0.0 SOVERSION 2) +set_target_properties(SC_3D_CollisionDetectionHelpers PROPERTIES VERSION 2.0.1 SOVERSION 2) if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "") message("Defaulting to \"Debug\" build type.") From 89a509f31545c53a2cf57e20579c6561d5a58e19 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 2 May 2024 12:35:54 +0900 Subject: [PATCH 3/3] Update Changelog.md --- Changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Changelog.md b/Changelog.md index 8309ce9..abf6666 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Changelog +## Version 2.0.1 + +Added check in SC_SACD_Sphere_Box_Collision(...) to see if sphere and box has +same center. + ## Version 2.0.0 Add collision detection with Spheres.