Skip to content

Instantly share code, notes, and snippets.

@cairnc
cairnc / portal.cpp
Created July 25, 2025 03:25
SIMD portal intersection
// A float which remains large when you modify its least significant bits
const Vec4f VEC4_LARGE_FLOAT = Vec4f::fromF32(8589934592);
const Vec4f VEC4_INDEX_MASK = Vec4f::fromI32(~1, ~1, 0, 0);
const Vec4f VEC4_INDEX_VALS = Vec4f::fromI32(0, 1, 0x50000000, 0x50000000);
const Vec4f VEC4_ZERO = Vec4f::fromF32(0.0f);
constexpr int BIG_FLOAT_INTEGER = 0x50000000;
template <size_t n, size_t i, size_t indexBits = 3>
@cairnc
cairnc / sat_blog.cpp
Last active July 19, 2025 13:21
sat_blog
void satCollideReference(const SatShape *a, Transform xfA, const SatShape *b, Transform xfB, SatResult *res)
{
ASSERT(b->numFaces != 2);
Transform bToA = xfA.inverse().mul(xfB);
Transform aToB = bToA.inverse();
res->vert = -1;
res->face = -1;
res->support = INFINITY;
// Test MD against planes of a