Compare commits

..

4 commits

Author SHA1 Message Date
428c5d054a Merge branch 'dev', version 2.0.1
All checks were successful
Run UnitTest / build-and-run-UnitTest (push) Successful in 7s
2024-05-02 12:36:06 +09:00
89a509f315 Update Changelog.md 2024-05-02 12:35:54 +09:00
ff091c233e Version 2.0.1 2024-05-02 12:33:22 +09:00
7b9f25ca5c Add check in Sphere/Box collision for same center 2024-05-02 12:32:18 +09:00
3 changed files with 12 additions and 1 deletions

View file

@ -6,7 +6,7 @@ set(SC_3D_CollisionDetectionHelpers_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/src/sc_
add_library(SC_3D_CollisionDetectionHelpers ${SC_3D_CollisionDetectionHelpers_SOURCES}) 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 "") if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
message("Defaulting to \"Debug\" build type.") message("Defaulting to \"Debug\" build type.")

View file

@ -1,5 +1,10 @@
# Changelog # 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 ## Version 2.0.0
Add collision detection with Spheres. Add collision detection with Spheres.

View file

@ -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_pos{sphere->x, sphere->y, sphere->z};
SC_SACD_Vec3 sphere_box_normal = SC_SACD_Vec3 sphere_box_normal =
SC_SACD_Vec3{box->x, box->y, box->z} - sphere_pos; 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 =
sphere_box_normal / sphere_box_normal /
std::sqrt(SC_SACD_Dot_Product(sphere_box_normal, sphere_box_normal)); std::sqrt(SC_SACD_Dot_Product(sphere_box_normal, sphere_box_normal));