VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::MeshManager Class Reference

Public Member Functions

 MeshManager (VulkanContext &context, std::unique_ptr< VulkanResources > &resources, VirtualFileSystem *vfs)
 Constructor for MeshManager.
void init (Engine *engine)
 Initialize the MeshManager.
MeshComponent loadMesh (const std::string &path)
 Loads mesh from a file, creates vulkan mesh and returns a MeshComponent.
ModelObjectcreateModel (const std::string &name, MeshComponent meshComponent, TransformComponent transformComponent, vex::Entity parent)
 Creates a model object from a mesh component, transform component, and parent entity.
void destroyModel (std::string &name, MeshComponent meshComponent)
 Destroys a model object by name and mesh component.
void registerVulkanMesh (MeshComponent &meshComponent)
 Registers a Vulkan mesh component.
std::unique_ptr< VulkanMesh > & getVulkanMeshByMesh (MeshComponent &meshComponent)
 Retrieves a Vulkan mesh by mesh component.
void loadMeshesAsync (const std::vector< MeshComponent * > &pendingComponents)
 Loads meshes asynchronously from the given paths.
bool isMeshLoaded (const std::string &path) const
 Checks if a mesh is loaded by path.
void clearState ()
 Clears the state of the mesh manager, resetting model IDs and clearing the mesh map.

Private Member Functions

void onMeshComponentConstruct (vex::Registry &registry, vex::Entity entity)
 Internally handles the construction of a mesh component called by entt callbacks.
void onMeshComponentDestroy (vex::Registry &registry, vex::Entity entity)
 Internally handles the destruction of a mesh component called by entt callbacks.
void releaseMeshReference (const std::string &path, MeshComponent &ownerComp)
 Internally handles the release of a mesh reference called by entt callbacks.

Private Attributes

VulkanContextm_r_context
Enginem_p_engine = nullptr
VirtualFileSystemm_vfs
std::unique_ptr< VulkanResources > & m_p_resources
vex_map< std::string, std::unique_ptr< VulkanMesh > > m_vulkanMeshes
std::vector< uint32_t > m_freeModelIds
uint32_t m_nextModelId = 0
std::unordered_map< uint32_t, std::string > m_installedPaths
std::unordered_map< std::string, std::pair< glm::vec3, float > > m_meshBoundsCache

Detailed Description

Definition at line 22 of file MeshManager.hpp.

Constructor & Destructor Documentation

◆ MeshManager()

vex::MeshManager::MeshManager ( VulkanContext & context,
std::unique_ptr< VulkanResources > & resources,
VirtualFileSystem * vfs )

Constructor for MeshManager.

Parameters
VulkanContext&context
std::unique_ptr<VulkanResources>&resources
VirtualFileSystem*vfs

Definition at line 18 of file MeshManager.cpp.

◆ ~MeshManager()

vex::MeshManager::~MeshManager ( )

Definition at line 23 of file MeshManager.cpp.

Member Function Documentation

◆ clearState()

void vex::MeshManager::clearState ( )

Clears the state of the mesh manager, resetting model IDs and clearing the mesh map.

Definition at line 284 of file MeshManager.cpp.

◆ createModel()

ModelObject * vex::MeshManager::createModel ( const std::string & name,
MeshComponent meshComponent,
TransformComponent transformComponent,
vex::Entity parent = vex::NULL_ENTITY )

Creates a model object from a mesh component, transform component, and parent entity.

Parameters
conststd::string& name
MeshComponentmeshComponent
TransformComponenttransformComponent
vex::Entityparent
Returns
ModelObject*

Definition at line 28 of file MeshManager.cpp.

◆ destroyModel()

void vex::MeshManager::destroyModel ( std::string & name,
MeshComponent meshComponent )

Destroys a model object by name and mesh component.

Parameters
std::string&name
MeshComponentmeshComponent

Definition at line 367 of file MeshManager.cpp.

◆ getVulkanMeshByMesh()

