Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Core::GltfStore Class Reference

Registry store for glTF source files and their renderable node handles. More...

#include <AssetRegistry.h>

Collaboration diagram for Engine::Core::GltfStore:

Classes

struct  GltfRecord
 Stored metadata for one glTF source handle slot. More...
struct  RenderableRecord
 Stored metadata for one glTF renderable handle slot. More...

Public Member Functions

 GltfStore (AssetManager *assetManager=nullptr, GeometryMeshStore *geometryMeshes=nullptr, MaterialStore *materials=nullptr)
 Creates a glTF store backed by optional asset and child stores.
void setAssetManager (AssetManager *assetManager)
 Sets the asset manager used by this store and imported child records.
void setGeometryMeshStore (GeometryMeshStore *geometryMeshes)
 Sets the geometry store used when importing glTF renderable metadata.
void setMaterialStore (MaterialStore *materials)
 Sets the material store used when importing glTF primitive metadata.
Assets::GltfHandle load (const std::filesystem::path &source)
 Gets or creates a stable handle for a glTF source file and imports its renderable metadata.
Assets::GltfRenderableHandle renderable (Assets::GltfHandle gltf, std::string_view nodeName)
 Looks up a renderable node handle inside a loaded glTF file.
Assets::GeometryMeshHandle geometryMesh (Assets::GltfRenderableHandle renderable) const
 Returns the geometry mesh handle used by a glTF renderable.
std::optional< AnchorPoint > anchorPoint (Assets::GltfRenderableHandle renderable, std::string_view name) const
 Looks up an AnchorPoint authored below a renderable node.
std::vector< std::string > anchorPointNames (Assets::GltfRenderableHandle renderable) const
 Lists the authored AnchorPoint names for a renderable node.
const GltfRenderableRecord * get (Assets::GltfRenderableHandle renderable) const
 Returns imported metadata for a glTF renderable handle.
const std::filesystem::path * sourcePath (Assets::GltfHandle gltf) const
 Returns the authored source path for a glTF handle.
bool isValid (Assets::GltfHandle handle) const
 Checks whether a glTF handle refers to a live slot in this store.
bool isValid (Assets::GltfRenderableHandle handle) const
 Checks whether a glTF renderable handle refers to a live slot in this store.

Private Member Functions

void importMetadata (Assets::GltfHandle gltf)
 Imports renderable, geometry, and material metadata for a loaded glTF handle.

Static Private Member Functions

static std::string keyFor (const std::filesystem::path &source)
 Builds the deduplication key for a glTF source path.
static std::string fallbackNodeName (size_t nodeIndex)
 Builds the synthetic node name used for unnamed glTF nodes.

Private Attributes

AssetManager * assetManager_ = nullptr
 Optional bridge retained for store wiring.
GeometryMeshStore * geometryMeshes_ = nullptr
 Store that receives geometry handles during metadata import.
MaterialStore * materials_ = nullptr
 Store that receives material handles during metadata import.
std::vector< GltfRecord > gltfRecords_
 Slot storage indexed by GltfHandle::index.
std::vector< RenderableRecord > renderableRecords_
 Slot storage indexed by GltfRenderableHandle::index.
std::unordered_map< std::string, uint32_t > sourceToIndex_
 Deduplication map from keyFor() to glTF slot index.

Detailed Description

Registry store for glTF source files and their renderable node handles.

GltfStore imports metadata from a source glTF, creates renderable records for mesh-bearing nodes, and links those records to geometry and material handles.

Definition at line 583 of file AssetRegistry.h.

Constructor & Destructor Documentation

◆ GltfStore()

Engine::Core::GltfStore::GltfStore ( AssetManager * assetManager = nullptr,
GeometryMeshStore * geometryMeshes = nullptr,
MaterialStore * materials = nullptr )

Creates a glTF store backed by optional asset and child stores.

Parameters
assetManagerAsset manager used by child stores when importing metadata.
geometryMeshesStore that receives geometry handles for mesh-bearing glTF nodes.
materialsStore that receives material handles for glTF primitives.

Member Function Documentation

◆ anchorPoint()

std::optional< AnchorPoint > Engine::Core::GltfStore::anchorPoint ( Assets::GltfRenderableHandle renderable,
std::string_view name ) const
nodiscard

Looks up an AnchorPoint authored below a renderable node.

Parameters
renderableRenderable node that owns the AnchorPoint.
nameAuthored direct-child empty node name.
Returns
AnchorPoint by value, or std::nullopt when the handle is invalid or the name is unknown.

References renderable().

Here is the call graph for this function:

◆ anchorPointNames()

std::vector< std::string > Engine::Core::GltfStore::anchorPointNames ( Assets::GltfRenderableHandle renderable) const
nodiscard

Lists the authored AnchorPoint names for a renderable node.

Parameters
renderableRenderable node to inspect.
Returns
Names sorted lexicographically, or an empty vector when the handle is invalid or has no AnchorPoints.

References renderable().

Here is the call graph for this function:

◆ fallbackNodeName()

std::string Engine::Core::GltfStore::fallbackNodeName ( size_t nodeIndex)
staticnodiscardprivate

Builds the synthetic node name used for unnamed glTF nodes.

Parameters
nodeIndexIndex of the unnamed glTF node.
Returns
Generated node name in the form #node:<index>.

◆ geometryMesh()

