Refactor RectPack into new RectPackNode and RectPackAtlas that uses more optimized memory allocations

This commit is contained in:
Wojtek Figat
2024-06-20 15:26:58 +02:00
parent a6324c8f65
commit 8e49a35e0e
9 changed files with 351 additions and 194 deletions

View File

@@ -13,12 +13,12 @@ namespace ShadowsOfMordor
{
public:
struct Node : RectPack<Node>
struct Node : RectPackNode<int32>
{
Builder::LightmapUVsChart* Chart = nullptr;
Node(uint32 x, uint32 y, uint32 width, uint32 height)
: RectPack<Node>(x, y, width, height)
Node(int32 x, int32 y, int32 width, int32 height)
: RectPackNode<int32>(x, y, width, height)
{
}
@@ -32,7 +32,7 @@ namespace ShadowsOfMordor
private:
Node _root;
RectPackAtlas<Node> _root;
const LightmapSettings* _settings;
public:
@@ -42,9 +42,9 @@ namespace ShadowsOfMordor
/// </summary>
/// <param name="settings">The settings.</param>
AtlasChartsPacker(const LightmapSettings* settings)
: _root(settings->ChartsPadding, settings->ChartsPadding, (int32)settings->AtlasSize - settings->ChartsPadding, (int32)settings->AtlasSize - settings->ChartsPadding)
, _settings(settings)
: _settings(settings)
{
_root.Init((int32)settings->AtlasSize, (int32)settings->AtlasSize, settings->ChartsPadding);
}
/// <summary>