gb
gb copied to clipboard
gb_math: gb_rectX_union
Hey, as I'm continue to develop a game based on gb_math, I find that rect unions are pretty much quite useful. Would be nice to have them in standard gb_math. So far I'm using something like this:
gbRect2 gb_rect2_union(gbRect2 a, gbRect2 b)
{
float tlx = gb_min(a.pos.x, b.pos.x);
float tly = gb_min(a.pos.y, b.pos.y);
float brx = gb_max(a.pos.x + a.dim.x, b.pos.x + b.dim.x);
float bry = gb_max(a.pos.y + a.dim.y, b.pos.y + b.dim.y);
return gb_rect2(gb_vec2(tlx, tly), gb_vec2(brx - tlx, bry - tly));
}