galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
RectPack.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_MATH_RECTPACK_HPP_
9#define GALAXY_MATH_RECTPACK_HPP_
10
11#include <optional>
12#include <vector>
13
14#include "galaxy/math/Rect.hpp"
15
16namespace galaxy
17{
21 class RectPack final
22 {
23 public:
27 RectPack() noexcept;
28
32 ~RectPack() noexcept;
33
42 void init(const int width, const int height) noexcept;
43
53 [[nodiscard]]
54 std::optional<iRect> pack(const int width, const int height);
55
59 void clear() noexcept;
60
66 [[nodiscard]]
67 int get_width() const noexcept;
68
74 [[nodiscard]]
75 int get_height() const noexcept;
76
82 [[nodiscard]]
83 const std::vector<iRect>& get_free_space() const noexcept;
84
85 private:
90
95
99 std::vector<iRect> m_free_rects;
100 };
101} // namespace galaxy
102
103#endif
Rectangle 2D bin packing class.
Definition RectPack.hpp:22
int m_width
The starting width of the rectangle.
Definition RectPack.hpp:89
const std::vector< iRect > & get_free_space() const noexcept
Get free rectangles.
Definition RectPack.cpp:106
std::optional< iRect > pack(const int width, const int height)
Pack a rectangle into the master rectangle.
Definition RectPack.cpp:31
RectPack() noexcept
Constructor.
Definition RectPack.cpp:12
int m_height
The starting width of the rectangle.
Definition RectPack.hpp:94
void clear() noexcept
Clear all data.
Definition RectPack.cpp:90
int get_height() const noexcept
Get total height.
Definition RectPack.cpp:101
void init(const int width, const int height) noexcept
Set starting width and height of rectangle.
Definition RectPack.cpp:23
int get_width() const noexcept
Get total width.
Definition RectPack.cpp:96
~RectPack() noexcept
Destructor.
Definition RectPack.cpp:18
std::vector< iRect > m_free_rects
Free space in master rectangle.
Definition RectPack.hpp:99
Timer.hpp galaxy.
Definition Timer.cpp:18