Merge remote-tracking branch 'origin/SP3-1-Rendering' into SP3-1-Rendering

This commit is contained in:
Brandon Mak 2022-09-09 11:20:46 +08:00
commit cce1d24374
4 changed files with 9 additions and 9 deletions

View File

@ -139,7 +139,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Data Members */ /* Data Members */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
ResourceLibrary<T>* library; ResourceLibrary<T>* library = nullptr;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Friend Declarations */ /* Friend Declarations */

View File

@ -69,7 +69,7 @@ namespace SHADE
/* Helper Functions */ /* Helper Functions */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
void assertHandleValid(Handle<T> handle) const; void assertHandleValid(Handle<T> handle) const;
int getAvailableFreeIndex(); uint32_t getAvailableFreeIndex();
}; };
/// <summary> /// <summary>

View File

@ -35,13 +35,13 @@ namespace SHADE
} }
else else
{ {
handle.id.Data.Version = 0; handle.id.Data.Version = 0U;
versionCounts.insert(handle.id.Data.Index, handle.id.Data.Version); versionCounts.insert(static_cast<uint32_t>(handle.id.Data.Index), handle.id.Data.Version);
} }
handle.library = this; handle.library = this;
// Create the resource // Create the resource
[[maybe_unused]] T& obj = objects.insert(handle.id.Data.Index, std::forward<Args>(args) ...); [[maybe_unused]] T& obj = objects.insert(static_cast<uint32_t>(handle.id.Data.Index), std::forward<Args>(args) ...);
// Handling SelfHandle assignment // Handling SelfHandle assignment
if constexpr (std::is_base_of_v<ISelfHandle<T>, T>) if constexpr (std::is_base_of_v<ISelfHandle<T>, T>)
@ -89,7 +89,7 @@ namespace SHADE
} }
template<typename T> template<typename T>
inline int ResourceLibrary<T>::getAvailableFreeIndex() inline uint32_t ResourceLibrary<T>::getAvailableFreeIndex()
{ {
// Get from the free list if present // Get from the free list if present
if (!freeList.empty()) if (!freeList.empty())

View File

@ -56,7 +56,7 @@ namespace SHADE
throw std::invalid_argument("An element at this index does not exist!"); throw std::invalid_argument("An element at this index does not exist!");
// Swap with the last element // Swap with the last element
const int BACK_IDX = denseArray.size() - 1; const auto BACK_IDX = denseArray.size() - 1;
std::swap(denseArray[sparseArray[idx]], denseArray.back()); std::swap(denseArray[sparseArray[idx]], denseArray.back());
denseArray.pop_back(); denseArray.pop_back();
// Update the sparse set by swapping the indices // Update the sparse set by swapping the indices
@ -110,7 +110,7 @@ namespace SHADE
// We need to resize the array // We need to resize the array
if (idx >= sparseArray.size()) if (idx >= sparseArray.size())
{ {
const int NEW_SIZE = idx + 1; const auto NEW_SIZE = idx + 1;
sparseArray.resize(NEW_SIZE, INVALID); sparseArray.resize(NEW_SIZE, INVALID);
inverseSparseArray.resize(NEW_SIZE, INVALID); inverseSparseArray.resize(NEW_SIZE, INVALID);
} }
@ -123,7 +123,7 @@ namespace SHADE
auto& insertedElem = denseArray.emplace_back(std::forward<Args>(args) ...); auto& insertedElem = denseArray.emplace_back(std::forward<Args>(args) ...);
// Update sparse and inverse sparse arrays // Update sparse and inverse sparse arrays
const index_type DENSE_IDX = denseArray.size() - 1; const auto DENSE_IDX = denseArray.size() - 1;
sparseArray[idx] = DENSE_IDX; sparseArray[idx] = DENSE_IDX;
inverseSparseArray[DENSE_IDX] = idx; inverseSparseArray[DENSE_IDX] = idx;