![]() |
galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
|
Rectangle 2D bin packing class. More...
#include <RectPack.hpp>
Public Member Functions | |
RectPack () noexcept | |
Constructor. | |
~RectPack () noexcept | |
Destructor. | |
void | init (const int width, const int height) noexcept |
Set starting width and height of rectangle. | |
std::optional< sf::IntRect > | pack (const int width, const int height) noexcept |
Pack a rectangle into the master rectangle. | |
void | clear () noexcept |
Clear all data. | |
int | get_width () const noexcept |
Get total width. | |
int | get_height () const noexcept |
Get total height. | |
const std::vector< sf::IntRect > & | get_free_space () const noexcept |
Get free rectangles. | |
Private Attributes | |
int | m_width |
The starting width of the rectangle. | |
int | m_height |
The starting width of the rectangle. | |
std::vector< sf::IntRect > | m_free_rects |
Free space in master rectangle. | |
Rectangle 2D bin packing class.
Definition at line 23 of file RectPack.hpp.
|
noexcept |
Constructor.
Definition at line 14 of file RectPack.cpp.
|
noexcept |
Destructor.
Definition at line 20 of file RectPack.cpp.
|
noexcept |
Set starting width and height of rectangle.
Generally should be a power of 2.
width | Width of the master rectangle. |
height | Height of the master rectangle. |
Definition at line 25 of file RectPack.cpp.
|
nodiscardnoexcept |
Pack a rectangle into the master rectangle.
width | Width of the rectangle to pack. |
height | Height of the rectangle to pack. |
Definition at line 33 of file RectPack.cpp.
|
noexcept |
Clear all data.
Definition at line 90 of file RectPack.cpp.
|
nodiscardnoexcept |
Get total width.
Definition at line 96 of file RectPack.cpp.
|
nodiscardnoexcept |
Get total height.
Definition at line 101 of file RectPack.cpp.
|
nodiscardnoexcept |
Get free rectangles.
Definition at line 106 of file RectPack.cpp.
|
private |
The starting width of the rectangle.
Definition at line 91 of file RectPack.hpp.
|
private |
The starting width of the rectangle.
Definition at line 96 of file RectPack.hpp.
|
private |
Free space in master rectangle.
Definition at line 101 of file RectPack.hpp.