diff --git a/SHADE_Engine/src/Assets/Asset Types/Models/SHMeshAsset.h b/SHADE_Engine/src/Assets/Asset Types/Models/SHMeshAsset.h index dee88cd0..f73078a3 100644 --- a/SHADE_Engine/src/Assets/Asset Types/Models/SHMeshAsset.h +++ b/SHADE_Engine/src/Assets/Asset Types/Models/SHMeshAsset.h @@ -12,6 +12,7 @@ #include "Math/SHMath.h" #include "Assets/Asset Types/SHAssetData.h" +#include "Math/Vector/SHVec4U.h" #include #include @@ -20,11 +21,6 @@ namespace SHADE { constexpr int BONE_INDEX_ALIGHTMENT = 4; - struct IndexUInt4 - { - std::array indices; - }; - struct SHMeshDataHeader { uint32_t vertexCount; @@ -55,12 +51,12 @@ namespace SHADE struct SH_API SHMeshAsset : SHAssetData { std::string name; - std::vector VertexPositions; - std::vector VertexTangents; - std::vector VertexNormals; - std::vector VertexTexCoords; - std::vector Indices; - std::vector VertexBoneIndices; - std::vector VertexBoneWeights; + std::vector VertexPositions; + std::vector VertexTangents; + std::vector VertexNormals; + std::vector VertexTexCoords; + std::vector Indices; + std::vector VertexBoneIndices; + std::vector VertexBoneWeights; }; } diff --git a/SHADE_Engine/src/Assets/Libraries/Loaders/SHModelLoader.cpp b/SHADE_Engine/src/Assets/Libraries/Loaders/SHModelLoader.cpp index 649e6ffc..230df857 100644 --- a/SHADE_Engine/src/Assets/Libraries/Loaders/SHModelLoader.cpp +++ b/SHADE_Engine/src/Assets/Libraries/Loaders/SHModelLoader.cpp @@ -260,7 +260,7 @@ namespace SHADE { if (boneWeight[j] == 0.f) { - boneIndices.indices[j] = boneIndex; + boneIndices[j] = boneIndex; boneWeight[j] = weight.weight; } } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.cpp index b0ca7f14..658cc5fe 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.cpp @@ -168,12 +168,12 @@ namespace SHADE vertBoneIdxStorage.insert ( vertBoneIdxStorage.end(), - addJob.VertexBoneIndices, addJob.VertexBoneIndices + addJob.VertexCount * SHMesh::BONE_INDICES_PER_VERTEX + addJob.VertexBoneIndices, addJob.VertexBoneIndices + addJob.VertexCount ); } else { - vertBoneIdxStorage.resize(vertBoneIdxStorage.size() + addJob.VertexCount * SHMesh::BONE_INDICES_PER_VERTEX); + vertBoneIdxStorage.resize(vertBoneIdxStorage.size() + addJob.VertexCount); } if (addJob.VertexBoneWeights) { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.h index 5e42c526..39b669b8 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.h @@ -20,6 +20,7 @@ of DigiPen Institute of Technology is prohibited. #include "Math/Vector/SHVec2.h" #include "Math/Vector/SHVec3.h" #include "Math/Vector/SHVec4.h" +#include "Math/Vector/SHVec4U.h" namespace SHADE { @@ -50,14 +51,9 @@ namespace SHADE using VertexTexCoord = SHVec2; using VertexTangent = SHVec3; using VertexNormal = SHVec3; - using VertexBoneIndices = int; + using VertexBoneIndices = SHVec4U; using VertexWeights = SHVec4; - /*-----------------------------------------------------------------------------*/ - /* Constants */ - /*-----------------------------------------------------------------------------*/ - static constexpr size_t BONE_INDICES_PER_VERTEX = 4; - /*-----------------------------------------------------------------------------*/ /* Data Members */ /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Math/Vector/SHVec4U.h b/SHADE_Engine/src/Math/Vector/SHVec4U.h new file mode 100644 index 00000000..40eec94f --- /dev/null +++ b/SHADE_Engine/src/Math/Vector/SHVec4U.h @@ -0,0 +1,23 @@ +/************************************************************************************//*! +\file SHVec4U.h +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Jan 16, 2023 +\brief Contains type alias for SHVec4U. + +Copyright (C) 2023 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +#pragma once + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Type Definitions */ + /*-----------------------------------------------------------------------------------*/ + /// + /// Simple type alias for a array of uint32_t of 4 uint32_ts. + /// + using SHVec4U = std::array; +} \ No newline at end of file