33 AABB(glm::vec2 pos, glm::vec2 size, glm::quat rot = glm::quat()) {
34 glm::vec2 half = size * 0.5f;
37 glm::vec3 corners[4] = {
38 glm::vec3(-half.x, -half.y, 0),
39 glm::vec3( half.x, -half.y, 0),
40 glm::vec3( half.x, half.y, 0),
41 glm::vec3(-half.x, half.y, 0)
45 glm::vec2 min(FLT_MAX), max(-FLT_MAX);
46 for (
int i = 0; i < 4; ++i) {
47 glm::vec3 rotated = rot * corners[i];
48 glm::vec2 p = glm::vec2(rotated.x, rotated.y) + pos;
50 min = glm::min(min, p);
51 max = glm::max(max, p);
54 center = (min + max) * 0.5f;