Sparkle 0.0.1
Loading...
Searching...
No Matches
spk_bounding_box_2d.hpp
1#pragma once
2
3#include "structure/math/spk_matrix.hpp"
4#include "structure/math/spk_vector2.hpp"
5#include "structure/math/spk_vector3.hpp"
6
7namespace spk
8{
19 {
23 spk::Vector2 center{0.0f, 0.0f};
27 spk::Vector2 size{0.0f, 0.0f};
31 spk::Vector2 min{0.0f, 0.0f};
35 spk::Vector2 max{0.0f, 0.0f};
36
40 BoundingBox2D() = default;
46 BoundingBox2D(const spk::Vector2 &p_center, const spk::Vector2 &p_size);
47
53 void setFromCenterSize(const spk::Vector2 &p_center, const spk::Vector2 &p_size);
59 void setFromMinMax(const spk::Vector2 &p_min, const spk::Vector2 &p_max);
65 BoundingBox2D applyMatrix(const spk::Matrix4x4 &p_transform) const;
71 bool intersect(const BoundingBox2D &p_other) const;
72 };
73}
spk::Vector2 max
Maximum corner of the bounding box.
Definition spk_bounding_box_2d.hpp:35
BoundingBox2D applyMatrix(const spk::Matrix4x4 &p_transform) const
Applies a transform matrix to the bounding box.
Definition spk_bounding_box_2d.cpp:29
BoundingBox2D()=default
Builds a default bounding box at the origin.
spk::Vector2 center
Center point of the bounding box.
Definition spk_bounding_box_2d.hpp:23
spk::Vector2 size
Size of the bounding box (width, height).
Definition spk_bounding_box_2d.hpp:27
spk::Vector2 min
Minimum corner of the bounding box.
Definition spk_bounding_box_2d.hpp:31
void setFromMinMax(const spk::Vector2 &p_min, const spk::Vector2 &p_max)
Updates the box from minimum and maximum corners.
Definition spk_bounding_box_2d.cpp:21
void setFromCenterSize(const spk::Vector2 &p_center, const spk::Vector2 &p_size)
Updates the box from center and size.
Definition spk_bounding_box_2d.cpp:12
bool intersect(const BoundingBox2D &p_other) const
Checks intersection with another bounding box.
Definition spk_bounding_box_2d.cpp:54