RenderItem::~RenderItem() = default;
-ClippingBox RenderItem::CalculateViewportSpaceAABB(const Vector3& size, const int viewportWidth, const int viewportHeight) const
+ClippingBox RenderItem::CalculateViewportSpaceAABB(const Matrix& modelViewMatrix, const Vector3& size, const int viewportWidth, const int viewportHeight)
{
// Calculate extent vector of the AABB:
const float halfActorX = size.x * 0.5f;
// We place the coords into the array in clockwise order, so we know opposite corners are always i + 2 from corner i.
// We skip the 4th corner here as we can calculate that from the other 3, bypassing matrix multiplication.
// Note: The below transform methods use a fast (2D) matrix multiply (only 4 multiplications are done).
- Vector2 corners[4]{Transform2D(mModelViewMatrix, -halfActorX, -halfActorY),
- Transform2D(mModelViewMatrix, halfActorX, -halfActorY),
- Transform2D(mModelViewMatrix, halfActorX, halfActorY)};
+ Vector2 corners[4]{Transform2D(modelViewMatrix, -halfActorX, -halfActorY),
+ Transform2D(modelViewMatrix, halfActorX, -halfActorY),
+ Transform2D(modelViewMatrix, halfActorX, halfActorY)};
// As we are dealing with a rectangle, we can do a fast calculation to get the 4th corner from knowing the other 3 (even if rotated).
corners[3] = Vector2(corners[0] + (corners[2] - corners[1]));