2626
2727#pragma once
2828
29- #include " Assets/RadientMorphTargetData.hpp"
3029#include " Render/RadientDrawableMesh.hpp"
3130#include " RadientAssetCache.hpp"
3231#include " RadientAssets.h"
@@ -48,8 +47,10 @@ class ResourceManager;
4847
4948class RadientMeshIndexSource ;
5049class RadientMeshVertexSource ;
50+ class RadientMorphTargetSource ;
5151class MeshIndexDataPayloadImpl ;
5252class MeshVertexDataPayloadImpl ;
53+ class MeshMorphTargetDataPayloadImpl ;
5354class MeshPayloadImpl ;
5455class RadientMeshAssetManager ;
5556struct RadientMeshViewCreateInfo ;
@@ -68,11 +69,19 @@ class IRadientMeshVertexData : public IRadientAsset
6869{
6970};
7071
72+ // Opaque handle to shared mesh morph-target data. The implementation details
73+ // are private to RadientMeshAssetManager.
74+ class IRadientMeshMorphTargetData : public IRadientAsset
75+ {
76+ };
77+
7178struct RadientMeshGeometryData
7279{
73- // / Vertex and index data that together form one drawable geometry.
74- IRadientMeshVertexData* pVertexData = nullptr ;
75- IRadientMeshIndexData* pIndexData = nullptr ;
80+ // / Vertex, index, and optional morph-target data that together form one
81+ // / drawable geometry. Morph-target deltas use the vertex data's domain.
82+ IRadientMeshVertexData* pVertexData = nullptr ;
83+ IRadientMeshIndexData* pIndexData = nullptr ;
84+ IRadientMeshMorphTargetData* pMorphTargetData = nullptr ;
7685};
7786
7887class RadientMeshAssetManager final : public std::enable_shared_from_this<RadientMeshAssetManager>
@@ -101,15 +110,18 @@ class RadientMeshAssetManager final : public std::enable_shared_from_this<Radien
101110 std::unique_ptr<RadientMeshVertexSource> pVertexSource,
102111 IRadientMeshVertexData** ppVertexData);
103112
113+ RADIENT_STATUS CreateMeshMorphTargetData (IThreadPool& ThreadPool,
114+ std::unique_ptr<RadientMorphTargetSource> pMorphTargetSource,
115+ IRadientMeshMorphTargetData** ppMorphTargetData);
116+
104117 // Creates a mesh handle and schedules mesh-view payload creation. When
105118 // vertex or index data is still loading, the view task depends on the
106119 // corresponding data tasks if they are still available.
107- RADIENT_STATUS CreateMeshView (IThreadPool& ThreadPool,
108- const RadientMeshGeometryData* pGeometryData,
109- Uint32 GeometryCount,
110- const RadientMeshViewCreateInfo& ViewCI,
111- IRadientMeshAsset** ppMesh,
112- std::unique_ptr<RadientMorphTargetData> pMorphTargetData = nullptr );
120+ RADIENT_STATUS CreateMeshView (IThreadPool& ThreadPool,
121+ const RadientMeshGeometryData* pGeometryData,
122+ Uint32 GeometryCount,
123+ const RadientMeshViewCreateInfo& ViewCI,
124+ IRadientMeshAsset** ppMesh);
113125
114126 // Returns drawable mesh data when the mesh asset is ready. A pending status
115127 // means that any mesh dependency may still be unresolved: source/view
@@ -127,18 +139,19 @@ class RadientMeshAssetManager final : public std::enable_shared_from_this<Radien
127139 static RADIENT_STATUS GetLoadStatus (IRadientMeshIndexData* pMeshIndexData);
128140 // Reports CPU-side mesh data readiness for shared mesh vertex data handles.
129141 static RADIENT_STATUS GetLoadStatus (IRadientMeshVertexData* pMeshVertexData);
142+ // Reports CPU-side mesh data readiness for shared morph-target data handles.
143+ static RADIENT_STATUS GetLoadStatus (IRadientMeshMorphTargetData* pMorphTargetData);
130144
131145 // Reports render-resource readiness. This follows GetLoadStatus(), then
132146 // checks geometry GPU resources and material/texture GPU resources.
133- static RADIENT_STATUS GetGPUResourceStatus (IRadientAsset* pMeshAsset);
134- static const MeshPayloadImpl* GetMeshPayload (IRadientMeshAsset* pMeshAsset);
135- static Uint32 GetMeshGeometryCount (IRadientMeshAsset* pMeshAsset);
136- static const MeshIndexDataPayloadImpl* GetMeshIndexDataPayload (IRadientMeshAsset* pMeshAsset, Uint32 GeometryIndex);
137- static const MeshVertexDataPayloadImpl* GetMeshVertexDataPayload (IRadientMeshAsset* pMeshAsset, Uint32 GeometryIndex);
138- static const IRadientMeshIndexData* GetMeshIndexData (IRadientMeshAsset* pMeshAsset);
139- static const IRadientMeshVertexData* GetMeshVertexData (IRadientMeshAsset* pMeshAsset);
140- // Returns packed morph deltas for a ready mesh asset.
141- static const RadientMorphTargetData* GetMorphTargetData (IRadientMeshAsset* pMeshAsset);
147+ static RADIENT_STATUS GetGPUResourceStatus (IRadientAsset* pMeshAsset);
148+ static const MeshPayloadImpl* GetMeshPayload (IRadientMeshAsset* pMeshAsset);
149+ static Uint32 GetMeshGeometryCount (IRadientMeshAsset* pMeshAsset);
150+ static const MeshIndexDataPayloadImpl* GetMeshIndexDataPayload (IRadientMeshAsset* pMeshAsset, Uint32 GeometryIndex);
151+ static const MeshVertexDataPayloadImpl* GetMeshVertexDataPayload (IRadientMeshAsset* pMeshAsset, Uint32 GeometryIndex);
152+ static const MeshMorphTargetDataPayloadImpl* GetMeshMorphTargetDataPayload (IRadientMeshAsset* pMeshAsset, Uint32 GeometryIndex);
153+ static const IRadientMeshIndexData* GetMeshIndexData (IRadientMeshAsset* pMeshAsset);
154+ static const IRadientMeshVertexData* GetMeshVertexData (IRadientMeshAsset* pMeshAsset);
142155
143156private:
144157 explicit RadientMeshAssetManager (const CreateInfo& CI );
@@ -147,9 +160,10 @@ class RadientMeshAssetManager final : public std::enable_shared_from_this<Radien
147160 RefCntWeakPtr<GLTF ::ResourceManager> m_WeakResourceManager;
148161 RefCntWeakPtr<IGPUUploadManager> m_WeakUploadManager;
149162
150- RadientAssetCache<MeshPayloadImpl> m_MeshCache;
151- RadientAssetCache<MeshIndexDataPayloadImpl> m_MeshIndexDataCache;
152- RadientAssetCache<MeshVertexDataPayloadImpl> m_MeshVertexDataCache;
163+ RadientAssetCache<MeshPayloadImpl> m_MeshCache;
164+ RadientAssetCache<MeshIndexDataPayloadImpl> m_MeshIndexDataCache;
165+ RadientAssetCache<MeshVertexDataPayloadImpl> m_MeshVertexDataCache;
166+ RadientAssetCache<MeshMorphTargetDataPayloadImpl> m_MeshMorphTargetDataCache;
153167};
154168
155169} // namespace Diligent
0 commit comments