Assets::GeometryMeshHandle Engine::Core::GltfStore::geometryMesh ( Assets::GltfRenderableHandle renderable) const
nodiscard

Returns the geometry mesh handle used by a glTF renderable.

Parameters
renderableRenderable node handle to inspect.
Returns
Geometry mesh handle, or a null handle when renderable is invalid.

References renderable().

Here is the call graph for this function:

◆ get()

const GltfRenderableRecord * Engine::Core::GltfStore::get ( Assets::GltfRenderableHandle renderable) const
nodiscard

Returns imported metadata for a glTF renderable handle.

Parameters
renderableRenderable node handle to inspect.
Returns
Pointer to renderable metadata, or nullptr when the handle is invalid.

References renderable().

Here is the call graph for this function:

◆ importMetadata()

void Engine::Core::GltfStore::importMetadata ( Assets::GltfHandle gltf)
private

Imports renderable, geometry, and material metadata for a loaded glTF handle.

Parameters
gltfValid glTF handle whose source metadata should be imported.

◆ isValid() [1/2]

bool Engine::Core::GltfStore::isValid ( Assets::GltfHandle handle) const
nodiscard

Checks whether a glTF handle refers to a live slot in this store.

Parameters
handleHandle to validate.
Returns
True when the handle index and generation match a stored glTF record.

◆ isValid() [2/2]

bool Engine::Core::GltfStore::isValid ( Assets::GltfRenderableHandle handle) const
nodiscard

Checks whether a glTF renderable handle refers to a live slot in this store.

Parameters
handleHandle to validate.
Returns
True when the handle index and generation match a stored renderable record.

◆ keyFor()

std::string Engine::Core::GltfStore::keyFor ( const std::filesystem::path & source)
staticnodiscardprivate

Builds the deduplication key for a glTF source path.

Parameters
sourceEngine-relative glTF source path.
Returns
Stable string key used by sourceToIndex_.

◆ load()

Assets::GltfHandle Engine::Core::GltfStore::load ( const std::filesystem::path & source)
nodiscard

Gets or creates a stable handle for a glTF source file and imports its renderable metadata.

Parameters
sourceEngine-relative glTF source path.
Returns
Existing or newly created glTF handle.
Exceptions
std::invalid_argumentwhen source is an absolute path.

Referenced by Engine::Entities::Scene::spawnAll().

Here is the caller graph for this function:

◆ renderable()

Assets::GltfRenderableHandle Engine::Core::GltfStore::renderable ( Assets::GltfHandle gltf,
std::string_view nodeName )
nodiscard

Looks up a renderable node handle inside a loaded glTF file.

Parameters
gltfValid glTF handle returned by load().
nodeNameName of the mesh-bearing node to look up.
Returns
Renderable handle, or a null handle when gltf is invalid or nodeName is unknown.

Referenced by anchorPoint(), anchorPointNames(), geometryMesh(), and get().

Here is the caller graph for this function:

◆ setAssetManager()

void Engine::Core::GltfStore::setAssetManager ( AssetManager * assetManager)

Sets the asset manager used by this store and imported child records.

Parameters
assetManagerAsset manager to use, or nullptr for handle-only use.

◆ setGeometryMeshStore()

void Engine::Core::GltfStore::setGeometryMeshStore ( GeometryMeshStore * geometryMeshes)

Sets the geometry store used when importing glTF renderable metadata.

Parameters
geometryMeshesGeometry mesh store to receive node geometry handles.

◆ setMaterialStore()

void Engine::Core::GltfStore::setMaterialStore ( MaterialStore * materials)

Sets the material store used when importing glTF primitive metadata.

Parameters
materialsMaterial store to receive primitive material handles.

◆ sourcePath()

const std::filesystem::path * Engine::Core::GltfStore::sourcePath ( Assets::GltfHandle gltf) const
nodiscard

Returns the authored source path for a glTF handle.

Parameters
gltfglTF handle to look up.
Returns
Pointer to the stored source path, or nullptr when the handle is invalid.

Member Data Documentation

◆ assetManager_

AssetManager* Engine::Core::GltfStore::assetManager_ = nullptr
private

Optional bridge retained for store wiring.

Definition at line 725 of file AssetRegistry.h.

◆ geometryMeshes_

GeometryMeshStore* Engine::Core::GltfStore::geometryMeshes_ = nullptr
private

Store that receives geometry handles during metadata import.

Definition at line 726 of file AssetRegistry.h.

◆ gltfRecords_

std::vector<GltfRecord> Engine::Core::GltfStore::gltfRecords_
private

Slot storage indexed by GltfHandle::index.

Definition at line 728 of file AssetRegistry.h.

◆ materials_

MaterialStore* Engine::Core::GltfStore::materials_ = nullptr
private

Store that receives material handles during metadata import.

Definition at line 727 of file AssetRegistry.h.

◆ renderableRecords_

std::vector<RenderableRecord> Engine::Core::GltfStore::renderableRecords_
private

Slot storage indexed by GltfRenderableHandle::index.

Definition at line 729 of file AssetRegistry.h.

◆ sourceToIndex_

std::unordered_map<std::string, uint32_t> Engine::Core::GltfStore::sourceToIndex_
private

Deduplication map from keyFor() to glTF slot index.

Definition at line 730 of file AssetRegistry.h.


The documentation for this class was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/Asset/AssetRegistry.h