3#include "Engine/Asset/AssetHandles.h"
4#include "Engine/Asset/AssetRefs.h"
5#include "Engine/Audio/AudioAssetRef.h"
6#include "Engine/Ecs/EcsData.h"
7#include "Engine/Files/AssetPath.h"
8#include "Engine/Material/MaterialAssetRef.h"
9#include "Engine/Mesh/MeshAssetRef.h"
10#include "Engine/Texture/TextureHandle.h"
13#include <glm/mat4x4.hpp>
18#include <unordered_map>
456 std::unique_ptr<Assets::Animation> animation
643 std::string_view name
710 [[nodiscard]]
static std::string
keyFor(
const std::filesystem::path & source );
Animation clip loaded from glTF animation data.
Holds decoded PCM audio data as an engine asset.
Skeleton definition loaded from glTF skin data.
Type-erased texture handle for runtime storage.
Registry store for animation clip handles.
const Asset::MeshPath * path(Assets::AnimationClipHandle handle) const
Returns the authored animation path for an animation clip handle.
Assets::Animation * payload(Assets::AnimationClipHandle handle) const
Resolves an animation clip handle to its loaded payload behind the manager boundary.
Assets::AnimationClipHandle registerRuntimeAnimation(Asset::MeshPath animationPath, std::unique_ptr< Assets::Animation > animation)
Registers a runtime animation payload and returns its stable animation clip handle.
std::unordered_map< std::string, uint32_t > pathToIndex_
Deduplication map from keyFor() to slot index.
static std::string keyFor(const Asset::MeshPath &animationPath)
Builds the deduplication key for an animation source path and animation name.
Assets::AnimationClipHandle load(const Asset::MeshPath &animationPath)
Gets or creates a stable handle for an authored animation source path.
std::vector< Record > records_
Slot storage indexed by AnimationClipHandle::index.
void setAssetManager(AssetManager *assetManager)
Sets the asset manager used when new animation handles request payload loading.
bool isValid(Assets::AnimationClipHandle handle) const
Checks whether an animation clip handle refers to a live slot in this store.
AssetManager * assetManager_
Optional bridge used to request animation refs.
AnimationClipStore(AssetManager *assetManager=nullptr)
Creates an animation clip store backed by an optional asset manager.
Coordinates engine asset loading pipelines and runtime texture descriptor ownership.
const GeometryMeshStore & geometryMeshes() const
Returns the read-only geometry mesh store.
Assets::GltfHandle resolve(Assets::Authored::GltfAssetRef ref)
Resolves an authored glTF file reference to a stable glTF handle.
MaterialStore & materials()
Returns the mutable material store.
Texture2DStore texture2Ds_
Store for sampled 2D texture handles.
AssetManager * assetManager_
Optional bridge shared by all child stores.
GltfStore gltfs_
Store for glTF source and renderable node handles.
SkinStore & skins()
Returns the mutable skin store.
GltfStore & gltfs()
Returns the mutable glTF store.
Assets::AudioClipHandle resolve(Assets::Authored::AudioAssetRef ref)
Resolves an authored audio reference to a stable audio clip handle.
AssetRegistry(AssetManager *assetManager=nullptr)
Creates an asset registry and wires all child stores to the same asset manager.
const MaterialStore & materials() const
Returns the read-only material store.
Texture2DStore & texture2Ds()
Returns the mutable 2D texture store.
AudioClipStore audioClips_
Store for audio clip handles.
const AnimationClipStore & animations() const
Returns the read-only animation clip store.
const AudioClipStore & audioClips() const
Returns the read-only audio clip store.
AnimationClipStore animations_
Store for animation clip handles.
AnimationClipStore & animations()
Returns the mutable animation clip store.
GeometryMeshStore & geometryMeshes()
Returns the mutable geometry mesh store.
GeometryMeshStore geometryMeshes_
Store for non-skinned mesh geometry handles.
AudioClipStore & audioClips()
Returns the mutable audio clip store.
const Texture2DStore & texture2Ds() const
Returns the read-only 2D texture store.
Assets::GltfRenderableHandle resolve(Assets::Authored::GltfRenderableAssetRef ref)
Resolves an authored glTF node reference to a stable renderable handle.
Assets::GeometryMeshHandle resolve(Assets::Authored::GeometryMeshAssetRef ref)
Resolves an authored geometry mesh reference through its glTF renderable node.
SkinStore skins_
Store for skin/skeleton binding handles.
const GltfStore & gltfs() const
Returns the read-only glTF store.
void setAssetManager(AssetManager *assetManager)
Updates the asset manager used by every child store.
Assets::Texture2DHandle resolve(Assets::Authored::Texture2DAssetRef ref)
Resolves an authored 2D texture reference to a stable texture handle.
MaterialStore materials_
Store for material handles.
const SkinStore & skins() const
Returns the read-only skin store.
Registry store for authored audio clip handles.
static std::string keyFor(const Asset::Path &source)
Builds the deduplication key for an audio source path.
std::unordered_map< std::string, uint32_t > sourceToIndex_
Deduplication map from keyFor() to slot index.
Assets::Audio * payload(Assets::AudioClipHandle handle) const
Returns the loaded payload behind a clip handle, or nullptr when not yet loaded.
const Asset::Path * sourcePath(Assets::AudioClipHandle handle) const
Returns the authored source path for an audio clip handle.
AudioClipStore(AssetManager *assetManager=nullptr)
Creates an audio clip store backed by an optional asset manager.
Asset::LoadState state(Assets::AudioClipHandle handle) const
Returns the current CPU loading state of the payload behind a clip handle.
AssetManager * assetManager_
Optional bridge used to request legacy audio refs.
std::vector< Record > records_
Slot storage indexed by AudioClipHandle::index.
Assets::AudioClipHandle load(const Asset::Path &source)
Gets or creates a stable handle for an authored audio source path.
void setAssetManager(AssetManager *assetManager)
Sets the asset manager used when new audio handles request payload loading.
bool isValid(Assets::AudioClipHandle handle) const
Checks whether an audio clip handle refers to a live slot in this store.
bool isLoaded(Assets::AudioClipHandle handle) const
Checks whether the payload behind a clip handle has finished loading.
Assets::AudioClipHandle load(const std::filesystem::path &source)
Gets or creates a stable handle for an authored audio source path.
bool isLoading(Assets::AudioClipHandle handle) const
Checks whether the payload behind a clip handle is currently being loaded.
Registry store for non-skinned geometry mesh handles.
AssetManager * assetManager_
Optional bridge used to request legacy mesh refs.
const Asset::MeshPath * path(Assets::GeometryMeshHandle handle) const
Returns the authored mesh path for a geometry mesh handle.
GeometryMeshStore(AssetManager *assetManager=nullptr)
Creates a geometry mesh store backed by an optional asset manager.
bool isValid(Assets::GeometryMeshHandle handle) const
Checks whether a geometry mesh handle refers to a live slot in this store.
void setAssetManager(AssetManager *assetManager)
Sets the asset manager used when new geometry handles request payload loading.
std::unordered_map< std::string, uint32_t > pathToIndex_
Deduplication map from keyFor() to slot index.
Assets::GeometryMeshHandle load(const Asset::MeshPath &meshPath)
Gets or creates a stable handle for a mesh path.
static std::string keyFor(const Asset::MeshPath &meshPath)
Builds the deduplication key for a mesh source path and mesh name.
std::vector< Record > records_
Slot storage indexed by GeometryMeshHandle::index.
Registry store for glTF source files and their renderable node handles.
void setGeometryMeshStore(GeometryMeshStore *geometryMeshes)
Sets the geometry store used when importing glTF renderable metadata.
const GltfRenderableRecord * get(Assets::GltfRenderableHandle renderable) const
Returns imported metadata for a glTF renderable handle.
Assets::GeometryMeshHandle geometryMesh(Assets::GltfRenderableHandle renderable) const
Returns the geometry mesh handle used by a glTF renderable.
Assets::GltfRenderableHandle renderable(Assets::GltfHandle gltf, std::string_view nodeName)
Looks up a renderable node handle inside a loaded glTF file.
const std::filesystem::path * sourcePath(Assets::GltfHandle gltf) const
Returns the authored source path for a glTF handle.
Assets::GltfHandle load(const std::filesystem::path &source)
Gets or creates a stable handle for a glTF source file and imports its renderable metadata.
static std::string fallbackNodeName(size_t nodeIndex)
Builds the synthetic node name used for unnamed glTF nodes.
std::vector< std::string > anchorPointNames(Assets::GltfRenderableHandle renderable) const
Lists the authored AnchorPoint names for a renderable node.
void importMetadata(Assets::GltfHandle gltf)
Imports renderable, geometry, and material metadata for a loaded glTF handle.
std::vector< RenderableRecord > renderableRecords_
Slot storage indexed by GltfRenderableHandle::index.
GltfStore(AssetManager *assetManager=nullptr, GeometryMeshStore *geometryMeshes=nullptr, MaterialStore *materials=nullptr)
Creates a glTF store backed by optional asset and child stores.
static std::string keyFor(const std::filesystem::path &source)
Builds the deduplication key for a glTF source path.
bool isValid(Assets::GltfHandle handle) const
Checks whether a glTF handle refers to a live slot in this store.
GeometryMeshStore * geometryMeshes_
Store that receives geometry handles during metadata import.
MaterialStore * materials_
Store that receives material handles during metadata import.
void setMaterialStore(MaterialStore *materials)
Sets the material store used when importing glTF primitive metadata.
std::vector< GltfRecord > gltfRecords_
Slot storage indexed by GltfHandle::index.
std::unordered_map< std::string, uint32_t > sourceToIndex_
Deduplication map from keyFor() to glTF slot index.
bool isValid(Assets::GltfRenderableHandle handle) const
Checks whether a glTF renderable handle refers to a live slot in this store.
AssetManager * assetManager_
Optional bridge retained for store wiring.
void setAssetManager(AssetManager *assetManager)
Sets the asset manager used by this store and imported child records.
std::optional< AnchorPoint > anchorPoint(Assets::GltfRenderableHandle renderable, std::string_view name) const
Looks up an AnchorPoint authored below a renderable node.
Registry store for material asset handles.
const Asset::MeshPath * path(Assets::MaterialHandle handle) const
Returns the authored material path for a material handle.
static std::string keyFor(const Asset::MeshPath &materialPath)
Builds the deduplication key for a material path and material name.
std::vector< Record > records_
Slot storage indexed by MaterialHandle::index.
MaterialStore(AssetManager *assetManager=nullptr)
Creates a material store backed by an optional asset manager.
void setAssetManager(AssetManager *assetManager)
Sets the asset manager used when new material handles request payload loading.
Assets::MaterialHandle registerRuntimeMaterial(Asset::MeshPath materialPath, std::unique_ptr< Assets::Material > material)
Registers a runtime material payload and returns its stable material handle.
std::unordered_map< std::string, uint32_t > pathToIndex_
Deduplication map from keyFor() to slot index.
bool isValid(Assets::MaterialHandle handle) const
Checks whether a material handle refers to a live slot in this store.
Assets::MaterialHandle load(const Asset::MeshPath &materialPath)
Gets or creates a stable handle for an authored material path.
AssetManager * assetManager_
Optional bridge used to request and register legacy materials.
Registry store for skin/skeleton binding handles.
Assets::SkinHandle load(const Asset::MeshPath &skinPath)
Gets or creates a stable handle for an authored skin source path.
void setAssetManager(AssetManager *assetManager)
Sets the asset manager used when new skin handles request payload loading.
static std::string keyFor(const Asset::MeshPath &skinPath)
Builds the deduplication key for a skin source path and skin name.
Assets::Skin * payload(Assets::SkinHandle handle) const
Resolves a skin handle to its loaded payload behind the manager boundary.
const Asset::MeshPath * path(Assets::SkinHandle handle) const
Returns the authored skin path for a skin handle.
AssetManager * assetManager_
Optional bridge used to request skin refs.
SkinStore(AssetManager *assetManager=nullptr)
Creates a skin store backed by an optional asset manager.
std::vector< Record > records_
Slot storage indexed by SkinHandle::index.
std::unordered_map< std::string, uint32_t > pathToIndex_
Deduplication map from keyFor() to slot index.
bool isValid(Assets::SkinHandle handle) const
Checks whether a skin handle refers to a live slot in this store.
Registry store for authored sampled 2D texture handles.
bool isValid(Assets::Texture2DHandle handle) const
Checks whether a texture handle refers to a live slot in this store.
Texture2DStore(AssetManager *assetManager=nullptr)
Creates a 2D texture store backed by an optional asset manager.
Assets::TextureType usage(Assets::Texture2DHandle handle) const
Returns the semantic usage recorded for a texture handle.
static std::string keyFor(const std::filesystem::path &source, Assets::TextureType usage)
Builds the deduplication key for a texture source path and usage.
AssetManager * assetManager_
Optional bridge used to reserve legacy texture handles.
const std::filesystem::path * sourcePath(Assets::Texture2DHandle handle) const
Returns the authored source path for a texture handle.
Assets::TextureHandle legacyHandle(Assets::Texture2DHandle handle) const
Returns the legacy runtime texture handle associated with a texture asset handle.
Assets::Texture2DHandle load(const std::filesystem::path &source, Assets::TextureType usage=Assets::TextureType::BaseColor)
Gets or creates a stable handle for an authored 2D texture source path.
void setAssetManager(AssetManager *assetManager)
Sets the asset manager used when new texture handles reserve legacy runtime handles.
std::vector< Record > records_
Slot storage indexed by Texture2DHandle::index.
std::unordered_map< std::string, uint32_t > sourceToIndex_
Deduplication map from keyFor() to slot index.
CpuLoadingState LoadState
Alias used by the asset manager and refs.
AssetHandle< GltfRenderableHandleTag > GltfRenderableHandle
Handle to one mesh-bearing node inside a glTF file.
Asset::Ref< Asset::Path, Audio > AudioAssetRef
Asset reference to decoded audio data loaded from a filesystem path.
AssetHandle< Texture2DHandleTag > Texture2DHandle
Handle to a file-backed sampled 2D texture.
AssetHandle< GltfHandleTag > GltfHandle
Handle to a glTF container file.
AssetHandle< AnimationClipHandleTag > AnimationClipHandle
Handle to an animation clip.
AssetHandle< SkinHandleTag > SkinHandle
Handle to skin binding data.
AssetHandle< GeometryMeshHandleTag > GeometryMeshHandle
Handle to non-skinned mesh geometry.
TextureType
Represents the semantic type of a texture, determining its Vulkan format.
@ BaseColor
Color data with gamma (SRGB format for 8-bit)
AssetHandle< AudioClipHandleTag > AudioClipHandle
Handle to audio clip asset data.
AssetHandle< MaterialHandleTag > MaterialHandle
Handle to a material payload.
std::unordered_map< std::string, AnchorPoint > AnchorPointMap
Lookup table from authored empty-node name to its AnchorPoint transform.
AssetLoadState
Load lifecycle state for registry-backed asset payloads.
@ Loading
Payload data is currently loading.
@ RequestedLoad
A load request has been queued but not started.
@ Loaded
Payload data is available.
@ Unloaded
No payload load is active.
@ Failed
Payload loading failed.
Identifies a named mesh-like asset inside an asset file.
Identifies a single asset file on disk.
Handle to audio clip asset data.
Handle to non-skinned mesh geometry.
Handle to a glTF container file.
Handle to one mesh-bearing node inside a glTF file.
Handle to a file-backed sampled 2D texture.
Named attachment transform authored as a direct child empty of a glTF mesh node.
glm::mat4 modelLocalTransform
Transform relative to the owning renderable node.
Stored metadata for one animation clip handle slot.
uint64_t residencyGeneration
Residency change counter reserved for streaming state.
Asset::MeshPath path
Authored source path and animation name.
uint32_t generation
Store generation used to validate handles for this slot.
uint64_t payloadGeneration
Payload change counter reserved for cache invalidation.
Stored metadata for one audio clip handle slot.
Assets::AudioAssetRef payloadRef
Legacy ref through which the decoded payload swaps in.
uint32_t generation
Store generation used to validate handles for this slot.
Asset::Path source
Engine-relative authored audio source path.
uint64_t payloadGeneration
Payload change counter reserved for cache invalidation.
uint64_t residencyGeneration
Residency change counter reserved for streaming state.
Stored metadata for one geometry mesh handle slot.
uint64_t residencyGeneration
Residency change counter reserved for streaming state.
uint32_t generation
Store generation used to validate handles for this slot.
Asset::MeshPath path
Authored source path and mesh name.
uint64_t payloadGeneration
Payload change counter reserved for cache invalidation.
Imported metadata for one renderable node inside a glTF file.
Ecs::Transform authoredTransform
Transform imported from the glTF node.
uint32_t nodeIndex
Node index in the source glTF file.
AnchorPointMap anchorPoints
Direct-child empty transforms keyed by their authored node names.
uint32_t meshIndex
Mesh index referenced by the source glTF node.
Assets::GeometryMeshHandle geometry
Geometry payload handle for the node mesh.
std::string nodeName
Authored node name, or a generated fallback for unnamed nodes.
std::vector< Assets::MaterialHandle > primitiveMaterials
Material handle per glTF primitive.
bool isStatic
True when imported metadata marks the node as static.
Assets::GltfHandle gltf
Source glTF container that owns this renderable node.
Stored metadata for one glTF source handle slot.
std::unordered_map< std::string, Assets::GltfRenderableHandle > renderablesByName
Node-name lookup table.
std::filesystem::path source
Engine-relative source glTF file path.
uint64_t payloadGeneration
Payload change counter reserved for cache invalidation.
uint32_t generation
Store generation used to validate handles for this slot.
uint64_t residencyGeneration
Residency change counter reserved for streaming state.
Stored metadata for one glTF renderable handle slot.
GltfRenderableRecord data
Imported renderable metadata exposed by get().
uint64_t residencyGeneration
Residency change counter reserved for streaming state.
uint32_t generation
Store generation used to validate handles for this slot.
uint64_t payloadGeneration
Payload change counter reserved for cache invalidation.
Stored metadata for one material handle slot.
uint32_t generation
Store generation used to validate handles for this slot.
Asset::MeshPath path
Authored source path and material name.
uint64_t residencyGeneration
Residency change counter reserved for streaming state.
uint64_t payloadGeneration
Payload change counter reserved for cache invalidation.
Stored metadata for one skin handle slot.
Asset::MeshPath path
Authored source path and skin name.
uint32_t generation
Store generation used to validate handles for this slot.
uint64_t payloadGeneration
Payload change counter reserved for cache invalidation.
uint64_t residencyGeneration
Residency change counter reserved for streaming state.
Stored metadata for one 2D texture handle slot.
uint32_t generation
Store generation used to validate handles for this slot.
uint64_t residencyGeneration
Residency change counter reserved for streaming state.
uint64_t payloadGeneration
Payload change counter reserved for cache invalidation.
Assets::TextureType usage
Semantic texture usage for descriptor registration.
std::filesystem::path source
Engine-relative authored texture source path.
Assets::TextureHandle legacyHandle
Renderer descriptor handle reserved through AssetManager.