Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::BoundingBox2D Struct Reference

Axis-aligned 2D bounding box defined by center, size, and extents. More...

#include <spk_bounding_box_2d.hpp>

Collaboration diagram for spk::BoundingBox2D:
Collaboration graph

Public Member Functions

 BoundingBox2D ()=default
 Builds a default bounding box at the origin.
 BoundingBox2D (const spk::Vector2 &p_center, const spk::Vector2 &p_size)
 Builds a bounding box from center and size.
void setFromCenterSize (const spk::Vector2 &p_center, const spk::Vector2 &p_size)
 Updates the box from center and size.
void setFromMinMax (const spk::Vector2 &p_min, const spk::Vector2 &p_max)
 Updates the box from minimum and maximum corners.
BoundingBox2D applyMatrix (const spk::Matrix4x4 &p_transform) const
 Applies a transform matrix to the bounding box.
bool intersect (const BoundingBox2D &p_other) const
 Checks intersection with another bounding box.

Public Attributes

spk::Vector2 center {0.0f, 0.0f}
 Center point of the bounding box.
spk::Vector2 size {0.0f, 0.0f}
 Size of the bounding box (width, height).
spk::Vector2 min {0.0f, 0.0f}
 Minimum corner of the bounding box.
spk::Vector2 max {0.0f, 0.0f}
 Maximum corner of the bounding box.

Detailed Description

Axis-aligned 2D bounding box defined by center, size, and extents.

spk::BoundingBox2D box({0.0f, 0.0f}, {10.0f, 5.0f});
if (box.intersect(other)) { // ... }
Axis-aligned 2D bounding box defined by center, size, and extents.
Definition spk_bounding_box_2d.hpp:19

Constructor & Destructor Documentation

◆ BoundingBox2D()

spk::BoundingBox2D::BoundingBox2D ( const spk::Vector2 & p_center,
const spk::Vector2 & p_size )

Builds a bounding box from center and size.

Parameters
p_centerCenter point.
p_sizeSize (width, height).
Here is the call graph for this function:

Member Function Documentation

◆ applyMatrix()

BoundingBox2D spk::BoundingBox2D::applyMatrix ( const spk::Matrix4x4 & p_transform) const

Applies a transform matrix to the bounding box.

Parameters
p_transformTransform matrix.
Returns
Transformed bounding box.
Here is the call graph for this function:

◆ intersect()

bool spk::BoundingBox2D::intersect ( const BoundingBox2D & p_other) const

Checks intersection with another bounding box.

Parameters
p_otherOther bounding box.
Returns
true when boxes overlap.
Here is the call graph for this function:

◆ setFromCenterSize()

void spk::BoundingBox2D::setFromCenterSize ( const spk::Vector2 & p_center,
const spk::Vector2 & p_size )

Updates the box from center and size.

Parameters
p_centerCenter point.
p_sizeSize (width, height).
Here is the caller graph for this function:

◆ setFromMinMax()

void spk::BoundingBox2D::setFromMinMax ( const spk::Vector2 & p_min,
const spk::Vector2 & p_max )

Updates the box from minimum and maximum corners.

Parameters
p_minMinimum corner.
p_maxMaximum corner.
Here is the caller graph for this function:

The documentation for this struct was generated from the following files: