[HN Gopher] A Couple 3D AABB Tricks
       ___________________________________________________________________
        
       A Couple 3D AABB Tricks
        
       Author : ibobev
       Score  : 23 points
       Date   : 2026-01-07 08:45 UTC (5 days ago)
        
 (HTM) web link (gpfault.net)
 (TXT) w3m dump (gpfault.net)
        
       | throwaway2027 wrote:
       | 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]; };
        
         | pkaler wrote:
         | 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.
        
           | shihab wrote:
           | For SIMD at least, the {mins[3], maxs[3]} representation
           | aligns more naturally with actual instructions on x86. To
           | compute a new bounding box:
           | 
           | new_box.mins = _mm_min_ps(a.mins[3], b.mins[3]);
        
             | delta_p_delta_x wrote:
             | Indeed. This is classic array-of-structs versus struct-of-
             | arrays.
        
       | stonemetal12 wrote:
       | For non 3d graphics people AABB -> Axis Aligned Bounding Box.
        
       | pphysch wrote:
       | The minmax representation makes less sense if you are frequently
       | updating the 3D objects position, no? You really want both
       | representations available.
       | 
       | It make sense to generate the bounds JIT when you are actually
       | building an octree to test collisions. Assuming you have a
       | nontrivial amount of objects.
        
         | ack_complete wrote:
         | Typically intersection checks outnumber updates, so it's better
         | to optimize the former. Also, that only works if the object's
         | pivot is at the center of the bounding box or you're
         | accumulating movements without an explicit position.
         | 
         | That being said, a lot of tricks work better with center/extent
         | instead of min/max, such as computing the AABB around an OBB or
         | doing separating axis tests with abs() tricks. A bounding box
         | and bounding sphere can also be stored together as
         | center/extent/radius with only one additional value needed.
         | Min/max works better for accumulation, though.
        
       ___________________________________________________________________
       (page generated 2026-01-12 23:01 UTC)