std::unique_ptr< VulkanMesh > & vex::MeshManager::getVulkanMeshByMesh ( MeshComponent & meshComponent)

Retrieves a Vulkan mesh by mesh component.

Parameters
MeshComponent&meshComponent
Returns
std::unique_ptr<VulkanMesh>&

Definition at line 116 of file MeshManager.cpp.

◆ init()

void vex::MeshManager::init ( Engine * engine)
inline

Initialize the MeshManager.

Parameters
Engine*engine

Definition at line 33 of file MeshManager.hpp.

◆ isMeshLoaded()

bool vex::MeshManager::isMeshLoaded ( const std::string & path) const
inline

Checks if a mesh is loaded by path.

Parameters
conststd::string& path
Returns
bool

Definition at line 79 of file MeshManager.hpp.

◆ loadMesh()

MeshComponent vex::MeshManager::loadMesh ( const std::string & path)

Loads mesh from a file, creates vulkan mesh and returns a MeshComponent.

Parameters
conststd::string& path
Returns
MeshComponent

Definition at line 76 of file MeshManager.cpp.

◆ loadMeshesAsync()

void vex::MeshManager::loadMeshesAsync ( const std::vector< MeshComponent * > & pendingComponents)

Loads meshes asynchronously from the given paths.

Parameters
conststd::vector<MeshComponent*>& pendingComponents

Definition at line 221 of file MeshManager.cpp.

◆ onMeshComponentConstruct()

void vex::MeshManager::onMeshComponentConstruct ( vex::Registry & registry,
vex::Entity entity )
private

Internally handles the construction of a mesh component called by entt callbacks.

Definition at line 292 of file MeshManager.cpp.

◆ onMeshComponentDestroy()

void vex::MeshManager::onMeshComponentDestroy ( vex::Registry & registry,
vex::Entity entity )
private

Internally handles the destruction of a mesh component called by entt callbacks.

Definition at line 323 of file MeshManager.cpp.

◆ registerVulkanMesh()

void vex::MeshManager::registerVulkanMesh ( MeshComponent & meshComponent)

Registers a Vulkan mesh component.

Parameters
MeshComponent&meshComponent

Definition at line 155 of file MeshManager.cpp.

◆ releaseMeshReference()

void vex::MeshManager::releaseMeshReference ( const std::string & path,
MeshComponent & ownerComp )
private

Internally handles the release of a mesh reference called by entt callbacks.

Definition at line 346 of file MeshManager.cpp.

Member Data Documentation

◆ m_freeModelIds

std::vector<uint32_t> vex::MeshManager::m_freeModelIds
private

Definition at line 92 of file MeshManager.hpp.

◆ m_installedPaths

std::unordered_map<uint32_t, std::string> vex::MeshManager::m_installedPaths
private

Definition at line 95 of file MeshManager.hpp.

◆ m_meshBoundsCache

std::unordered_map<std::string, std::pair<glm::vec3, float> > vex::MeshManager::m_meshBoundsCache
private

Definition at line 96 of file MeshManager.hpp.

◆ m_nextModelId

uint32_t vex::MeshManager::m_nextModelId = 0
private

Definition at line 93 of file MeshManager.hpp.

◆ m_p_engine

Engine* vex::MeshManager::m_p_engine = nullptr
private

Definition at line 88 of file MeshManager.hpp.

◆ m_p_resources

std::unique_ptr<VulkanResources>& vex::MeshManager::m_p_resources
private

Definition at line 90 of file MeshManager.hpp.

◆ m_r_context

VulkanContext& vex::MeshManager::m_r_context
private

Definition at line 87 of file MeshManager.hpp.

◆ m_vfs

VirtualFileSystem* vex::MeshManager::m_vfs
private

Definition at line 89 of file MeshManager.hpp.

◆ m_vulkanMeshes

vex_map<std::string, std::unique_ptr<VulkanMesh> > vex::MeshManager::m_vulkanMeshes
private

Definition at line 91 of file MeshManager.hpp.


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