Compare commits

..

No commits in common. "12aee049c01d333b8bbb4d6a376dc0ba402bf137" and "763b2d3a6d365c4e1d28592f587f3e747fc6ba40" have entirely different histories.

3 changed files with 11 additions and 11 deletions

View file

@ -7,7 +7,6 @@ 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.2 SOVERSION 2)
target_compile_features(SC_3D_CollisionDetectionHelpers PUBLIC cxx_std_20)
if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
message("Defaulting to \"Debug\" build type.")

View file

@ -4,8 +4,6 @@
Refactoring of internally used function(s).
This library now requires a compiler that supports C++20.
## Version 2.0.2
Fix SC_SACD_Translate_Mat4(...). It was missing a "1" in the first element of

View file

@ -3,7 +3,6 @@
// Standard library includes.
#include <array>
#include <cmath>
#include <span>
#include <stdfloat>
#include <vector>
@ -214,17 +213,18 @@ struct SC_SACD_MinMax {
};
std::vector<SC_SACD_MinMax> SC_SACD_Get_Box_MinMax(
const SC_SACD_Generic_Box *box, const std::span<SC_SACD_Vec3> normals) {
const SC_SACD_Generic_Box *box, const SC_SACD_Vec3 *normals,
std::size_t size) {
std::vector<SC_SACD_MinMax> minmaxes;
std::vector<SC_SACD_Vec3> corners = SC_SACD_Get_Box_Corners(box);
// Assuming normals are not normalized, and will not normalize anyway.
// MinMax count should be same as normals count.
for (const auto &normal : normals) {
for (std::size_t idx = 0; idx < size; ++idx) {
SC_SACD_MinMax minmax{INFINITY, -INFINITY};
for (const auto &corner : corners) {
float projected = SC_SACD_Dot_Product(corner, normal);
float projected = SC_SACD_Dot_Product(corner, normals[idx]);
if (projected > minmax.max) {
minmax.max = projected;
}
@ -284,8 +284,10 @@ int SC_SACD_Generic_Box_Collision(const SC_SACD_Generic_Box *a,
}
// Get all minmaxes.
std::vector<SC_SACD_MinMax> minmaxes_a = SC_SACD_Get_Box_MinMax(a, normals);
std::vector<SC_SACD_MinMax> minmaxes_b = SC_SACD_Get_Box_MinMax(b, normals);
std::vector<SC_SACD_MinMax> minmaxes_a =
SC_SACD_Get_Box_MinMax(a, normals.data(), normals.size());
std::vector<SC_SACD_MinMax> minmaxes_b =
SC_SACD_Get_Box_MinMax(b, normals.data(), normals.size());
// Check minmaxes.
for (unsigned int i = 0; i < normals.size(); ++i) {
@ -365,7 +367,7 @@ int SC_SACD_Sphere_Box_Collision(const SC_SACD_Sphere *sphere,
std::vector<SC_SACD_Vec3> normals{sphere_box_normal};
std::vector<SC_SACD_MinMax> box_minmaxes =
SC_SACD_Get_Box_MinMax(box, normals);
SC_SACD_Get_Box_MinMax(box, normals.data(), normals.size());
float projected_0 = SC_SACD_Dot_Product(
sphere_box_normal, sphere_pos + sphere_box_normal * sphere->radius);
@ -384,7 +386,8 @@ int SC_SACD_Sphere_Box_Collision(const SC_SACD_Sphere *sphere,
// Next check the planes for the 3 normals of the box.
auto box_normals = SC_SACD_Get_Box_Normals(box);
box_minmaxes = SC_SACD_Get_Box_MinMax(box, box_normals);
box_minmaxes =
SC_SACD_Get_Box_MinMax(box, box_normals.data(), box_normals.size());
for (unsigned int i = 0; i < box_normals.size(); ++i) {
projected_0 = SC_SACD_Dot_Product(
box_normals[i], sphere_pos + box_normals[i] * sphere->radius);