The Gilbert–Johnson–Keerthi (GJK) distance algorithm is a method of determining the minimum distance between two convex sets. The algorithm's stability, speed which operates in near-constant time, and small storage footprint make it popular for realtime collision detection.
Unlike many other distance algorithms, it has no requirments on geometry data to be stored in any specific format, but instead relies solely on a support function to iteratively generate closer simplices to the correct answer using the Minkowski sum (CSO) of two convex shapes.
| #include <immintrin.h> // For AVX2 intrinsics | |
| #include <stdio.h> | |
| #include <float.h> // For FLT_MAX and FLT_MIN | |
| #include <string.h> // For memset | |
| #include <stdlib.h> // For exit | |
| #include <math.h> // For fmaxf, fminf | |
| #include <pthread.h> // For pthreads (example, assuming your pool uses similar mechanisms) | |
| #include <assert.h> | |
| #define EPSILON 1e-6f // Define a small epsilon to handle floating point inaccuracies |
This is essentially just the original Minimal D3D11 codebase with 8x MSAA added. However, since MSAA only smooths triangle edges and does not affect textured surface interiors, texturing is removed to isolate and make the effect of MSAA clearer.
In short there are two parts to it: 1) Create and render to an MSAA texture rather than your typical rendertarget/framebuffer (note: the depth buffer must match), and 2) [Resolve](https://gist.github.com/d7samurai/d74299f8bcadcb9cb0686
