SIMD for Collision
The author rewrote the Separating Axis Test’s edge‑edge stage to operate on a structure‑of‑arrays layout, letting a single SIMD lane compare one edge from hull A against four edges from hull B. On the convex‑pile benchmark—a stack of 5 120 hulls each with 32 vertices (89 edges)—this change reduced a full 500‑step simulation from 40.7 s (scalar) to 17.3 s with SSE2 and 15.8 s with an AVX2‑lite variant on a single AMD 7950X core. Scaling to eight threads further dropped times to 5.3 s (scalar), 2.4 s (SSE2) and 2.3 s (AVX2‑lite), confirming that the speedup is not limited to single‑core execution. The gains stem from the 7 921 edge‑edge cross‑product calls per hull pair, which dominate the SAT cost for “boulder”‑type hulls, while simple box‑box tests see negligible benefit.
This development arrives amid a long‑standing split in physics engines between SAT, which works without collision margins, and the GJK + EPA combo that tolerates small separations but can produce visual gaps and numerical brittleness. Most engines rely on narrow SIMD—vectorizing xyz components—but have not widely exploited “wide” SIMD to batch independent collision pairs. By targeting the quadratic edge‑edge phase, Box3D demonstrates a concrete path to keep SAT viable for high‑detail convex hulls, such as those generated during runtime destruction. The approach also mirrors Box2D’s limited AVX2 support, yet Box3D’s decision to cap hulls at 128 edges preserves cache friendliness and keeps the SoA transformation manageable.
Looking ahead, the author plans a true AVX2 implementation that processes eight
About the Source
This analysis is based on reporting by Hacker News. Here is a short excerpt for context:
CommentsRead the original at Hacker News