From 277f88c00cbd432682fedefde511488d5b847c97 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sat, 7 Mar 2026 20:38:51 +0100 Subject: [PATCH] sphere box test --- interfaces/Crafter.Math-Intersection.cppm | 6 +++--- interfaces/main.cpp | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/interfaces/Crafter.Math-Intersection.cppm b/interfaces/Crafter.Math-Intersection.cppm index 9462d11..370cb9f 100755 --- a/interfaces/Crafter.Math-Intersection.cppm +++ b/interfaces/Crafter.Math-Intersection.cppm @@ -202,9 +202,9 @@ namespace Crafter { // Translate the sphere center into the OBB's local space Vector localCenter = Vector( - Vector::Dot(sphereCenter - Vector(boxMatrix.m[3][0], boxMatrix.m[3][1], boxMatrix.m[3][2]), xAxis), - Vector::Dot(sphereCenter - Vector(boxMatrix.m[3][0], boxMatrix.m[3][1], boxMatrix.m[3][2]), yAxis), - Vector::Dot(sphereCenter - Vector(boxMatrix.m[3][0], boxMatrix.m[3][1], boxMatrix.m[3][2]), zAxis) + Vector::Dot(sphereCenter - Vector(boxMatrix.m[0][3], boxMatrix.m[1][3], boxMatrix.m[2][3]), xAxis), + Vector::Dot(sphereCenter - Vector(boxMatrix.m[0][3], boxMatrix.m[1][3], boxMatrix.m[2][3]), yAxis), + Vector::Dot(sphereCenter - Vector(boxMatrix.m[0][3], boxMatrix.m[1][3], boxMatrix.m[2][3]), zAxis) ); // Clamp the local center to the OBB's extents diff --git a/interfaces/main.cpp b/interfaces/main.cpp index 57997c6..ebd3ac9 100644 --- a/interfaces/main.cpp +++ b/interfaces/main.cpp @@ -5,5 +5,9 @@ import std; using namespace Crafter; int main() { - + Vector sphereCenter(-10,0,0); + float sphereRadius = 10; + Vector boxSize(0,0,0); + MatrixRowMajor boxMatrix = MatrixRowMajor ::Translation(10,0,0); + std::cout << IntersectionTestSphereOrientedBox(sphereCenter, sphereRadius, boxSize, boxMatrix) << std::endl; } \ No newline at end of file