From 8cb15ebb5da1fc825a211548d51a7e77bb981647 Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 30 Nov 2020 21:40:10 -0800 Subject: GLTF Loader: added GetFirstIndexLocation and GetBaseVertex methods --- AssetLoader/src/GLTFResourceManager.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'AssetLoader/src/GLTFResourceManager.cpp') diff --git a/AssetLoader/src/GLTFResourceManager.cpp b/AssetLoader/src/GLTFResourceManager.cpp index 54724ea..c6f627c 100644 --- a/AssetLoader/src/GLTFResourceManager.cpp +++ b/AssetLoader/src/GLTFResourceManager.cpp @@ -80,13 +80,16 @@ GLTFResourceManager::BufferAllocation GLTFResourceManager::AllocateBufferSpace(U std::lock_guard Lock{BuffCache.Mtx}; BufferAllocation Allocation; - Allocation.BufferIndex = BufferIndex; - Allocation.Region = BuffCache.Mgr.Allocate(Size, Alignment); + Allocation.Region = BuffCache.Mgr.Allocate(Size, Alignment); + if (Allocation.Region.IsValid()) + Allocation.BufferIndex = BufferIndex; return Allocation; } void GLTFResourceManager::FreeBufferSpace(BufferAllocation&& Allocation) { + VERIFY_EXPR(Allocation.IsValid()); + auto& BuffCache = m_Buffers[Allocation.BufferIndex]; std::lock_guard Lock{BuffCache.Mtx}; @@ -103,10 +106,11 @@ GLTFResourceManager::TextureAllocation GLTFResourceManager::AllocateTextureSpace std::lock_guard Lock{TexCache.Mtx}; TextureAllocation Allocation; - Allocation.TextureIndex = TextureIndex; - Allocation.Region = TexCache.Mgr.Allocate(Width, Height); + Allocation.Region = TexCache.Mgr.Allocate(Width, Height); if (!Allocation.Region.IsEmpty()) { + Allocation.TextureIndex = TextureIndex; + Allocation.Region.x *= TexCache.Granularity; Allocation.Region.y *= TexCache.Granularity; Allocation.Region.width *= TexCache.Granularity; @@ -117,6 +121,8 @@ GLTFResourceManager::TextureAllocation GLTFResourceManager::AllocateTextureSpace void GLTFResourceManager::FreeTextureSpace(TextureAllocation&& Allocation) { + VERIFY_EXPR(Allocation.IsValid()); + auto& TexCache = m_Textures[Allocation.TextureIndex]; auto& Region = Allocation.Region; -- cgit v1.2.3