Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::DynamicAtlasManager Class Reference

Dynamic 2D atlas manager. More...

#include <DynamicAtlasManager.hpp>

Classes

struct  Region
 Structure representing a rectangular region in the atlas. More...
 

Public Member Functions

Region Allocate (Uint32 Width, Uint32 Height)
 Allocates a rectangular region in the atlas.
 
void Free (Region &&R)
 Frees a previously allocated region in the atlas.
 
Uint32 GetFreeRegionCount () const
 Returns the number of free regions in the atlas.
 
Uint32 GetWidth () const
 Returns the atlas width.
 
Uint32 GetHeight () const
 Returns the atlas height.
 
Uint64 GetTotalFreeArea () const
 Returns the total free area of the atlas.
 
bool IsEmpty () const
 Checks if the atlas is empty, i.e. if there are no allocated regions.
 

Detailed Description

Dynamic 2D atlas manager.

This class manages a 2D atlas of regions. It allows allocating and freeing rectangular regions of the atlas. The regions are represented by the Region structure, which contains the x and y coordinates of the top-left corner, as well as the width and height of the region.

Warning
The class is not thread-safe. All operations on the atlas must be must be protected by a mutex or other synchronization mechanism.

Member Function Documentation

◆ Allocate()

DynamicAtlasManager::Region Diligent::DynamicAtlasManager::Allocate ( Uint32 Width,
Uint32 Height )

Allocates a rectangular region in the atlas.

Parameters
Width- Width of the region to allocate.
Height- Height of the region to allocate.
Returns
The allocated region.

If the requested region cannot be allocated, an empty region is returned.

◆ Free()

void Diligent::DynamicAtlasManager::Free ( Region && R)

Frees a previously allocated region in the atlas.

Parameters
R- The region to free.

◆ GetTotalFreeArea()

Uint64 Diligent::DynamicAtlasManager::GetTotalFreeArea ( ) const
inline

Returns the total free area of the atlas.

The total free area is the sum of the areas of all free regions in the atlas, and thus may be fragmented.