U3D
Open-source, cross-platform 2D and 3D game engine built in C++
Loading...
Searching...
No Matches
Urho3D::AreaAllocator Class Reference

Rectangular area allocator. More...

#include </var/dev/u3d/stable/Source/Urho3D/Math/AreaAllocator.h>

Collaboration diagram for Urho3D::AreaAllocator:
[legend]

Public Member Functions

 AreaAllocator ()
 Default construct with empty size.
 
 AreaAllocator (int width, int height, bool fastMode=true)
 Construct with given width and height.
 
 AreaAllocator (int width, int height, int maxWidth, int maxHeight, bool fastMode=true)
 Construct with given width and height, and set the maximum it allows to grow.
 
void Reset (int width, int height, int maxWidth=0, int maxHeight=0, bool fastMode=true)
 Reset to given width and height and remove all previous allocations.
 
bool Allocate (int width, int height, int &x, int &y)
 Try to allocate an area. Return true if successful, with x & y coordinates filled.
 
int GetWidth () const
 Return the current width.
 
int GetHeight () const
 Return the current height.
 
bool GetFastMode () const
 Return whether uses fast mode. Fast mode uses a simpler allocation scheme which may waste free space, but is OK for eg. fonts.
 

Private Member Functions

bool SplitRect (unsigned freeAreaIndex, const IntRect &reserve)
 Remove space from a free rectangle. Return true if the original rectangle should be erased from the free list. Not called in fast mode.
 
void Cleanup ()
 Clean up redundant free space. Not called in fast mode.
 

Private Attributes

PODVector< IntRectfreeAreas_
 Free rectangles.
 
IntVector2 size_
 Current size.
 
IntVector2 maxSize_
 Maximum size it allows to grow. It is zero when it is not allowed to grow.
 
bool doubleWidth_ {true}
 The dimension use for next growth. Used internally.
 
bool fastMode_ {true}
 Fast mode flag.
 

Detailed Description

Rectangular area allocator.


The documentation for this class was generated from the following files: