Compare commits

..

3 commits

Author SHA1 Message Date
4528053334 Merge branch 'dev', version 2.2.1
All checks were successful
Run UnitTest / build-and-run-UnitTest (push) Successful in 5s
2024-05-06 15:03:17 +09:00
6acbef0fa3 Version 2.2.1 (fix UnitTest) 2024-05-06 15:02:55 +09:00
b40a434d2a Fix UnitTest for checking combined AABB 2024-05-06 15:02:21 +09:00
3 changed files with 69 additions and 7 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})
set_target_properties(SC_3D_CollisionDetectionHelpers PROPERTIES VERSION 2.2.0 SOVERSION 2)
set_target_properties(SC_3D_CollisionDetectionHelpers PROPERTIES VERSION 2.2.1 SOVERSION 2)
target_compile_features(SC_3D_CollisionDetectionHelpers PUBLIC cxx_std_20)
if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")

View file

@ -1,5 +1,9 @@
# Changelog
## Version 2.2.1
Fix UnitTest for checking AABB.
## Version 2.2.0
Refactoring of internally used function.

View file

@ -688,12 +688,70 @@ int main() {
SC_SACD_AABB_Box b{-3.0F, -3.0F, -3.0F, 2.0F, 2.0F, 2.0F};
auto combined = SC_SACD_AABB_Combine(a, b);
CHECK_FLOAT(combined.x, (7.0F - 5.0F) / 2.0F);
CHECK_FLOAT(combined.y, (7.0F - 5.0F) / 2.0F);
CHECK_FLOAT(combined.z, (7.0F - 5.0F) / 2.0F);
CHECK_FLOAT(combined.width, 10.0F);
CHECK_FLOAT(combined.height, 10.0F);
CHECK_FLOAT(combined.depth, 10.0F);
auto *box_min = a.x - a.width / 2.0F < b.x - b.width / 2.0F ? &a : &b;
auto *box_max = a.x + a.width / 2.0F > b.x + b.width / 2.0F ? &a : &b;
CHECK_FLOAT(combined.width, box_max->x + box_max->width / 2.0F -
(box_min->x - box_min->width / 2.0F));
CHECK_FLOAT(combined.x, box_min->x - box_min->width / 2.0F +
(box_max->x + box_max->width / 2.0F -
(box_min->x - box_min->width / 2.0F)) /
2.0F);
box_min = a.y - a.height / 2.0F < b.y - b.height / 2.0F ? &a : &b;
box_max = a.y + a.height / 2.0F > b.y + b.height / 2.0F ? &a : &b;
CHECK_FLOAT(combined.height, box_max->y + box_max->height / 2.0F -
(box_min->y - box_min->height / 2.0F));
CHECK_FLOAT(combined.y, box_min->y - box_min->height / 2.0F +
(box_max->y + box_max->height / 2.0F -
(box_min->y - box_min->height / 2.0F)) /
2.0F);
box_min = a.z - a.depth / 2.0F < b.z - b.depth / 2.0F ? &a : &b;
box_max = a.z + a.depth / 2.0F > b.z + b.depth / 2.0F ? &a : &b;
CHECK_FLOAT(combined.depth, box_max->z + box_max->depth / 2.0F -
(box_min->z - box_min->depth / 2.0F));
CHECK_FLOAT(combined.z, box_min->z - box_min->depth / 2.0F +
(box_max->z + box_max->depth / 2.0F -
(box_min->z - box_min->depth / 2.0F)) /
2.0F);
a.x = -12.0F;
a.z = -1.0F;
a.width = 1.0F;
a.height = 5.0F;
a.depth = 0.5F;
b.x = 1.0F;
b.y = 7.0F;
b.width = 3.0F;
b.height = 4.0F;
b.depth = 0.7F;
combined = SC_SACD_AABB_Combine(a, b);
box_min = a.x - a.width / 2.0F < b.x - b.width / 2.0F ? &a : &b;
box_max = a.x + a.width / 2.0F > b.x + b.width / 2.0F ? &a : &b;
CHECK_FLOAT(combined.width, box_max->x + box_max->width / 2.0F -
(box_min->x - box_min->width / 2.0F));
CHECK_FLOAT(combined.x, box_min->x - box_min->width / 2.0F +
(box_max->x + box_max->width / 2.0F -
(box_min->x - box_min->width / 2.0F)) /
2.0F);
box_min = a.y - a.height / 2.0F < b.y - b.height / 2.0F ? &a : &b;
box_max = a.y + a.height / 2.0F > b.y + b.height / 2.0F ? &a : &b;
CHECK_FLOAT(combined.height, box_max->y + box_max->height / 2.0F -
(box_min->y - box_min->height / 2.0F));
CHECK_FLOAT(combined.y, box_min->y - box_min->height / 2.0F +
(box_max->y + box_max->height / 2.0F -
(box_min->y - box_min->height / 2.0F)) /
2.0F);
box_min = a.z - a.depth / 2.0F < b.z - b.depth / 2.0F ? &a : &b;
box_max = a.z + a.depth / 2.0F > b.z + b.depth / 2.0F ? &a : &b;
CHECK_FLOAT(combined.depth, box_max->z + box_max->depth / 2.0F -
(box_min->z - box_min->depth / 2.0F));
CHECK_FLOAT(combined.z, box_min->z - box_min->depth / 2.0F +
(box_max->z + box_max->depth / 2.0F -
(box_min->z - box_min->depth / 2.0F)) /
2.0F);
}
std::cout << "Checks checked: " << checks_checked << '\n'