From d1120ace145bb3a2b0006659c128a4162df15985 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 10 Dec 2020 21:57:10 -0800 Subject: GLTFLoader: added option to not load animation data and skin --- AssetLoader/interface/GLTFLoader.hpp | 21 +++++++++++++-------- AssetLoader/interface/GLTFResourceManager.hpp | 9 ++++++--- 2 files changed, 19 insertions(+), 11 deletions(-) (limited to 'AssetLoader/interface') diff --git a/AssetLoader/interface/GLTFLoader.hpp b/AssetLoader/interface/GLTFLoader.hpp index aba68c3..91f4aef 100644 --- a/AssetLoader/interface/GLTFLoader.hpp +++ b/AssetLoader/interface/GLTFLoader.hpp @@ -284,7 +284,7 @@ struct Animation struct Model { - struct VertexAttribs0 + struct VertexBasicAttribs { float3 pos; float3 normal; @@ -292,7 +292,7 @@ struct Model float2 uv1; }; - struct VertexAttribs1 + struct VertexSkinAttribs { float4 joint0; float4 weight0; @@ -300,8 +300,8 @@ struct Model enum BUFFER_ID { - BUFFER_ID_VERTEX0 = 0, - BUFFER_ID_VERTEX1, + BUFFER_ID_VERTEX_BASIC_ATTRIBS = 0, + BUFFER_ID_VERTEX_SKIN_ATTRIBS, BUFFER_ID_INDEX, BUFFER_ID_NUM_BUFFERS }; @@ -348,6 +348,10 @@ struct Model /// Optional resource cache usage info. ResourceCacheUseInfo* pCacheInfo = nullptr; + + /// Whether to load animation and initialize skin attributes + /// buffer. + bool LoadAnimationAndSkin = true; }; Model(IRenderDevice* pDevice, IDeviceContext* pContext, @@ -383,11 +387,11 @@ struct Model Uint32 GetBaseVertex() const { - auto& VertBuff = Buffers[BUFFER_ID_VERTEX0]; - VERIFY(!VertBuff.pSuballocation || VertBuff.pSuballocation->GetOffset() % sizeof(VertexAttribs0) == 0, + auto& VertBuff = Buffers[BUFFER_ID_VERTEX_BASIC_ATTRIBS]; + VERIFY(!VertBuff.pSuballocation || VertBuff.pSuballocation->GetOffset() % sizeof(VertexBasicAttribs) == 0, "Allocation offset is not multiple of sizeof(VertexAttribs0)"); return VertBuff.pSuballocation ? - static_cast(VertBuff.pSuballocation->GetOffset() / sizeof(VertexAttribs0)) : + static_cast(VertBuff.pSuballocation->GetOffset() / sizeof(VertexBasicAttribs)) : 0; } @@ -400,7 +404,8 @@ private: Node* parent, const tinygltf::Node& gltf_node, uint32_t nodeIndex, - const tinygltf::Model& gltf_model); + const tinygltf::Model& gltf_model, + bool LoadSkin); void LoadSkins(const tinygltf::Model& gltf_model); diff --git a/AssetLoader/interface/GLTFResourceManager.hpp b/AssetLoader/interface/GLTFResourceManager.hpp index bd3ea19..f42c975 100644 --- a/AssetLoader/interface/GLTFResourceManager.hpp +++ b/AssetLoader/interface/GLTFResourceManager.hpp @@ -82,7 +82,7 @@ public: RefCntAutoPtr FindAllocation(const char* CacheId); - Uint32 GetResourceVersion() + Uint32 GetTextureVersion() { Uint32 Version = 0; @@ -93,6 +93,11 @@ public: return Version; } + Uint32 GetBufferVersion(Uint32 Index) const + { + return m_BufferSuballocators[Index]->GetVersion(); + } + IBuffer* GetBuffer(Uint32 Index, IRenderDevice* pDevice, IDeviceContext* pContext) { return m_BufferSuballocators[Index]->GetBuffer(pDevice, pContext); @@ -131,8 +136,6 @@ private: using TexAllocationsHashMapType = std::unordered_map>; std::mutex m_TexAllocationsMtx; TexAllocationsHashMapType m_TexAllocations; - - std::atomic_uint32_t m_ResourceVersion = {}; }; } // namespace GLTF -- cgit v1.2.3