22 [[nodiscard]]
inline AABB CalculateAABB(
const glm::mat3& transform,
const glm::vec2 halfSize) {
23 const glm::vec2 corners[4]{
24 {transform * glm::vec3{-halfSize.x, -halfSize.y, 1.0f}},
25 {transform * glm::vec3{halfSize.x, -halfSize.y, 1.0f}},
26 {transform * glm::vec3{halfSize.x, halfSize.y, 1.0f}},
27 {transform * glm::vec3{-halfSize.x, halfSize.y, 1.0f}},
29 AABB bounds { corners[0], corners[0] };
31 for (int32_t i = 1; i < 4; ++i) {
32 bounds.
m_Min.x = std::min(bounds.
m_Min.x, corners[i].x);
33 bounds.
m_Min.y = std::min(bounds.
m_Min.y, corners[i].y);
34 bounds.
m_Max.x = std::max(bounds.
m_Max.x, corners[i].x);
35 bounds.
m_Max.y = std::max(bounds.
m_Max.y, corners[i].y);