Function transform

Synopsis

#include <Source/Falcor/Utils/Math/AABB.h>

BoundingBox transform(const glm::mat4 &mat) const

Description

Calculates the bounding box transformed by a matrix

Parameters:

[ in ] mat - Transform matrix

Return
Bounding box after transformation

Source

Lines 51-76 in Source/Falcor/Utils/Math/AABB.h.

BoundingBox transform(const glm::mat4& mat) const
{
    float3 min = center - extent;
    float3 max = center + extent;
    float3 xa = float3(mat[0] * min.x);
    float3 xb = float3(mat[0] * max.x);
    float3 xMin = glm::min(xa, xb);
    float3 xMax = glm::max(xa, xb);
    float3 ya = float3(mat[1] * min.y);
    float3 yb = float3(mat[1] * max.y);
    float3 yMin = glm::min(ya, yb);
    float3 yMax = glm::max(ya, yb);
    float3 za = float3(mat[2] * min.z);
    float3 zb = float3(mat[2] * max.z);
    float3 zMin = glm::min(za, zb);
    float3 zMax = glm::max(za, zb);
    float3 newMin = xMin + yMin + zMin + float3(mat[3]);
    float3 newMax = xMax + yMax + zMax + float3(mat[3]);
    return BoundingBox::fromMinMax(newMin, newMax);
}





Add Discussion as Guest

Log in to DocsForge