logoalt Hacker News

throwaway2027yesterday at 6:30 PM2 repliesview on HN

struct aabb { float x_minmax[2]; float y_minmax[2]; float z_minmax[2]; };

Why not just do struct aabb { float mins[3]; float maxs[3]; };


Replies

nice_byteyesterday at 11:45 PM

(author here) Both would work - doesn't fundamentally change the underlying idea. This particular representation is lifted from raytracing in one weekend and emphasizes the fact that we're really thinking of aabb as an intersection of three "slabs" of space. for me, it makes the ray intersection bit somewhat easier to explain.

pkaleryesterday at 6:58 PM

SIMD and data locality. You probably want to check across three vectors simultaneously and load the coordinates next to each other.

I'm guessing here. I haven't written video games in 20 years but struct packing/alignment was super important on the Sony PSP back then.

show 1 reply