Lysa  0.0
Lysa 3D Engine
MeshManager Class Reference
+ Inheritance diagram for MeshManager:

Public Member Functions

 MeshManager (size_t capacity, size_t vertexCapacity, size_t indexCapacity, size_t surfaceCapacity)
 
Meshcreate (const std::vector< Vertex > &vertices, const std::vector< uint32 > &indices, const std::vector< MeshSurface > &surfaces, const std::string &name="")
 
Meshcreate (const std::string &name="")
 
MeshcreateQuad (float width, float height, unique_id material, MeshAlignment alignment=MeshAlignment::CENTER, float xOffset=0.f, float yOffset=0.f, const std::string &name="quad")
 
MeshcreateTriangle (float width, float height, unique_id material, MeshAlignment alignment=MeshAlignment::CENTER, float xOffset=0.f, float yOffset=0.f, const std::string &name="triangle")
 
void upload (unique_id id)
 
bool isUploaded (const unique_id id)
 
void flush ()
 
auto getMeshBuffer () const
 
auto getMeshSurfaceBuffer () const
 
auto getVertexBuffer () const
 
auto getIndexBuffer () const
 
bool destroy (unique_id id) override
 
bool destroy (const Mesh &m) override
 
- Public Member Functions inherited from ResourcesManager< Mesh >
 ResourcesManager (ResourcesManager &) = delete
 
Meshcreate (Args &&...args)
 
void destroy (const std::vector< unique_id > &ids)
 
void forEach (Func &&func)
 
void forEach (Func &&func) const
 
unique_id getCapacity () const
 
bool have (const unique_id id) const
 
ResourcesManageroperator= (ResourcesManager &) = delete
 
Meshoperator[] (const unique_id id)
 
const Meshoperator[] (const unique_id id) const
 
void use (const unique_id id)
 
virtual ~ResourcesManager ()
 

Additional Inherited Members

- Protected Member Functions inherited from ResourcesManager< Mesh >
 ResourcesManager (const size_t capacity, const std::string &name)
 
Meshallocate (std::unique_ptr< Mesh > instance)
 
bool isFull () const
 
- Protected Attributes inherited from ResourcesManager< Mesh >
std::vector< std::unique_ptr< Mesh > > resources
 
std::mutex resourcesMutex
 

Constructor & Destructor Documentation

MeshManager ( size_t  capacity,
size_t  vertexCapacity,
size_t  indexCapacity,
size_t  surfaceCapacity 
)

Construct a new manager

Parameters
capacitymaximum capacity
vertexCapacity
indexCapacity
surfaceCapacity

Member Function Documentation

Mesh& create ( const std::string &  name = "")
Mesh& create ( const std::vector< Vertex > &  vertices,
const std::vector< uint32 > &  indices,
const std::vector< MeshSurface > &  surfaces,
const std::string &  name = "" 
)
Mesh& createQuad ( float  width,
float  height,
unique_id  material,
MeshAlignment  alignment = MeshAlignment::CENTER,
float  xOffset = 0.f,
float  yOffset = 0.f,
const std::string &  name = "quad" 
)

Creates a QuadMesh (flat quad in the XY plane).

Parameters
widthWidth along the X axis (world units)
heightHeight along the Y axis (world units)
materialMaterial applied to the quad surface
alignmentCENTER: origin at horizontal center; LEFT: origin at left edge
xOffsetHorizontal offset applied to all vertices (shifts the quad left/right from origin)
yOffsetVertical offset applied to all vertices (shifts the quad up/down from origin)
nameResource name
Mesh& createTriangle ( float  width,
float  height,
unique_id  material,
MeshAlignment  alignment = MeshAlignment::CENTER,
float  xOffset = 0.f,
float  yOffset = 0.f,
const std::string &  name = "triangle" 
)

Creates a TriangleMesh (flat triangle in the XY plane).

Parameters
widthWidth of the base along the X axis (world units)
heightHeight along the Y axis (world units)
materialMaterial applied to the triangle surface
alignmentCENTER: apex at horizontal center; LEFT: left base edge at origin
xOffsetHorizontal offset applied to all vertices
yOffsetVertical offset applied to all vertices
nameResource name
bool destroy ( const Mesh res)
inlineoverridevirtual

Releases a resource by reference, decrementing its reference counter.

Parameters
resResource to destroy.
Returns
true if the resource was actually freed, false if references remain.

Reimplemented from lysa::ResourcesManager< Mesh >::destroy()

bool destroy ( unique_id  id)
overridevirtual

Releases a resource by ID, decrementing its reference counter. The slot is returned to the free list only when the counter reaches zero.

Parameters
idUnique identifier of the resource to destroy.
Returns
true if the resource was actually freed, false if references remain.

Reimplemented from lysa::ResourcesManager< Mesh >::destroy()

void flush ( )
auto getIndexBuffer ( ) const
inline
auto getMeshBuffer ( ) const
inline
auto getMeshSurfaceBuffer ( ) const
inline
auto getVertexBuffer ( ) const
inline
bool isUploaded ( const unique_id  id)
inline
void upload ( unique_id  id)