Utility/GuillotineImageAtlas: Add max layer size
This commit is contained in:
@@ -15,7 +15,8 @@ namespace Nz
|
||||
|
||||
GuillotineImageAtlas::GuillotineImageAtlas() :
|
||||
m_rectChoiceHeuristic(GuillotineBinPack::RectBestAreaFit),
|
||||
m_rectSplitHeuristic(GuillotineBinPack::SplitMinimizeArea)
|
||||
m_rectSplitHeuristic(GuillotineBinPack::SplitMinimizeArea),
|
||||
m_maxLayerSize(16384)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,6 +43,11 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int GuillotineImageAtlas::GetMaxLayerSize() const
|
||||
{
|
||||
return m_maxLayerSize;
|
||||
}
|
||||
|
||||
GuillotineBinPack::FreeRectChoiceHeuristic GuillotineImageAtlas::GetRectChoiceHeuristic() const
|
||||
{
|
||||
return m_rectChoiceHeuristic;
|
||||
@@ -115,9 +121,10 @@ namespace Nz
|
||||
if (newSize == Vector2ui::Zero())
|
||||
newSize.Set(s_atlasStartSize);
|
||||
|
||||
if (ResizeLayer(layer, newSize))
|
||||
// Limit image atlas size to prevent allocating too much contiguous memory blocks
|
||||
if (newSize.x <= m_maxLayerSize && newSize.y <= m_maxLayerSize && ResizeLayer(layer, newSize))
|
||||
{
|
||||
// Oui on peut !
|
||||
// Yes we can!
|
||||
layer.binPack.Expand(newSize); // On ajuste l'atlas virtuel
|
||||
|
||||
// Et on relance la boucle sur la nouvelle dernière couche
|
||||
@@ -149,6 +156,11 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
void GuillotineImageAtlas::SetMaxLayerSize(unsigned int maxLayerSize)
|
||||
{
|
||||
m_maxLayerSize = maxLayerSize;
|
||||
}
|
||||
|
||||
void GuillotineImageAtlas::SetRectChoiceHeuristic(GuillotineBinPack::FreeRectChoiceHeuristic heuristic)
|
||||
{
|
||||
m_rectChoiceHeuristic = heuristic;
|
||||
|
||||
Reference in New Issue
Block a user