diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AnimGraphTriggerActionCommands.cpp b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AnimGraphTriggerActionCommands.cpp index 8b04a80085..d5f43348f6 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AnimGraphTriggerActionCommands.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AnimGraphTriggerActionCommands.cpp @@ -58,7 +58,7 @@ namespace CommandSystem CommandAnimGraphAddTransitionAction::CommandAnimGraphAddTransitionAction(MCore::Command* orgCommand) : MCore::Command(s_commandName, orgCommand) - , m_oldActionIndex(MCORE_INVALIDINDEX32) + , m_oldActionIndex(InvalidIndex) { } @@ -105,14 +105,14 @@ namespace CommandSystem } // get the location where to add the new action - size_t insertAt = MCORE_INVALIDINDEX32; + size_t insertAt = InvalidIndex; if (parameters.CheckIfHasParameter("insertAt")) { insertAt = parameters.GetValueAsInt("insertAt", this); } // add it to the transition - if (insertAt == MCORE_INVALIDINDEX32) + if (insertAt == InvalidIndex) { actionSetup.AddAction(newAction); } @@ -214,7 +214,7 @@ namespace CommandSystem : MCore::Command(s_commandName, orgCommand) { m_oldActionType = AZ::TypeId::CreateNull(); - m_oldActionIndex = MCORE_INVALIDINDEX32; + m_oldActionIndex = InvalidIndex; } bool CommandAnimGraphRemoveTransitionAction::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult) @@ -331,7 +331,7 @@ namespace CommandSystem CommandAnimGraphAddStateAction::CommandAnimGraphAddStateAction(MCore::Command* orgCommand) : MCore::Command(s_commandName, orgCommand) - , m_oldActionIndex(MCORE_INVALIDINDEX32) + , m_oldActionIndex(InvalidIndex) { } @@ -385,14 +385,14 @@ namespace CommandSystem } // get the location where to add the new action - size_t insertAt = MCORE_INVALIDINDEX32; + size_t insertAt = InvalidIndex; if (parameters.CheckIfHasParameter("insertAt")) { insertAt = parameters.GetValueAsInt("insertAt", this); } // add it to the transition - if (insertAt == MCORE_INVALIDINDEX32) + if (insertAt == InvalidIndex) { actionSetup.AddAction(newAction); } @@ -501,7 +501,7 @@ namespace CommandSystem : MCore::Command(s_commandName, orgCommand) { m_oldActionType = AZ::TypeId::CreateNull(); - m_oldActionIndex = MCORE_INVALIDINDEX32; + m_oldActionIndex = InvalidIndex; } bool CommandAnimGraphRemoveStateAction::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult) diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/MotionEventCommands.cpp b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/MotionEventCommands.cpp index 76ba6f37b7..e4b8d38147 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/MotionEventCommands.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/MotionEventCommands.cpp @@ -293,7 +293,7 @@ namespace CommandSystem CommandRemoveMotionEventTrack::CommandRemoveMotionEventTrack(MCore::Command* orgCommand) : MCore::Command("RemoveMotionEventTrack", orgCommand) { - mOldTrackIndex = MCORE_INVALIDINDEX32; + mOldTrackIndex = InvalidIndex; } @@ -586,9 +586,9 @@ namespace CommandSystem } // add the motion event and check if everything worked fine - mMotionEventNr = eventTrack->AddEvent(m_startTime, m_endTime, AZStd::move(m_eventDatas.value_or(EMotionFX::EventDataSet()))); + mMotionEventNr = eventTrack->AddEvent(m_startTime, m_endTime, m_eventDatas.value_or(EMotionFX::EventDataSet())); - if (mMotionEventNr == MCORE_INVALIDINDEX32) + if (mMotionEventNr == InvalidIndex) { outResult = AZStd::string::format("Cannot create motion event. The returned motion event index is not valid."); return false; diff --git a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/EndianConversion.cpp b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/EndianConversion.cpp index a513710c83..153ec6e701 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/EndianConversion.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/EndianConversion.cpp @@ -88,6 +88,11 @@ namespace ExporterLib MCore::Endian::ConvertUnsignedInt32(value, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } + void ConvertUnsignedInt(uint64* value, MCore::Endian::EEndianType targetEndianType) + { + MCore::Endian::ConvertUnsignedInt64(value, EXPLIB_PLATFORM_ENDIAN, targetEndianType); + } + void ConvertInt(int* value, MCore::Endian::EEndianType targetEndianType) { diff --git a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/Exporter.h b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/Exporter.h index 09c0646509..290f9d4470 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/Exporter.h +++ b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/Exporter.h @@ -57,6 +57,7 @@ namespace ExporterLib // endian conversion void ConvertUnsignedInt(uint32* value, MCore::Endian::EEndianType targetEndianType); + void ConvertUnsignedInt(uint64* value, MCore::Endian::EEndianType targetEndianType); void ConvertInt(int* value, MCore::Endian::EEndianType targetEndianType); void ConvertUnsignedShort(uint16* value, MCore::Endian::EEndianType targetEndianType); void ConvertFloat(float* value, MCore::Endian::EEndianType targetEndianType); @@ -113,7 +114,7 @@ namespace ExporterLib // actors const char* GetActorExtension(bool includingDot = true); void SaveActorHeader(MCore::Stream* file, MCore::Endian::EEndianType targetEndianType); - void SaveActorFileInfo(MCore::Stream* file, uint32 numLODLevels, uint32 motionExtractionNodeIndex, uint32 retargetRootNodeIndex, const char* sourceApp, const char* orgFileName, const char* actorName, MCore::Distance::EUnitType unitType, MCore::Endian::EEndianType targetEndianType, bool optimizeSkeleton); + void SaveActorFileInfo(MCore::Stream* file, uint64 numLODLevels, uint64 motionExtractionNodeIndex, uint64 retargetRootNodeIndex, const char* sourceApp, const char* orgFileName, const char* actorName, MCore::Distance::EUnitType unitType, MCore::Endian::EEndianType targetEndianType, bool optimizeSkeleton); void SaveActor(MCore::MemoryFile* file, const EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType, const AZStd::optional meshAssetId = AZStd::nullopt); bool SaveActor(AZStd::string& filename, const EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType, const AZStd::optional meshAssetId = AZStd::nullopt); diff --git a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/FileHeaderExport.cpp b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/FileHeaderExport.cpp index 5a7f8d13e0..bafc899d4e 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/FileHeaderExport.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/FileHeaderExport.cpp @@ -38,9 +38,9 @@ namespace ExporterLib void SaveActorFileInfo(MCore::Stream* file, - uint32 numLODLevels, - uint32 motionExtractionNodeIndex, - uint32 retargetRootNodeIndex, + uint64 numLODLevels, + uint64 motionExtractionNodeIndex, + uint64 retargetRootNodeIndex, const char* sourceApp, const char* orgFileName, const char* actorName, @@ -62,9 +62,9 @@ namespace ExporterLib EMotionFX::FileFormat::Actor_Info3 infoChunk; memset(&infoChunk, 0, sizeof(EMotionFX::FileFormat::Actor_Info3)); - infoChunk.mNumLODs = numLODLevels; - infoChunk.mMotionExtractionNodeIndex = motionExtractionNodeIndex; - infoChunk.mRetargetRootNodeIndex = retargetRootNodeIndex; + infoChunk.mNumLODs = aznumeric_caster(numLODLevels); + infoChunk.mMotionExtractionNodeIndex = aznumeric_caster(motionExtractionNodeIndex); + infoChunk.mRetargetRootNodeIndex = aznumeric_caster(retargetRootNodeIndex); infoChunk.mExporterHighVersion = static_cast(EMotionFX::GetEMotionFX().GetHighVersion()); infoChunk.mExporterLowVersion = static_cast(EMotionFX::GetEMotionFX().GetLowVersion()); infoChunk.mUnitType = static_cast(unitType); diff --git a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/MorphTargetExport.cpp b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/MorphTargetExport.cpp index b2d88295b4..eefa92f21d 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/MorphTargetExport.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/MorphTargetExport.cpp @@ -168,7 +168,7 @@ namespace ExporterLib { // rename the morph target AZStd::string morphTargetName; - morphTargetName = AZStd::string::format("Morph Target %d", MCore::GetIDGenerator().GenerateID()); + morphTargetName = AZStd::string::format("Morph Target %zu", MCore::GetIDGenerator().GenerateID()); MCore::LogWarning("The morph target has an empty name. The morph target will be automatically renamed to '%s'.", morphTargetName.c_str()); morphTarget->SetName(morphTargetName.c_str()); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLActor.cpp b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLActor.cpp index 7a78b5749d..5a7d2032a7 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLActor.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLActor.cpp @@ -113,8 +113,8 @@ namespace RenderGL mTexturePath = texturePath; // get the number of nodes and geometry LOD levels - const uint32 numGeometryLODLevels = actor->GetNumLODLevels(); - const uint32 numNodes = actor->GetNumNodes(); + const size_t numGeometryLODLevels = actor->GetNumLODLevels(); + const size_t numNodes = actor->GetNumNodes(); // set the pre-allocation amount for the number of materials mMaterials.resize(numGeometryLODLevels); @@ -149,7 +149,7 @@ namespace RenderGL uint32 totalNumIndices[3] = { 0, 0, 0 }; // iterate through all nodes - for (uint32 n = 0; n < numNodes; ++n) + for (size_t n = 0; n < numNodes; ++n) { // get the current node EMotionFX::Node* node = skeleton->GetNode(n); @@ -171,7 +171,7 @@ namespace RenderGL EMotionFX::Mesh::EMeshType meshType = ClassifyMeshType(node, mesh, lodLevel); // get the number of submeshes and iterate through them - const uint32 numSubMeshes = mesh->GetNumSubMeshes(); + const size_t numSubMeshes = mesh->GetNumSubMeshes(); for (uint32 s = 0; s < numSubMeshes; ++s) { // get the current submesh @@ -278,7 +278,7 @@ namespace RenderGL for (uint32 lodLevel = 0; lodLevel < numGeometryLODLevels; ++lodLevel) { // iterate through all nodes - for (uint32 n = 0; n < numNodes; ++n) + for (size_t n = 0; n < numNodes; ++n) { // get the current node EMotionFX::Node* node = skeleton->GetNode(n); @@ -577,8 +577,8 @@ namespace RenderGL EMotionFX::Skeleton* skeleton = mActor->GetSkeleton(); // get the number of nodes and iterate through them - const uint32 numNodes = mActor->GetNumNodes(); - for (uint32 n = 0; n < numNodes; ++n) + const size_t numNodes = mActor->GetNumNodes(); + for (size_t n = 0; n < numNodes; ++n) { // get the current node EMotionFX::Node* node = skeleton->GetNode(n); @@ -703,7 +703,7 @@ namespace RenderGL } // get the number of nodes - const uint32 numNodes = mActor->GetNumNodes(); + const size_t numNodes = mActor->GetNumNodes(); if (numNodes == 0) { return; @@ -722,7 +722,7 @@ namespace RenderGL uint32 globalVert = 0; // iterate through all nodes - for (uint32 n = 0; n < numNodes; ++n) + for (size_t n = 0; n < numNodes; ++n) { // get the current node EMotionFX::Node* node = skeleton->GetNode(n); @@ -793,7 +793,7 @@ namespace RenderGL } // get the number of dynamic nodes - const uint32 numNodes = mActor->GetNumNodes(); + const size_t numNodes = mActor->GetNumNodes(); if (numNodes == 0) { return; @@ -812,7 +812,7 @@ namespace RenderGL uint32 globalVert = 0; // iterate through all nodes - for (uint32 n = 0; n < numNodes; ++n) + for (size_t n = 0; n < numNodes; ++n) { // get the current node EMotionFX::Node* node = skeleton->GetNode(n); diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Material.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Material.h index ed5ab18609..9c0522a6da 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Material.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Material.h @@ -29,18 +29,18 @@ namespace RenderGL mNumTriangles = 0; mNumVertices = 0; - mNodeIndex = MCORE_INVALIDINDEX32; + mNodeIndex = InvalidIndex; mMaterialIndex = MCORE_INVALIDINDEX32; } - uint32 mNodeIndex; /**< The index of the node to which this primitive belongs to. */ + size_t mNodeIndex; /**< The index of the node to which this primitive belongs to. */ uint32 mVertexOffset; uint32 mIndexOffset; /**< The starting index. */ uint32 mNumTriangles; /**< The number of triangles in the primitive. */ uint32 mNumVertices; /**< The number of vertices in the primitive. */ uint32 mMaterialIndex; /**< The material index which is mapped to the primitive. */ - AZStd::vector mBoneNodeIndices;/**< Mapping from local bones 0-50 to nodes. */ + AZStd::vector mBoneNodeIndices;/**< Mapping from local bones 0-50 to nodes. */ }; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp index 541ab65071..d8377f2d0e 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp @@ -75,8 +75,8 @@ namespace EMotionFX mSkeleton = Skeleton::Create(); - mMotionExtractionNode = MCORE_INVALIDINDEX32; - mRetargetRootNode = MCORE_INVALIDINDEX32; + mMotionExtractionNode = InvalidIndex; + mRetargetRootNode = InvalidIndex; mThreadIndex = 0; mCustomData = nullptr; mID = MCore::GetIDGenerator().GenerateID(); @@ -172,7 +172,7 @@ namespace EMotionFX result->mSkeleton = mSkeleton->Clone(); // clone lod data - const uint32 numNodes = mSkeleton->GetNumNodes(); + const size_t numNodes = mSkeleton->GetNumNodes(); const size_t numLodLevels = m_meshLodData.m_lodLevels.size(); MeshLODData& resultMeshLodData = result->m_meshLodData; @@ -184,7 +184,7 @@ namespace EMotionFX AZStd::vector& resultNodeInfos = resultMeshLodData.m_lodLevels[lodLevel].mNodeInfos; resultNodeInfos.resize(numNodes); - for (uint32 n = 0; n < numNodes; ++n) + for (size_t n = 0; n < numNodes; ++n) { NodeLODInfo& resultNodeInfo = resultNodeInfos[n]; const NodeLODInfo& sourceNodeInfo = nodeInfos[n]; @@ -230,11 +230,11 @@ namespace EMotionFX // init node mirror info void Actor::AllocateNodeMirrorInfos() { - const uint32 numNodes = mSkeleton->GetNumNodes(); + const size_t numNodes = mSkeleton->GetNumNodes(); mNodeMirrorInfos.resize(numNodes); // init the data - for (uint32 i = 0; i < numNodes; ++i) + for (size_t i = 0; i < numNodes; ++i) { mNodeMirrorInfos[i].mSourceNode = static_cast(i); mNodeMirrorInfos[i].mAxis = MCORE_INVALIDINDEX8; @@ -253,20 +253,15 @@ namespace EMotionFX // check if we have our axes detected bool Actor::GetHasMirrorAxesDetected() const { - if (mNodeMirrorInfos.size() == 0) + if (mNodeMirrorInfos.empty()) { return false; } - for (uint32 i = 0; i < mNodeMirrorInfos.size(); ++i) + return AZStd::all_of(begin(mNodeMirrorInfos), end(mNodeMirrorInfos), [](const NodeMirrorInfo& nodeMirrorInfo) { - if (mNodeMirrorInfos[i].mAxis == MCORE_INVALIDINDEX8) - { - return false; - } - } - - return true; + return nodeMirrorInfo.mAxis != MCORE_INVALIDINDEX8; + }); } @@ -274,13 +269,12 @@ namespace EMotionFX void Actor::RemoveAllMaterials() { // for all LODs - for (uint32 i = 0; i < mMaterials.size(); ++i) + for (AZStd::vector& mMaterial : mMaterials) { // delete all materials - const uint32 numMats = mMaterials[i].size(); - for (uint32 m = 0; m < numMats; ++m) + for (Material* m : mMaterial) { - mMaterials[i][m]->Destroy(); + m->Destroy(); } } @@ -295,7 +289,7 @@ namespace EMotionFX lodLevels.emplace_back(); LODLevel& newLOD = lodLevels.back(); - const uint32 numNodes = mSkeleton->GetNumNodes(); + const size_t numNodes = mSkeleton->GetNumNodes(); newLOD.mNodeInfos.resize(numNodes); const size_t numLODs = lodLevels.size(); @@ -339,11 +333,11 @@ namespace EMotionFX lodLevels.emplace(lodLevels.begin()+insertAt); LODLevel& newLOD = lodLevels[insertAt]; const uint32 lodIndex = insertAt; - const uint32 numNodes = mSkeleton->GetNumNodes(); + const size_t numNodes = mSkeleton->GetNumNodes(); newLOD.mNodeInfos.resize(numNodes); // get the number of nodes, iterate through them, create a new LOD level and copy over the meshes from the last LOD level - for (uint32 i = 0; i < numNodes; ++i) + for (size_t i = 0; i < numNodes; ++i) { NodeLODInfo& lodInfo = lodLevels[lodIndex].mNodeInfos[i]; lodInfo.mMesh = nullptr; @@ -366,8 +360,8 @@ namespace EMotionFX const LODLevel& sourceLOD = copyLodLevels[copyLODLevel]; LODLevel& targetLOD = lodLevels[replaceLODLevel]; - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Node* node = mSkeleton->GetNode(i); Node* copyNode = copyActor->GetSkeleton()->FindNodeByID(node->GetID()); @@ -410,14 +404,14 @@ namespace EMotionFX } // copy the materials - const uint32 numMaterials = copyActor->GetNumMaterials(copyLODLevel); - for (uint32 i = 0; i < mMaterials[replaceLODLevel].size(); ++i) + const size_t numMaterials = copyActor->GetNumMaterials(copyLODLevel); + for (Material* i : mMaterials[replaceLODLevel]) { - mMaterials[replaceLODLevel][i]->Destroy(); + i->Destroy(); } mMaterials[replaceLODLevel].clear(); mMaterials[replaceLODLevel].reserve(numMaterials); - for (uint32 i = 0; i < numMaterials; ++i) + for (size_t i = 0; i < numMaterials; ++i) { AddMaterial(replaceLODLevel, copyActor->GetMaterial(copyLODLevel, i)->Clone()); } @@ -449,22 +443,19 @@ namespace EMotionFX if (adjustMorphSetup) { mMorphSetups.resize(numLODs); - for (uint32 i = 0; i < numLODs; ++i) - { - mMorphSetups[i] = nullptr; - } + AZStd::fill(begin(mMorphSetups), AZStd::next(begin(mMorphSetups), numLODs), nullptr); } } // removes all node meshes and stacks void Actor::RemoveAllNodeMeshes() { - const uint32 numNodes = mSkeleton->GetNumNodes(); + const size_t numNodes = mSkeleton->GetNumNodes(); AZStd::vector& lodLevels = m_meshLodData.m_lodLevels; for (LODLevel& lodLevel : lodLevels) { - for (uint32 i = 0; i < numNodes; ++i) + for (size_t i = 0; i < numNodes; ++i) { NodeLODInfo& info = lodLevel.mNodeInfos[i]; MCore::Destroy(info.mMesh); @@ -482,8 +473,8 @@ namespace EMotionFX uint32 totalVerts = 0; uint32 totalIndices = 0; - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Mesh* mesh = GetMesh(lodLevel, i); if (!mesh) @@ -520,8 +511,8 @@ namespace EMotionFX uint32 totalIndices = 0; // for all nodes - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Mesh* mesh = GetMesh(lodLevel, i); @@ -564,8 +555,8 @@ namespace EMotionFX uint32 totalIndices = 0; // for all nodes - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Mesh* mesh = GetMesh(lodLevel, i); @@ -605,8 +596,8 @@ namespace EMotionFX { uint32 maxInfluences = 0; - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Mesh* mesh = GetMesh(lodLevel, i); if (!mesh) @@ -627,7 +618,7 @@ namespace EMotionFX uint32 n; // get the number of nodes - const uint32 numNodes = mSkeleton->GetNumNodes(); + const size_t numNodes = mSkeleton->GetNumNodes(); // check if the conflict node flag array's size is set to the number of nodes inside the actor if (conflictNodeFlags.size() != numNodes) @@ -694,8 +685,8 @@ namespace EMotionFX // Get the vertex counts for the influences. (e.g. 500 vertices have 1 skinning influence, 300 vertices have 2 skinning influences etc.) AZStd::vector meshVertexCounts; - const uint32 numNodes = GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Mesh* mesh = GetMesh(lodLevel, i); if (!mesh) @@ -716,11 +707,11 @@ namespace EMotionFX } // check if there is any mesh available - bool Actor::CheckIfHasMeshes(uint32 lodLevel) const + bool Actor::CheckIfHasMeshes(size_t lodLevel) const { // check if any of the nodes has a mesh - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { if (GetMesh(lodLevel, i)) { @@ -735,8 +726,8 @@ namespace EMotionFX bool Actor::CheckIfHasSkinnedMeshes(AZ::u32 lodLevel) const { - const AZ::u32 numNodes = mSkeleton->GetNumNodes(); - for (AZ::u32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { const Mesh* mesh = GetMesh(lodLevel, i); if (mesh && mesh->FindSharedVertexAttributeLayer(SkinningInfoVertexAttributeLayer::TYPE_ID)) @@ -768,13 +759,11 @@ namespace EMotionFX // remove all morph setups void Actor::RemoveAllMorphSetups(bool deleteMeshDeformers) { - uint32 i; - // get the number of lod levels - const uint32 numLODs = GetNumLODLevels(); + const size_t numLODs = GetNumLODLevels(); // for all LODs, get rid of all the morph setups for each geometry LOD - for (i = 0; i < mMorphSetups.size(); ++i) + for (uint32 i = 0; i < mMorphSetups.size(); ++i) { if (mMorphSetups[i]) { @@ -788,8 +777,8 @@ namespace EMotionFX if (deleteMeshDeformers) { // for all nodes - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { // process all LOD levels for (uint32 lod = 0; lod < numLODs; ++lod) @@ -825,8 +814,8 @@ namespace EMotionFX } // iterate through the submeshes - const uint32 numSubMeshes = mesh->GetNumSubMeshes(); - for (uint32 s = 0; s < numSubMeshes; ++s) + const size_t numSubMeshes = mesh->GetNumSubMeshes(); + for (size_t s = 0; s < numSubMeshes; ++s) { // if the submesh material index is the same as the material index we search for, then it is being used if (mesh->GetSubMesh(s)->GetMaterial() == materialIndex) @@ -843,18 +832,14 @@ namespace EMotionFX bool Actor::CheckIfIsMaterialUsed(uint32 lodLevel, uint32 index) const { // iterate through all nodes of the actor and check its meshes - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { // if the mesh is in LOD range check if it uses the material if (CheckIfIsMaterialUsed(GetMesh(lodLevel, i), index)) { return true; } - - // same for the collision mesh - //if (CheckIfIsMaterialUsed( GetCollisionMesh(lodLevel, i), index )) - //return true; } // return false, this means that no mesh uses the given material @@ -883,14 +868,14 @@ namespace EMotionFX uint32 maxNumChilds = 0; // traverse through all root nodes - const uint32 numRootNodes = mSkeleton->GetNumRootNodes(); - for (uint32 i = 0; i < numRootNodes; ++i) + const size_t numRootNodes = mSkeleton->GetNumRootNodes(); + for (size_t i = 0; i < numRootNodes; ++i) { // get the given root node from the actor Node* rootNode = mSkeleton->GetNode(mSkeleton->GetRootNodeIndex(i)); // get the number of child nodes recursively - const uint32 numChildNodes = rootNode->GetNumChildNodesRecursive(); + const size_t numChildNodes = rootNode->GetNumChildNodesRecursive(); // if the number of child nodes of this node is bigger than the current max number // this is our new candidate for the repositioning node @@ -919,8 +904,8 @@ namespace EMotionFX outBoneList->clear(); // for all nodes - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 n = 0; n < numNodes; ++n) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t n = 0; n < numNodes; ++n) { Mesh* mesh = GetMesh(lodLevel, n); @@ -946,7 +931,7 @@ namespace EMotionFX for (uint32 i = 0; i < numInfluences; ++i) { // get the node number of the bone - uint32 nodeNr = skinningLayer->GetInfluence(v, i)->GetNodeNr(); + uint16 nodeNr = skinningLayer->GetInfluence(v, i)->GetNodeNr(); // check if it is already in the bone list, if not, add it if (AZStd::find(begin(*outBoneList), end(*outBoneList), nodeNr) == end(*outBoneList)) @@ -963,8 +948,8 @@ namespace EMotionFX void Actor::RecursiveAddDependencies(const Actor* actor) { // process all dependencies of the given actor - const uint32 numDependencies = actor->GetNumDependencies(); - for (uint32 i = 0; i < numDependencies; ++i) + const size_t numDependencies = actor->GetNumDependencies(); + for (size_t i = 0; i < numDependencies; ++i) { // add it to the actor instance mDependencies.emplace_back(*actor->GetDependency(i)); @@ -995,8 +980,8 @@ namespace EMotionFX AZStd::string nameB; // search through all nodes to find the best match - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 n = 0; n < numNodes; ++n) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t n = 0; n < numNodes; ++n) { // get the node name const char* name = mSkeleton->GetNode(n)->GetName(); @@ -1052,21 +1037,21 @@ namespace EMotionFX bool Actor::MapNodeMotionSource(const char* sourceNodeName, const char* destNodeName) { // find the source node index - const uint32 sourceNodeIndex = mSkeleton->FindNodeByNameNoCase(sourceNodeName)->GetNodeIndex(); - if (sourceNodeIndex == MCORE_INVALIDINDEX32) + const size_t sourceNodeIndex = mSkeleton->FindNodeByNameNoCase(sourceNodeName)->GetNodeIndex(); + if (sourceNodeIndex == InvalidIndex) { return false; } // find the dest node index - const uint32 destNodeIndex = mSkeleton->FindNodeByNameNoCase(destNodeName)->GetNodeIndex(); - if (destNodeIndex == MCORE_INVALIDINDEX32) + const size_t destNodeIndex = mSkeleton->FindNodeByNameNoCase(destNodeName)->GetNodeIndex(); + if (destNodeIndex == InvalidIndex) { return false; } // allocate the data if we haven't already - if (mNodeMirrorInfos.size() == 0) + if (mNodeMirrorInfos.empty()) { AllocateNodeMirrorInfos(); } @@ -1084,7 +1069,7 @@ namespace EMotionFX bool Actor::MapNodeMotionSource(uint16 sourceNodeIndex, uint16 targetNodeIndex) { // allocate the data if we haven't already - if (mNodeMirrorInfos.size() == 0) + if (mNodeMirrorInfos.empty()) { AllocateNodeMirrorInfos(); } @@ -1104,8 +1089,8 @@ namespace EMotionFX void Actor::MatchNodeMotionSources(const char* subStringA, const char* subStringB) { // try to map all nodes - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Node* node = mSkeleton->GetNode(i); @@ -1137,14 +1122,14 @@ namespace EMotionFX // find the first active parent node in a given skeletal LOD - uint32 Actor::FindFirstActiveParentBone(uint32 skeletalLOD, uint32 startNodeIndex) const + size_t Actor::FindFirstActiveParentBone(uint32 skeletalLOD, size_t startNodeIndex) const { - uint32 curNodeIndex = startNodeIndex; + size_t curNodeIndex = startNodeIndex; do { curNodeIndex = mSkeleton->GetNode(curNodeIndex)->GetParentIndex(); - if (curNodeIndex == MCORE_INVALIDINDEX32) + if (curNodeIndex == InvalidIndex) { return curNodeIndex; } @@ -1153,9 +1138,9 @@ namespace EMotionFX { return curNodeIndex; } - } while (curNodeIndex != MCORE_INVALIDINDEX32); + } while (curNodeIndex != InvalidIndex); - return MCORE_INVALIDINDEX32; + return InvalidIndex; } // make the geometry LOD levels compatible with the skeletal LOD levels @@ -1169,8 +1154,8 @@ namespace EMotionFX for (size_t geomLod = 0; geomLod < numGeomLODs; ++geomLod) { // for all nodes - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 n = 0; n < numNodes; ++n) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t n = 0; n < numNodes; ++n) { Node* node = mSkeleton->GetNode(n); @@ -1192,8 +1177,8 @@ namespace EMotionFX const uint32* orgVertices = (uint32*)mesh->FindOriginalVertexData(Mesh::ATTRIB_ORGVTXNUMBERS); // for all submeshes - const uint32 numSubMeshes = mesh->GetNumSubMeshes(); - for (uint32 s = 0; s < numSubMeshes; ++s) + const size_t numSubMeshes = mesh->GetNumSubMeshes(); + for (size_t s = 0; s < numSubMeshes; ++s) { SubMesh* subMesh = mesh->GetSubMesh(s); @@ -1214,8 +1199,8 @@ namespace EMotionFX if (mSkeleton->GetNode(influence->GetNodeNr())->GetSkeletalLODStatus(static_cast(geomLod)) == false) { // find the first parent bone that is enabled in this LOD - const uint32 newNodeIndex = FindFirstActiveParentBone(static_cast(geomLod), influence->GetNodeNr()); - if (newNodeIndex == MCORE_INVALIDINDEX32) + const size_t newNodeIndex = FindFirstActiveParentBone(geomLod, influence->GetNodeNr()); + if (newNodeIndex == InvalidIndex) { MCore::LogWarning("EMotionFX::Actor::MakeGeomLODsCompatibleWithSkeletalLODs() - Failed to find an enabled parent for node '%s' in skeletal LOD %d of actor '%s' (0x%x)", node->GetName(), geomLod, GetFileName(), this); continue; @@ -1250,7 +1235,7 @@ namespace EMotionFX // generate a path from the current node towards the root - void Actor::GenerateUpdatePathToRoot(uint32 endNodeIndex, AZStd::vector& outPath) const + void Actor::GenerateUpdatePathToRoot(size_t endNodeIndex, AZStd::vector& outPath) const { outPath.clear(); outPath.reserve(32); @@ -1279,7 +1264,7 @@ namespace EMotionFX } } - void Actor::SetMotionExtractionNodeIndex(uint32 nodeIndex) + void Actor::SetMotionExtractionNodeIndex(size_t nodeIndex) { mMotionExtractionNode = nodeIndex; ActorNotificationBus::Broadcast(&ActorNotificationBus::Events::OnMotionExtractionNodeChanged, this, GetMotionExtractionNode()); @@ -1287,7 +1272,7 @@ namespace EMotionFX Node* Actor::GetMotionExtractionNode() const { - if (mMotionExtractionNode != MCORE_INVALIDINDEX32 && + if (mMotionExtractionNode != InvalidIndex && mMotionExtractionNode < mSkeleton->GetNumNodes()) { return mSkeleton->GetNode(mMotionExtractionNode); @@ -1298,9 +1283,9 @@ namespace EMotionFX void Actor::ReinitializeMeshDeformers() { - const uint32 numLODLevels = GetNumLODLevels(); - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numLODLevels = GetNumLODLevels(); + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Node* node = mSkeleton->GetNode(i); @@ -1327,9 +1312,9 @@ namespace EMotionFX // calculate the inverse bind pose matrices const Pose* bindPose = GetBindPose(); - const uint32 numNodes = mSkeleton->GetNumNodes(); + const size_t numNodes = mSkeleton->GetNumNodes(); mInvBindPoseTransforms.resize(numNodes); - for (uint32 i = 0; i < numNodes; ++i) + for (size_t i = 0; i < numNodes; ++i) { mInvBindPoseTransforms[i] = bindPose->GetModelSpaceTransform(i).Inversed(); } @@ -1509,7 +1494,7 @@ namespace EMotionFX outPoints.clear(); const uint32 geomLODLevel = 0; - const uint32 numNodes = mSkeleton->GetNumNodes(); + const size_t numNodes = mSkeleton->GetNumNodes(); for (int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++) { @@ -1532,8 +1517,8 @@ namespace EMotionFX AZ::Vector3* positions = (AZ::Vector3*)mesh->FindVertexData(EMotionFX::Mesh::ATTRIB_POSITIONS); // for all submeshes - const uint32 numSubMeshes = mesh->GetNumSubMeshes(); - for (uint32 subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex) + const size_t numSubMeshes = mesh->GetNumSubMeshes(); + for (size_t subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex) { SubMesh* subMesh = mesh->GetSubMesh(subMeshIndex); @@ -1545,10 +1530,10 @@ namespace EMotionFX const uint32 orgVertex = orgVertices[startVertex + vertexIndex]; // for all skinning influences of the vertex - const uint32 numInfluences = static_cast(layer->GetNumInfluences(orgVertex)); + const size_t numInfluences = layer->GetNumInfluences(orgVertex); float maxWeight = 0.0f; - uint32 maxWeightNodeIndex = 0; - for (uint32 i = 0; i < numInfluences; ++i) + size_t maxWeightNodeIndex = 0; + for (size_t i = 0; i < numInfluences; ++i) { SkinInfluence* influence = layer->GetInfluence(orgVertex, i); float weight = influence->GetWeight(); @@ -1577,8 +1562,8 @@ namespace EMotionFX Pose pose; pose.LinkToActor(this); - const uint32 numNodes = mNodeMirrorInfos.size(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mNodeMirrorInfos.size(); + for (size_t i = 0; i < numNodes; ++i) { const uint16 motionSource = (GetHasMirrorInfo()) ? GetNodeMirrorInfo(i).mSourceNode : static_cast(i); @@ -1699,9 +1684,6 @@ namespace EMotionFX //MCore::LogInfo("best for %s = %f (axis=%d) (flags=%d)", mNodes[i]->GetName(), minDist, bestAxis, bestFlags); } } - - //for (uint32 i=0; iGetName(), mNodeMirrorInfos[i].mAxis, mNodeMirrorInfos[i].mFlags); } @@ -1766,10 +1748,10 @@ namespace EMotionFX uint16 result = MCORE_INVALIDINDEX16; // find nodes that have the mirrored transform - const uint32 numNodes = mSkeleton->GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = mSkeleton->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { - const Transform curNodeTransform = pose.GetModelSpaceTransform(i); + const Transform& curNodeTransform = pose.GetModelSpaceTransform(i); if (i != nodeIndex) { // only check the translation for now @@ -1791,8 +1773,8 @@ namespace EMotionFX if (numMatches == 1) { - const uint32 hierarchyDepth = mSkeleton->CalcHierarchyDepthForNode(nodeIndex); - const uint32 matchingHierarchyDepth = mSkeleton->CalcHierarchyDepthForNode(result); + const size_t hierarchyDepth = mSkeleton->CalcHierarchyDepthForNode(nodeIndex); + const size_t matchingHierarchyDepth = mSkeleton->CalcHierarchyDepthForNode(result); if (hierarchyDepth != matchingHierarchyDepth) { return MCORE_INVALIDINDEX16; @@ -1838,7 +1820,7 @@ namespace EMotionFX *mSkeleton->GetBindPose() = *other->GetSkeleton()->GetBindPose(); } - void Actor::SetNumNodes(uint32 numNodes) + void Actor::SetNumNodes(size_t numNodes) { mSkeleton->SetNumNodes(numNodes); @@ -1868,13 +1850,13 @@ namespace EMotionFX mSkeleton->GetBindPose()->SetLocalSpaceTransform(mSkeleton->GetNumNodes() - 1, Transform::CreateIdentity()); } - Node* Actor::AddNode(uint32 nodeIndex, const char* name, uint32 parentIndex) + Node* Actor::AddNode(size_t nodeIndex, const char* name, size_t parentIndex) { Node* node = Node::Create(name, GetSkeleton()); node->SetNodeIndex(nodeIndex); node->SetParentIndex(parentIndex); AddNode(node); - if (parentIndex == MCORE_INVALIDINDEX32) + if (parentIndex == InvalidIndex) { GetSkeleton()->AddRootNode(node->GetNodeIndex()); } @@ -1885,7 +1867,7 @@ namespace EMotionFX return node; } - void Actor::RemoveNode(uint32 nr, bool delMem) + void Actor::RemoveNode(size_t nr, bool delMem) { mSkeleton->RemoveNode(nr, delMem); @@ -2169,20 +2151,20 @@ namespace EMotionFX //--------------------------------- - Mesh* Actor::GetMesh(uint32 lodLevel, uint32 nodeIndex) const + Mesh* Actor::GetMesh(size_t lodLevel, size_t nodeIndex) const { const AZStd::vector& lodLevels = m_meshLodData.m_lodLevels; return lodLevels[lodLevel].mNodeInfos[nodeIndex].mMesh; } - MeshDeformerStack* Actor::GetMeshDeformerStack(uint32 lodLevel, uint32 nodeIndex) const + MeshDeformerStack* Actor::GetMeshDeformerStack(uint32 lodLevel, size_t nodeIndex) const { const AZStd::vector& lodLevels = m_meshLodData.m_lodLevels; return lodLevels[lodLevel].mNodeInfos[nodeIndex].mStack; } // set the mesh for a given node in a given LOD - void Actor::SetMesh(uint32 lodLevel, uint32 nodeIndex, Mesh* mesh) + void Actor::SetMesh(uint32 lodLevel, size_t nodeIndex, Mesh* mesh) { AZStd::vector& lodLevels = m_meshLodData.m_lodLevels; lodLevels[lodLevel].mNodeInfos[nodeIndex].mMesh = mesh; @@ -2190,14 +2172,14 @@ namespace EMotionFX // set the mesh deformer stack for a given node in a given LOD - void Actor::SetMeshDeformerStack(uint32 lodLevel, uint32 nodeIndex, MeshDeformerStack* stack) + void Actor::SetMeshDeformerStack(uint32 lodLevel, size_t nodeIndex, MeshDeformerStack* stack) { AZStd::vector& lodLevels = m_meshLodData.m_lodLevels; lodLevels[lodLevel].mNodeInfos[nodeIndex].mStack = stack; } // check if the mesh has a skinning deformer (either linear or dual quat) - bool Actor::CheckIfHasSkinningDeformer(uint32 lodLevel, uint32 nodeIndex) const + bool Actor::CheckIfHasSkinningDeformer(uint32 lodLevel, size_t nodeIndex) const { // check if there is a mesh Mesh* mesh = GetMesh(lodLevel, nodeIndex); @@ -2217,7 +2199,7 @@ namespace EMotionFX } // remove the mesh for a given node in a given LOD - void Actor::RemoveNodeMeshForLOD(uint32 lodLevel, uint32 nodeIndex, bool destroyMesh) + void Actor::RemoveNodeMeshForLOD(uint32 lodLevel, size_t nodeIndex, bool destroyMesh) { AZStd::vector& lodLevels = m_meshLodData.m_lodLevels; @@ -2273,8 +2255,8 @@ namespace EMotionFX // scale the bind pose positions Pose* bindPose = GetBindPose(); - const uint32 numNodes = GetNumNodes(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { Transform transform = bindPose->GetLocalSpaceTransform(i); transform.mPosition *= scaleFactor; @@ -2283,7 +2265,7 @@ namespace EMotionFX bindPose->ForceUpdateFullModelSpacePose(); // calculate the inverse bind pose matrices - for (uint32 i = 0; i < numNodes; ++i) + for (size_t i = 0; i < numNodes; ++i) { mInvBindPoseTransforms[i] = bindPose->GetModelSpaceTransform(i).Inversed(); } @@ -2293,10 +2275,10 @@ namespace EMotionFX m_staticAabb.SetMax(m_staticAabb.GetMax() * scaleFactor); // update mesh data for all LOD levels - const uint32 numLODs = GetNumLODLevels(); - for (uint32 lod = 0; lod < numLODs; ++lod) + const size_t numLODs = GetNumLODLevels(); + for (size_t lod = 0; lod < numLODs; ++lod) { - for (uint32 i = 0; i < numNodes; ++i) + for (size_t i = 0; i < numNodes; ++i) { Mesh* mesh = GetMesh(lod, i); if (mesh) @@ -2344,8 +2326,8 @@ namespace EMotionFX // Try to figure out which axis points "up" for the motion extraction node. Actor::EAxis Actor::FindBestMatchingMotionExtractionAxis() const { - MCORE_ASSERT(mMotionExtractionNode != MCORE_INVALIDINDEX32); - if (mMotionExtractionNode == MCORE_INVALIDINDEX32) + MCORE_ASSERT(mMotionExtractionNode != InvalidIndex); + if (mMotionExtractionNode == InvalidIndex) { return AXIS_Y; } @@ -2380,7 +2362,7 @@ namespace EMotionFX } - void Actor::SetRetargetRootNodeIndex(uint32 nodeIndex) + void Actor::SetRetargetRootNodeIndex(size_t nodeIndex) { mRetargetRootNode = nodeIndex; } @@ -2388,10 +2370,10 @@ namespace EMotionFX void Actor::SetRetargetRootNode(Node* node) { - mRetargetRootNode = node ? node->GetNodeIndex() : MCORE_INVALIDINDEX32; + mRetargetRootNode = node ? node->GetNodeIndex() : InvalidIndex; } - void Actor::InsertJointAndParents(AZ::u32 jointIndex, AZStd::unordered_set& includedJointIndices) + void Actor::InsertJointAndParents(size_t jointIndex, AZStd::unordered_set& includedJointIndices) { // If our joint is already in, then we can skip things. if (includedJointIndices.find(jointIndex) != includedJointIndices.end()) @@ -2400,8 +2382,8 @@ namespace EMotionFX } // Add the parent. - const AZ::u32 parentIndex = mSkeleton->GetNode(jointIndex)->GetParentIndex(); - if (parentIndex != InvalidIndex32) + const size_t parentIndex = mSkeleton->GetNode(jointIndex)->GetParentIndex(); + if (parentIndex != InvalidIndex) { InsertJointAndParents(parentIndex, includedJointIndices); } @@ -2412,10 +2394,10 @@ namespace EMotionFX void Actor::AutoSetupSkeletalLODsBasedOnSkinningData(const AZStd::vector& alwaysIncludeJoints) { - AZStd::unordered_set includedJointIndices; + AZStd::unordered_set includedJointIndices; - const AZ::u32 numLODs = GetNumLODLevels(); - for (AZ::u32 lod = 0; lod < numLODs; ++lod) + const size_t numLODs = GetNumLODLevels(); + for (size_t lod = 0; lod < numLODs; ++lod) { includedJointIndices.clear(); @@ -2425,8 +2407,8 @@ namespace EMotionFX continue; } - const AZ::u32 numJoints = mSkeleton->GetNumNodes(); - for (AZ::u32 jointIndex = 0; jointIndex < numJoints; ++jointIndex) + const size_t numJoints = mSkeleton->GetNumNodes(); + for (size_t jointIndex = 0; jointIndex < numJoints; ++jointIndex) { const Mesh* mesh = GetMesh(lod, jointIndex); if (!mesh) @@ -2438,14 +2420,13 @@ namespace EMotionFX InsertJointAndParents(jointIndex, includedJointIndices); // Look at the joints registered in the submeshes. - const AZ::u32 numSubMeshes = mesh->GetNumSubMeshes(); - for (AZ::u32 subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex) + const size_t numSubMeshes = mesh->GetNumSubMeshes(); + for (size_t subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex) { - const AZStd::vector& subMeshJoints = mesh->GetSubMesh(subMeshIndex)->GetBonesArray(); - const AZ::u32 numSubMeshJoints = subMeshJoints.size(); - for (AZ::u32 i = 0; i < numSubMeshJoints; ++i) + const AZStd::vector& subMeshJoints = mesh->GetSubMesh(subMeshIndex)->GetBonesArray(); + for (size_t subMeshJoint : subMeshJoints) { - InsertJointAndParents(subMeshJoints[i], includedJointIndices); + InsertJointAndParents(subMeshJoint, includedJointIndices); } } } // for all joints @@ -2456,7 +2437,7 @@ namespace EMotionFX // Force joints in our "always include list" to be included. for (const AZStd::string& jointName : alwaysIncludeJoints) { - AZ::u32 jointIndex = InvalidIndex32; + size_t jointIndex = InvalidIndex; if (!mSkeleton->FindNodeAndIndexByName(jointName, jointIndex)) { if (!jointName.empty()) @@ -2470,14 +2451,14 @@ namespace EMotionFX } // Disable all joints first. - for (AZ::u32 jointIndex = 0; jointIndex < numJoints; ++jointIndex) + for (size_t jointIndex = 0; jointIndex < numJoints; ++jointIndex) { mSkeleton->GetNode(jointIndex)->SetSkeletalLODStatus(lod, false); } // Enable all our included joints in this skeletal LOD. AZ_TracePrintf("EMotionFX", "[LOD %d] Enabled joints = %zd\n", lod, includedJointIndices.size()); - for (AZ::u32 jointIndex : includedJointIndices) + for (size_t jointIndex : includedJointIndices) { mSkeleton->GetNode(jointIndex)->SetSkeletalLODStatus(lod, true); } @@ -2485,7 +2466,7 @@ namespace EMotionFX else // When we have an empty include list, enable everything. { AZ_TracePrintf("EMotionFX", "[LOD %d] Enabled joints = %zd\n", lod, mSkeleton->GetNumNodes()); - for (AZ::u32 i = 0; i < mSkeleton->GetNumNodes(); ++i) + for (size_t i = 0; i < mSkeleton->GetNumNodes(); ++i) { mSkeleton->GetNode(i)->SetSkeletalLODStatus(lod, true); } @@ -2496,17 +2477,17 @@ namespace EMotionFX void Actor::PrintSkeletonLODs() { - const AZ::u32 numLODs = GetNumLODLevels(); - for (AZ::u32 lod = 0; lod < numLODs; ++lod) + const size_t numLODs = GetNumLODLevels(); + for (size_t lod = 0; lod < numLODs; ++lod) { AZ_TracePrintf("EMotionFX", "[LOD %d]:", lod); - const AZ::u32 numJoints = mSkeleton->GetNumNodes(); - for (AZ::u32 jointIndex = 0; jointIndex < numJoints; ++jointIndex) + const size_t numJoints = mSkeleton->GetNumNodes(); + for (size_t jointIndex = 0; jointIndex < numJoints; ++jointIndex) { const Node* joint = mSkeleton->GetNode(jointIndex); if (joint->GetSkeletalLODStatus(lod)) { - AZ_TracePrintf("EMotionFX", "\t%s (index=%d)", joint->GetName(), jointIndex); + AZ_TracePrintf("EMotionFX", "\t%s (index=%zu)", joint->GetName(), jointIndex); } } } @@ -2530,7 +2511,7 @@ namespace EMotionFX // 3) In actor skeleton, remove every node that hasn't been marked. // 4) Meanwhile, build a map that represent the child-parent relationship. // 5) After the node index changed, we use the map in 4) to restore the child-parent relationship. - AZ::u32 numNodes = mSkeleton->GetNumNodes(); + size_t numNodes = mSkeleton->GetNumNodes(); AZStd::vector flags; AZStd::unordered_map childParentMap; flags.resize(numNodes); @@ -2554,7 +2535,7 @@ namespace EMotionFX } // Search the actor skeleton to find all the critical nodes. - for (AZ::u32 i = 0; i < numNodes; ++i) + for (size_t i = 0; i < numNodes; ++i) { Node* node = mSkeleton->GetNode(i); if (node->GetIsCritical() && nodesToKeep.find(node) == nodesToKeep.end()) @@ -2584,7 +2565,7 @@ namespace EMotionFX } // Remove all the nodes that haven't been marked - for (AZ::u32 nodeIndex = numNodes - 1; nodeIndex > 0; nodeIndex--) + for (size_t nodeIndex = numNodes - 1; nodeIndex > 0; nodeIndex--) { if (!flags[nodeIndex]) { @@ -2597,7 +2578,7 @@ namespace EMotionFX // After the node index changed, the parent index become invalid. First, clear all information about children because // it's not valid anymore. - for (AZ::u32 nodeIndex = 0; nodeIndex < mSkeleton->GetNumNodes(); ++nodeIndex) + for (size_t nodeIndex = 0; nodeIndex < mSkeleton->GetNumNodes(); ++nodeIndex) { Node* node = mSkeleton->GetNode(nodeIndex); node->RemoveAllChildNodes(); @@ -2654,8 +2635,8 @@ namespace EMotionFX const size_t numLODLevels = lodAssets.size(); lodLevels.clear(); - SetNumLODLevels(static_cast(numLODLevels), /*adjustMorphSetup=*/false); - const uint32 numNodes = mSkeleton->GetNumNodes(); + SetNumLODLevels(numLODLevels, /*adjustMorphSetup=*/false); + const size_t numNodes = mSkeleton->GetNumNodes(); // Remove all the materials and add them back based on the meshAsset. Eventually we will remove all the material from Actor and // GLActor. @@ -2679,7 +2660,7 @@ namespace EMotionFX continue; } - const AZ::u32 jointIndex = meshJoint->GetNodeIndex(); + const size_t jointIndex = meshJoint->GetNodeIndex(); NodeLODInfo& jointInfo = lodLevels[lodLevel].mNodeInfos[jointIndex]; jointInfo.mMesh = mesh; @@ -2690,8 +2671,8 @@ namespace EMotionFX } // Add the skinning deformers - const AZ::u32 numLayers = mesh->GetNumSharedVertexAttributeLayers(); - for (AZ::u32 layerNr = 0; layerNr < numLayers; ++layerNr) + const size_t numLayers = mesh->GetNumSharedVertexAttributeLayers(); + for (size_t layerNr = 0; layerNr < numLayers; ++layerNr) { EMotionFX::VertexAttributeLayer* vertexAttributeLayer = mesh->GetSharedVertexAttributeLayer(layerNr); if (vertexAttributeLayer->GetType() != EMotionFX::SkinningInfoVertexAttributeLayer::TYPE_ID) @@ -2703,7 +2684,7 @@ namespace EMotionFX static_cast(vertexAttributeLayer); const AZ::u32 numOrgVerts = skinLayer->GetNumAttributes(); AZStd::set localJointIndices = skinLayer->CalcLocalJointIndices(numOrgVerts); - const AZ::u32 numLocalJoints = static_cast(localJointIndices.size()); + const size_t numLocalJoints = localJointIndices.size(); // The information about if we want to use dual quat skinning is baked into the mesh chunk and we don't have access to that // anymore. Default to dual quat skinning. @@ -2801,7 +2782,7 @@ namespace EMotionFX continue; } - const AZ::u32 jointIndex = meshJoint->GetNodeIndex(); + const size_t jointIndex = meshJoint->GetNodeIndex(); NodeLODInfo& jointInfo = lodLevels[lodLevel].mNodeInfos[jointIndex]; Mesh* mesh = jointInfo.mMesh; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Actor.h b/Gems/EMotionFX/Code/EMotionFX/Source/Actor.h index 0894d22c4c..21b97c0bd6 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Actor.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Actor.h @@ -131,14 +131,14 @@ namespace EMotionFX /** * Add a node to this actor. */ - Node* AddNode(uint32 nodeIndex, const char* name, uint32 parentIndex = MCORE_INVALIDINDEX32); + Node* AddNode(size_t nodeIndex, const char* name, size_t parentIndex = InvalidIndex); /** * Remove a given node. * @param nr The node to remove. * @param delMem If true the allocated memory of the node will be deleted. */ - void RemoveNode(uint32 nr, bool delMem = true); + void RemoveNode(size_t nr, bool delMem = true); /** * Remove all nodes from memory. @@ -188,7 +188,7 @@ namespace EMotionFX * @param endNodeIndex The node index to generate the path to. * @param outPath the array that will contain the path. */ - void GenerateUpdatePathToRoot(uint32 endNodeIndex, AZStd::vector& outPath) const; + void GenerateUpdatePathToRoot(size_t endNodeIndex, AZStd::vector& outPath) const; /** * Set the motion extraction node. @@ -206,7 +206,7 @@ namespace EMotionFX * You can set the node to MCORE_INVALIDINDEX32 in case you want to disable motion extraction. * @param nodeIndex The motion extraction node, or MCORE_INVALIDINDEX32 to disable it. */ - void SetMotionExtractionNodeIndex(uint32 nodeIndex); + void SetMotionExtractionNodeIndex(size_t nodeIndex); /** * Get the motion extraction node. @@ -218,7 +218,7 @@ namespace EMotionFX * Get the motion extraction node index. * @result The motion extraction node index, or MCORE_INVALIDINDEX32 when it has not been set. */ - MCORE_INLINE uint32 GetMotionExtractionNodeIndex() const { return mMotionExtractionNode; } + MCORE_INLINE size_t GetMotionExtractionNodeIndex() const { return mMotionExtractionNode; } //--------------------------------------------------------------------- @@ -227,7 +227,7 @@ namespace EMotionFX * @param lodLevel The LOD level to check for. * @result Returns true when this actor contains nodes that have meshes in the given LOD, otherwise false is returned. */ - bool CheckIfHasMeshes(uint32 lodLevel) const; + bool CheckIfHasMeshes(size_t lodLevel) const; /** * Check if we have skinned meshes. @@ -529,8 +529,8 @@ namespace EMotionFX * @param nr The dependency number, which must be in range of [0..GetNumDependencies()-1]. * @result A pointer to the dependency. */ - MCORE_INLINE Dependency* GetDependency(uint32 nr) { return &mDependencies[nr]; } - MCORE_INLINE const Dependency* GetDependency(uint32 nr) const { return &mDependencies[nr]; } + MCORE_INLINE Dependency* GetDependency(size_t nr) { return &mDependencies[nr]; } + MCORE_INLINE const Dependency* GetDependency(size_t nr) const { return &mDependencies[nr]; } /** * Recursively add dependencies that this actor has on other actors. @@ -649,14 +649,14 @@ namespace EMotionFX * @param nodeIndex The node index to get the info for. * @result A reference to the mirror info. */ - MCORE_INLINE NodeMirrorInfo& GetNodeMirrorInfo(uint32 nodeIndex) { return mNodeMirrorInfos[nodeIndex]; } + MCORE_INLINE NodeMirrorInfo& GetNodeMirrorInfo(size_t nodeIndex) { return mNodeMirrorInfos[nodeIndex]; } /** * Get the mirror info for a given node. * @param nodeIndex The node index to get the info for. * @result A reference to the mirror info. */ - MCORE_INLINE const NodeMirrorInfo& GetNodeMirrorInfo(uint32 nodeIndex) const { return mNodeMirrorInfos[nodeIndex]; } + MCORE_INLINE const NodeMirrorInfo& GetNodeMirrorInfo(size_t nodeIndex) const { return mNodeMirrorInfos[nodeIndex]; } MCORE_INLINE bool GetHasMirrorInfo() const { return (mNodeMirrorInfos.size() != 0); } @@ -735,7 +735,7 @@ namespace EMotionFX * @param startNodeIndex The node to start looking at, for example the node index of the finger bone. * @result Returns the index of the first active node, when moving up the hierarchy towards the root node. Returns MCORE_INVALIDINDEX32 when not found. */ - uint32 FindFirstActiveParentBone(uint32 skeletalLOD, uint32 startNodeIndex) const; + size_t FindFirstActiveParentBone(uint32 skeletalLOD, size_t startNodeIndex) const; /** * Make the geometry LOD levels compatible with the skinning LOD levels. @@ -763,7 +763,7 @@ namespace EMotionFX * @param jointIndex The joint number, which must be in range of [0..GetNumNodes()-1]. * @result The inverse of the bind pose transform. */ - MCORE_INLINE const Transform& GetInverseBindPoseTransform(uint32 nodeIndex) const { return mInvBindPoseTransforms[nodeIndex]; } + MCORE_INLINE const Transform& GetInverseBindPoseTransform(size_t nodeIndex) const { return mInvBindPoseTransforms[nodeIndex]; } void ReleaseTransformData(); void ResizeTransformData(); @@ -776,8 +776,8 @@ namespace EMotionFX void SetThreadIndex(uint32 index) { mThreadIndex = index; } uint32 GetThreadIndex() const { return mThreadIndex; } - Mesh* GetMesh(uint32 lodLevel, uint32 nodeIndex) const; - MeshDeformerStack* GetMeshDeformerStack(uint32 lodLevel, uint32 nodeIndex) const; + Mesh* GetMesh(size_t lodLevel, size_t nodeIndex) const; + MeshDeformerStack* GetMeshDeformerStack(uint32 lodLevel, size_t nodeIndex) const; /** Finds the mesh points for which the specified node is the node with the highest influence. * This is a pretty expensive function which is only intended for use in the editor. @@ -788,17 +788,17 @@ namespace EMotionFX void FindMostInfluencedMeshPoints(const Node* node, AZStd::vector& outPoints) const; MCORE_INLINE Skeleton* GetSkeleton() const { return mSkeleton; } - MCORE_INLINE uint32 GetNumNodes() const { return mSkeleton->GetNumNodes(); } + MCORE_INLINE size_t GetNumNodes() const { return mSkeleton->GetNumNodes(); } - void SetMesh(uint32 lodLevel, uint32 nodeIndex, Mesh* mesh); - void SetMeshDeformerStack(uint32 lodLevel, uint32 nodeIndex, MeshDeformerStack* stack); + void SetMesh(uint32 lodLevel, size_t nodeIndex, Mesh* mesh); + void SetMeshDeformerStack(uint32 lodLevel, size_t nodeIndex, MeshDeformerStack* stack); - bool CheckIfHasMorphDeformer(uint32 lodLevel, uint32 nodeIndex) const; - bool CheckIfHasSkinningDeformer(uint32 lodLevel, uint32 nodeIndex) const; + bool CheckIfHasMorphDeformer(uint32 lodLevel, size_t nodeIndex) const; + bool CheckIfHasSkinningDeformer(uint32 lodLevel, size_t nodeIndex) const; - void RemoveNodeMeshForLOD(uint32 lodLevel, uint32 nodeIndex, bool destroyMesh = true); + void RemoveNodeMeshForLOD(uint32 lodLevel, size_t nodeIndex, bool destroyMesh = true); - void SetNumNodes(uint32 numNodes); + void SetNumNodes(size_t numNodes); void SetUnitType(MCore::Distance::EUnitType unitType); MCore::Distance::EUnitType GetUnitType() const; @@ -808,9 +808,9 @@ namespace EMotionFX EAxis FindBestMatchingMotionExtractionAxis() const; - MCORE_INLINE uint32 GetRetargetRootNodeIndex() const { return mRetargetRootNode; } - MCORE_INLINE Node* GetRetargetRootNode() const { return (mRetargetRootNode != MCORE_INVALIDINDEX32) ? mSkeleton->GetNode(mRetargetRootNode) : nullptr; } - void SetRetargetRootNodeIndex(uint32 nodeIndex); + MCORE_INLINE size_t GetRetargetRootNodeIndex() const { return mRetargetRootNode; } + MCORE_INLINE Node* GetRetargetRootNode() const { return (mRetargetRootNode != InvalidIndex) ? mSkeleton->GetNode(mRetargetRootNode) : nullptr; } + void SetRetargetRootNodeIndex(size_t nodeIndex); void SetRetargetRootNode(Node* node); void AutoSetupSkeletalLODsBasedOnSkinningData(const AZStd::vector& alwaysIncludeJoints); @@ -846,7 +846,7 @@ namespace EMotionFX void Finalize(LoadRequirement loadReq = LoadRequirement::AllowAsyncLoad); private: - void InsertJointAndParents(AZ::u32 jointIndex, AZStd::unordered_set& includedJointIndices); + void InsertJointAndParents(size_t jointIndex, AZStd::unordered_set& includedJointIndices); AZStd::unordered_map ConstructSkinToSkeletonIndexMap(const AZ::Data::Asset& skinMetaAsset); void ConstructMeshes(); @@ -932,8 +932,8 @@ namespace EMotionFX MCore::Distance::EUnitType mFileUnitType; /**< The unit type used on export. */ AZStd::vector mInvBindPoseTransforms; /**< The inverse world space bind pose transforms. */ void* mCustomData; /**< Some custom data, for example a pointer to your own game character class which is linked to this actor. */ - uint32 mMotionExtractionNode; /**< The motion extraction node. This is the node from which to transfer a filtered part of the motion onto the actor instance. Can also be MCORE_INVALIDINDEX32 when motion extraction is disabled. */ - uint32 mRetargetRootNode; /**< The retarget root node, which controls the height displacement of the character. This is most likely the hip or pelvis node. */ + size_t mMotionExtractionNode; /**< The motion extraction node. This is the node from which to transfer a filtered part of the motion onto the actor instance. Can also be MCORE_INVALIDINDEX32 when motion extraction is disabled. */ + size_t mRetargetRootNode; /**< The retarget root node, which controls the height displacement of the character. This is most likely the hip or pelvis node. */ uint32 mID; /**< The unique identification number for the actor. */ uint32 mThreadIndex; /**< The thread number we are running on, which is a value starting at 0, up to the number of threads in the job system. */ AZ::Aabb m_staticAabb; /**< The static AABB. */ diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/ActorInstance.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/ActorInstance.cpp index 34af57026a..eaa09f92c0 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/ActorInstance.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/ActorInstance.cpp @@ -1356,7 +1356,7 @@ namespace EMotionFX void ActorInstance::MotionExtractionCompensate(Transform& inOutMotionExtractionNodeTransform, EMotionExtractionFlags motionExtractionFlags) const { - MCORE_ASSERT(mActor->GetMotionExtractionNodeIndex() != MCORE_INVALIDINDEX32); + MCORE_ASSERT(mActor->GetMotionExtractionNodeIndex() != InvalidIndex); Transform bindPoseTransform = mTransformData->GetBindPose()->GetLocalSpaceTransform(mActor->GetMotionExtractionNodeIndex()); MotionExtractionCompensate(inOutMotionExtractionNodeTransform, bindPoseTransform, motionExtractionFlags); @@ -1365,8 +1365,8 @@ namespace EMotionFX // Remove the trajectory transform from the motion extraction node to prevent double transformation. void ActorInstance::MotionExtractionCompensate(EMotionExtractionFlags motionExtractionFlags) { - const uint32 motionExtractIndex = mActor->GetMotionExtractionNodeIndex(); - if (motionExtractIndex == MCORE_INVALIDINDEX32) + const size_t motionExtractIndex = mActor->GetMotionExtractionNodeIndex(); + if (motionExtractIndex == InvalidIndex) { return; } @@ -1396,7 +1396,7 @@ namespace EMotionFX // Apply the motion extraction delta transform to the actor instance. void ActorInstance::ApplyMotionExtractionDelta(const Transform& trajectoryDelta) { - if (mActor->GetMotionExtractionNodeIndex() == MCORE_INVALIDINDEX32) + if (mActor->GetMotionExtractionNodeIndex() == InvalidIndex) { return; } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2AdditiveNode.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2AdditiveNode.cpp index 703838f22b..e6ce8c6119 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2AdditiveNode.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2AdditiveNode.cpp @@ -443,7 +443,7 @@ namespace EMotionFX FilterEvents(animGraphInstance, eventMode, nodeA, nodeB, weight, data); // Output motion extraction deltas. - if (animGraphInstance->GetActorInstance()->GetActor()->GetMotionExtractionNodeIndex() != MCORE_INVALIDINDEX32) + if (animGraphInstance->GetActorInstance()->GetActor()->GetMotionExtractionNodeIndex() != InvalidIndex) { UpdateMotionExtraction(animGraphInstance, nodeA, nodeB, weight, uniqueData); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2LegacyNode.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2LegacyNode.cpp index c94bf09eb5..7e2fdd4736 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2LegacyNode.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2LegacyNode.cpp @@ -461,7 +461,7 @@ namespace EMotionFX eventMode = EVENTMODE_BOTHNODES; } FilterEvents(animGraphInstance, eventMode, nodeA, nodeB, weight, data); - if (animGraphInstance->GetActorInstance()->GetActor()->GetMotionExtractionNodeIndex() != MCORE_INVALIDINDEX32) + if (animGraphInstance->GetActorInstance()->GetActor()->GetMotionExtractionNodeIndex() != InvalidIndex) { UpdateMotionExtraction(animGraphInstance, nodeA, nodeB, weight, uniqueData); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2Node.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2Node.cpp index 3cfff94f72..f3b9ee2014 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2Node.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeBlend2Node.cpp @@ -405,7 +405,7 @@ namespace EMotionFX FilterEvents(animGraphInstance, m_eventMode, nodeA, nodeB, weight, data); - if (animGraphInstance->GetActorInstance()->GetActor()->GetMotionExtractionNodeIndex() != MCORE_INVALIDINDEX32) + if (animGraphInstance->GetActorInstance()->GetActor()->GetMotionExtractionNodeIndex() != InvalidIndex) { UpdateMotionExtraction(animGraphInstance, nodeA, nodeB, weight, uniqueData); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeFootIKNode.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeFootIKNode.cpp index 4e4f0ed4e4..8e0e67e95a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeFootIKNode.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeFootIKNode.cpp @@ -1021,7 +1021,7 @@ namespace EMotionFX // Adjust the hip position by moving it up or down if that would result in a more natural look. float hipHeightAdjustment = 0.0f; - if (GetAdjustHip(animGraphInstance) && uniqueData->m_hipJointIndex != MCORE_INVALIDINDEX32) + if (GetAdjustHip(animGraphInstance) && uniqueData->m_hipJointIndex != InvalidIndex) { hipHeightAdjustment = AdjustHip(animGraphInstance, uniqueData, inputPose->GetPose(), outputPose->GetPose(), intersectionResults, true /* allowHipAdjust */); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeFootIKNode.h b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeFootIKNode.h index ed2d8113f4..0e46f156af 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeFootIKNode.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/BlendTreeFootIKNode.h @@ -87,7 +87,7 @@ namespace EMotionFX struct Leg { - AZ::u32 m_jointIndices[4]; // Use LegJointId as index into this array. + size_t m_jointIndices[4]; // Use LegJointId as index into this array. AZ::u8 m_flags = static_cast(LegFlags::FirstUpdate); AZ::Vector3 m_footLockPosition = AZ::Vector3::CreateZero(); AZ::Quaternion m_footLockRotation; @@ -138,7 +138,7 @@ namespace EMotionFX float m_hipCorrectionTarget = 0.0f; float m_curHipCorrection = 0.0f; float m_timeDelta = 0.0f; - AZ::u32 m_hipJointIndex = MCORE_INVALIDINDEX32; + size_t m_hipJointIndex = InvalidIndex; AnimGraphEventBuffer m_eventBuffer; }; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/DualQuatSkinDeformer.h b/Gems/EMotionFX/Code/EMotionFX/Source/DualQuatSkinDeformer.h index b1f3387df7..fc1c986b68 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/DualQuatSkinDeformer.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/DualQuatSkinDeformer.h @@ -111,7 +111,7 @@ namespace EMotionFX * This does not alter the value returned by GetNumLocalBones(). * @param numBones The number of bones to pre-allocate space for. */ - MCORE_INLINE void ReserveLocalBones(uint32 numBones) { m_bones.reserve(numBones); } + MCORE_INLINE void ReserveLocalBones(size_t numBones) { m_bones.reserve(numBones); } protected: /** diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp index 18ec99b435..b6b0b091a2 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp @@ -1165,6 +1165,10 @@ namespace EMotionFX } actor->SetMotionExtractionNodeIndex(fileInformation.mMotionExtractionNodeIndex); + if (fileInformation.mMotionExtractionNodeIndex != MCORE_INVALIDINDEX32) + { + actor->SetMotionExtractionNodeIndex(fileInformation.mMotionExtractionNodeIndex); + } // actor->SetRetargetOffset( fileInformation.mRetargetRootOffset ); actor->SetUnitType(static_cast(fileInformation.mUnitType)); actor->SetFileUnitType(actor->GetUnitType()); @@ -1211,8 +1215,14 @@ namespace EMotionFX MCore::LogDetailedInfo(" + UnitType = %d", fileInformation.mUnitType); } - actor->SetMotionExtractionNodeIndex(fileInformation.mMotionExtractionNodeIndex); - actor->SetRetargetRootNodeIndex(fileInformation.mRetargetRootNodeIndex); + if (fileInformation.mMotionExtractionNodeIndex != MCORE_INVALIDINDEX32) + { + actor->SetMotionExtractionNodeIndex(fileInformation.mMotionExtractionNodeIndex); + } + if (fileInformation.mRetargetRootNodeIndex != MCORE_INVALIDINDEX32) + { + actor->SetRetargetRootNodeIndex(fileInformation.mRetargetRootNodeIndex); + } actor->SetUnitType(static_cast(fileInformation.mUnitType)); actor->SetFileUnitType(actor->GetUnitType()); @@ -1258,8 +1268,14 @@ namespace EMotionFX MCore::LogDetailedInfo(" + UnitType = %d", fileInformation.mUnitType); } - actor->SetMotionExtractionNodeIndex(fileInformation.mMotionExtractionNodeIndex); - actor->SetRetargetRootNodeIndex(fileInformation.mRetargetRootNodeIndex); + if (fileInformation.mMotionExtractionNodeIndex != MCORE_INVALIDINDEX32) + { + actor->SetMotionExtractionNodeIndex(fileInformation.mMotionExtractionNodeIndex); + } + if (fileInformation.mRetargetRootNodeIndex != MCORE_INVALIDINDEX32) + { + actor->SetRetargetRootNodeIndex(fileInformation.mRetargetRootNodeIndex); + } actor->SetUnitType(static_cast(fileInformation.mUnitType)); actor->SetFileUnitType(actor->GetUnitType()); actor->SetOptimizeSkeleton(fileInformation.mOptimizeSkeleton == 0? false : true); diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.cpp index 36fc898ed1..1203e3762a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.cpp @@ -850,7 +850,7 @@ namespace EMotionFX //--------------------------------------------------------------- - VertexAttributeLayer* Mesh::GetSharedVertexAttributeLayer(uint32 layerNr) + VertexAttributeLayer* Mesh::GetSharedVertexAttributeLayer(size_t layerNr) { MCORE_ASSERT(layerNr < mSharedVertexAttributes.size()); return mSharedVertexAttributes[layerNr]; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.h b/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.h index a0a99f2961..4a86a9875d 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.h @@ -242,7 +242,7 @@ namespace EMotionFX * @param nr The SubMesh number to get. * @result A pointer to the SubMesh. */ - MCORE_INLINE SubMesh* GetSubMesh(uint32 nr) const; + MCORE_INLINE SubMesh* GetSubMesh(size_t nr) const; /** * Set the value for a given submesh. @@ -279,7 +279,7 @@ namespace EMotionFX * @param layerNr The layer number to get the attributes from. Must be below the value returned by GetNumSharedVertexAttributeLayers(). * @result A pointer to the array of shared vertex attributes. You can typecast this pointer if you know the type of the vertex attributes. */ - VertexAttributeLayer* GetSharedVertexAttributeLayer(uint32 layerNr); + VertexAttributeLayer* GetSharedVertexAttributeLayer(size_t layerNr); /** * Adds a new layer of shared vertex attributes. diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.inl b/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.inl index 4ee52eaf19..6a29a3de69 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.inl +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Mesh.inl @@ -30,7 +30,7 @@ MCORE_INLINE size_t Mesh::GetNumSubMeshes() const } -MCORE_INLINE SubMesh* Mesh::GetSubMesh(uint32 nr) const +MCORE_INLINE SubMesh* Mesh::GetSubMesh(size_t nr) const { MCORE_ASSERT(nr < mSubMeshes.size()); return mSubMeshes[nr]; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Node.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Node.cpp index a712ffe337..5474087574 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Node.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Node.cpp @@ -20,11 +20,11 @@ namespace EMotionFX Node::Node(const char* name, Skeleton* skeleton) : BaseObject() { - mParentIndex = MCORE_INVALIDINDEX32; - mNodeIndex = MCORE_INVALIDINDEX32; // hasn't been set yet + mParentIndex = InvalidIndex; + mNodeIndex = InvalidIndex; // hasn't been set yet mSkeletalLODs = 0xFFFFFFFF; // set all bits of the integer to 1, which enables this node in all LOD levels on default mSkeleton = skeleton; - mSemanticNameID = MCORE_INVALIDINDEX32; + mSemanticNameID = InvalidIndex; mNodeFlags = FLAG_INCLUDEINBOUNDSCALC; if (name) @@ -33,20 +33,20 @@ namespace EMotionFX } else { - mNameID = MCORE_INVALIDINDEX32; + mNameID = InvalidIndex; } } - Node::Node(uint32 nameID, Skeleton* skeleton) + Node::Node(size_t nameID, Skeleton* skeleton) : BaseObject() { - mParentIndex = MCORE_INVALIDINDEX32; - mNodeIndex = MCORE_INVALIDINDEX32; // hasn't been set yet + mParentIndex = InvalidIndex; + mNodeIndex = InvalidIndex; // hasn't been set yet mSkeletalLODs = 0xFFFFFFFF;// set all bits of the integer to 1, which enables this node in all LOD levels on default mSkeleton = skeleton; mNameID = nameID; - mSemanticNameID = MCORE_INVALIDINDEX32; + mSemanticNameID = InvalidIndex; mNodeFlags = FLAG_INCLUDEINBOUNDSCALC; } @@ -69,82 +69,12 @@ namespace EMotionFX // create a node - Node* Node::Create(uint32 nameID, Skeleton* skeleton) + Node* Node::Create(size_t nameID, Skeleton* skeleton) { return aznew Node(nameID, skeleton); } - /* - // create a clone of this node - Node* Node::Clone(Actor* actor) const - { - Node* result = Node::Create(GetName(), actor); - - // copy attributes - result->mParentIndex = mParentIndex; - result->mNodeIndex = mNodeIndex; - result->mNameID = mNameID; - result->mSkeletalLODs = mSkeletalLODs; - //result->mMotionLODs = mMotionLODs; - result->mChildIndices = mChildIndices; - //result->mImportanceFactor = mImportanceFactor; - result->mNodeFlags = mNodeFlags; - result->mSemanticNameID = mSemanticNameID; - - // copy the node attributes - for (uint32 i=0; iAddAttribute( mAttributes[i]->Clone() ); - - // copy the meshes - const uint32 numLODs = mLODs.GetLength(); - if (result->mLODs.GetLength() < numLODs) - result->mLODs.Resize( numLODs ); - - for (uint32 i=0; imLODs[i].mMesh = realMesh->Clone(actor, result); - else - result->mLODs[i].mMesh = nullptr; - } - - // copy the collision meshes - for (uint32 i=0; imLODs[i].mColMesh = realMesh->Clone(actor, result); - else - result->mLODs[i].mColMesh = nullptr; - } - - // clone node stacks - for (uint32 i=0; imLODs[i].mStack = realStack->Clone(result->mLODs[i].mMesh, actor); - else - result->mLODs[i].mStack = nullptr; - } - - // clone node collision stacks if desired - for (uint32 i=0; imLODs[i].mColStack = realStack->Clone(result->mLODs[i].mColMesh, actor); - else - result->mLODs[i].mColStack = nullptr; - } - - // return the resulting clone - return result; - } - */ - // create a clone of this node Node* Node::Clone(Skeleton* skeleton) const { @@ -160,9 +90,9 @@ namespace EMotionFX // copy the node attributes result->mAttributes.reserve(mAttributes.size()); - for (uint32 i = 0; i < mAttributes.size(); i++) + for (const NodeAttribute* mAttribute : mAttributes) { - result->AddAttribute(mAttributes[i]->Clone()); + result->AddAttribute(mAttribute->Clone()); } // return the resulting clone @@ -173,7 +103,7 @@ namespace EMotionFX // removes all attributes void Node::RemoveAllAttributes() { - while (mAttributes.size()) + while (!mAttributes.empty()) { mAttributes.back()->Destroy(); mAttributes.pop_back(); @@ -182,16 +112,15 @@ namespace EMotionFX // get the total number of children - uint32 Node::GetNumChildNodesRecursive() const + size_t Node::GetNumChildNodesRecursive() const { // the number of total child nodes which include the childs of the childs, too - uint32 result = 0; + size_t result = 0; // retrieve the number of child nodes of the actual node - const uint32 numChildNodes = GetNumChildNodes(); - for (uint32 i = 0; i < numChildNodes; ++i) + for (size_t childIndex : mChildIndices) { - mSkeleton->GetNode(mChildIndices[i])->RecursiveCountChildNodes(result); + mSkeleton->GetNode(childIndex)->RecursiveCountChildNodes(result); } return result; @@ -199,22 +128,21 @@ namespace EMotionFX // recursively count the number of nodes down the hierarchy - void Node::RecursiveCountChildNodes(uint32& numNodes) + void Node::RecursiveCountChildNodes(size_t& numNodes) { // increase the counter numNodes++; // recurse down the hierarchy - const uint32 numChildNodes = mChildIndices.size(); - for (uint32 i = 0; i < numChildNodes; ++i) + for (size_t childIndex : mChildIndices) { - mSkeleton->GetNode(mChildIndices[i])->RecursiveCountChildNodes(numNodes); + mSkeleton->GetNode(childIndex)->RecursiveCountChildNodes(numNodes); } } // recursively go through the parents until a root node is reached and store all parents inside an array - void Node::RecursiveCollectParents(AZStd::vector& parents, bool clearParentsArray) const + void Node::RecursiveCollectParents(AZStd::vector& parents, bool clearParentsArray) const { if (clearParentsArray) { @@ -222,12 +150,12 @@ namespace EMotionFX } // loop until we reached a root node - Node* node = const_cast(this); + const Node* node = this; while (node) { // get the parent index and add it to the list of parents if the current node is not a root node - const uint32 parentIndex = node->GetParentIndex(); - if (parentIndex != MCORE_INVALIDINDEX32) + const size_t parentIndex = node->GetParentIndex(); + if (parentIndex != InvalidIndex) { // check if the parent is already in our array, if not add it so that we only store each node once if (AZStd::find(begin(parents), end(parents), parentIndex) == end(parents)) @@ -243,55 +171,29 @@ namespace EMotionFX // remove the given attribute of the given type from the node - void Node::RemoveAttributeByType(uint32 attributeTypeID, uint32 occurrence) + void Node::RemoveAttributeByType(uint32 attributeTypeID, size_t occurrence) { - // retrieve the number of attributes inside this node - const uint32 numAttributes = GetNumAttributes(); - - // counts the number of occurrences of the attribute to search for - uint32 numOccurredAttibutes = 0; - - // iterate through all node attributes - for (uint32 i = 0; i < numAttributes; ++i) + const auto foundAttribute = AZStd::find_if(begin(mAttributes), end(mAttributes), [attributeTypeID, occurrence, currentOccurrence = size_t{0}] (const NodeAttribute* attribute) mutable { - // get the current node attribute - NodeAttribute* nodeAttribute = GetAttribute(i); - - // check the type of the current node attribute and compare the two - if (nodeAttribute->GetType() == attributeTypeID) + if (attribute->GetType() == attributeTypeID) { - // increase the occurrence counter - numOccurredAttibutes++; - - // check if the found attribute is the one we searched - if (occurrence < numOccurredAttibutes) - { - // remove the attribute and return - RemoveAttribute(i); - return; - } + ++currentOccurrence; + return occurrence < currentOccurrence; } - } + return false; + }); + + mAttributes.erase(foundAttribute); } // remove all attributes of the given type from the node - uint32 Node::RemoveAllAttributesByType(uint32 attributeTypeID) + size_t Node::RemoveAllAttributesByType(uint32 attributeTypeID) { - uint32 attributeNumber = MCORE_INVALIDINDEX32; - uint32 numAttributesRemoved = 0; - - // try to find a node of the given attribute type - while ((attributeNumber = FindAttributeNumber(attributeTypeID)) != MCORE_INVALIDINDEX32) + return AZStd::erase_if(mAttributes, [attributeTypeID](const NodeAttribute* attribute) { - // remove the attribute we found and go again - RemoveAttribute(attributeNumber); - - // increase the number of removed attributes - numAttributesRemoved++; - } - - return numAttributesRemoved; + return attribute->GetType() == attributeTypeID; + }); } @@ -299,23 +201,23 @@ namespace EMotionFX // recursively find the root node (expensive call) Node* Node::FindRoot() const { - uint32 parentIndex = mParentIndex; - Node* curNode = const_cast(this); + size_t parentIndex = mParentIndex; + const Node* curNode = this; - while (parentIndex != MCORE_INVALIDINDEX32) + while (parentIndex != InvalidIndex) { curNode = mSkeleton->GetNode(parentIndex); parentIndex = curNode->GetParentIndex(); } - return curNode; + return const_cast(curNode); } // get the parent node, or nullptr when it doesn't exist Node* Node::GetParentNode() const { - if (mParentIndex != MCORE_INVALIDINDEX32) + if (mParentIndex != InvalidIndex) { return mSkeleton->GetNode(mParentIndex); } @@ -333,7 +235,7 @@ namespace EMotionFX } else { - mNameID = MCORE_INVALIDINDEX32; + mNameID = InvalidIndex; } } @@ -347,12 +249,12 @@ namespace EMotionFX } else { - mSemanticNameID = MCORE_INVALIDINDEX32; + mSemanticNameID = InvalidIndex; } } - void Node::SetParentIndex(uint32 parentNodeIndex) + void Node::SetParentIndex(size_t parentNodeIndex) { mParentIndex = parentNodeIndex; } @@ -389,7 +291,7 @@ namespace EMotionFX // returns true if this is a root node, so if it has no parents bool Node::GetIsRootNode() const { - return (mParentIndex == MCORE_INVALIDINDEX32); + return (mParentIndex == InvalidIndex); } @@ -407,7 +309,7 @@ namespace EMotionFX } - NodeAttribute* Node::GetAttribute(uint32 attributeNr) + NodeAttribute* Node::GetAttribute(size_t attributeNr) { // make sure we are in range MCORE_ASSERT(attributeNr < mAttributes.size()); @@ -417,72 +319,60 @@ namespace EMotionFX } - uint32 Node::FindAttributeNumber(uint32 attributeTypeID) const + size_t Node::FindAttributeNumber(uint32 attributeTypeID) const { // check all attributes, and find where the specific attribute is - const uint32 numAttributes = mAttributes.size(); - for (uint32 i = 0; i < numAttributes; ++i) + const auto foundAttribute = AZStd::find_if(begin(mAttributes), end(mAttributes), [attributeTypeID](const NodeAttribute* attribute) { - if (mAttributes[i]->GetType() == attributeTypeID) - { - return i; - } - } - - // not found - return MCORE_INVALIDINDEX32; + return attribute->GetType() == attributeTypeID; + }); + return foundAttribute != end(mAttributes) ? AZStd::distance(begin(mAttributes), foundAttribute) : InvalidIndex; } NodeAttribute* Node::GetAttributeByType(uint32 attributeType) { // check all attributes - const uint32 numAttributes = mAttributes.size(); - for (uint32 i = 0; i < numAttributes; ++i) + const auto foundAttribute = AZStd::find_if(begin(mAttributes), end(mAttributes), [attributeType](const NodeAttribute* attribute) { - if (mAttributes[i]->GetType() == attributeType) - { - return mAttributes[i]; - } - } - - // not found - return nullptr; + return attribute->GetType() == attributeType; + }); + return foundAttribute != end(mAttributes) ? *foundAttribute : nullptr; } // remove the given attribute - void Node::RemoveAttribute(uint32 index) + void Node::RemoveAttribute(size_t index) { mAttributes.erase(AZStd::next(begin(mAttributes), index)); } - void Node::AddChild(uint32 nodeIndex) + void Node::AddChild(size_t nodeIndex) { mChildIndices.emplace_back(nodeIndex); } - void Node::SetChild(uint32 childNr, uint32 childNodeIndex) + void Node::SetChild(size_t childNr, size_t childNodeIndex) { mChildIndices[childNr] = childNodeIndex; } - void Node::SetNumChildNodes(uint32 numChildNodes) + void Node::SetNumChildNodes(size_t numChildNodes) { mChildIndices.resize(numChildNodes); } - void Node::PreAllocNumChildNodes(uint32 numChildNodes) + void Node::PreAllocNumChildNodes(size_t numChildNodes) { mChildIndices.reserve(numChildNodes); } - void Node::RemoveChild(uint32 nodeIndex) + void Node::RemoveChild(size_t nodeIndex) { if (const auto it = AZStd::find(begin(mChildIndices), end(mChildIndices), nodeIndex); it != end(mChildIndices)) { @@ -499,11 +389,11 @@ namespace EMotionFX bool Node::GetHasChildNodes() const { - return (mChildIndices.size() > 0); + return !mChildIndices.empty(); } - void Node::SetNodeIndex(uint32 index) + void Node::SetNodeIndex(size_t index) { mNodeIndex = index; } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Node.h b/Gems/EMotionFX/Code/EMotionFX/Source/Node.h index 73e8a41c01..fe22a12c8d 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Node.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Node.h @@ -70,7 +70,7 @@ namespace EMotionFX * @param nameID The name ID, generated using the MCore::GetStringIdPool(). * @param skeleton The skeleton where this node will belong to, you still need to manually add it to the skeleton though. */ - static Node* Create(uint32 nameID, Skeleton* skeleton); + static Node* Create(size_t nameID, Skeleton* skeleton); /** * Clone the node. @@ -85,14 +85,14 @@ namespace EMotionFX * In that case this node is a root node. * @param parentNodeIndex The node index of the node where to link this node to. */ - void SetParentIndex(uint32 parentNodeIndex); + void SetParentIndex(size_t parentNodeIndex); /** * Get the parent node's index. * This is either a valid index, or MCORE_INVALIDINDEX32 in case there is no parent node. * @result The index of the parent node, or MCORE_INVALIDINDEX32 in case this node has no parent. */ - MCORE_INLINE uint32 GetParentIndex() const { return mParentIndex; } + MCORE_INLINE size_t GetParentIndex() const { return mParentIndex; } /** * Get the parent node as node pointer. @@ -105,7 +105,7 @@ namespace EMotionFX * @param parents The array to which parent and the parents of the parents of the node will be added. * @param clearParentsArray When true the given parents array will be cleared before filling it. */ - void RecursiveCollectParents(AZStd::vector& parents, bool clearParentsArray = true) const; + void RecursiveCollectParents(AZStd::vector& parents, bool clearParentsArray = true) const; /** * Set the node name. @@ -155,14 +155,14 @@ namespace EMotionFX * same ID number. * @result The node ID number, which can be used for fast compares between nodes. */ - MCORE_INLINE uint32 GetID() const { return mNameID; } + MCORE_INLINE size_t GetID() const { return mNameID; } /** * Get the semantic name ID. * To get the name you can also use GetSemanticName() and GetSemanticNameString(). * @result The semantic name ID. */ - MCORE_INLINE uint32 GetSemanticID() const { return mSemanticNameID; } + MCORE_INLINE size_t GetSemanticID() const { return mSemanticNameID; } /** * Get the number of child nodes attached to this node. @@ -175,48 +175,48 @@ namespace EMotionFX * The current node is not included in the count. * @return The total number of nodes down the hierarchy of this node. */ - uint32 GetNumChildNodesRecursive() const; + size_t GetNumChildNodesRecursive() const; /** * Get a given child's node index. * @param nr The child number. * @result The index of the child node, which is a node number inside the actor. */ - MCORE_INLINE uint32 GetChildIndex(uint32 nr) const { return mChildIndices[nr]; } + MCORE_INLINE size_t GetChildIndex(size_t nr) const { return mChildIndices[nr]; } /** * Checks if the given node is a child of this node. * @param nodeIndex The node to check whether it is a child or not. * @result True if the given node is a child, false if not. */ - MCORE_INLINE bool CheckIfIsChildNode(uint32 nodeIndex) const { return (AZStd::find(begin(mChildIndices), end(mChildIndices), nodeIndex) != end(mChildIndices)); } + MCORE_INLINE bool CheckIfIsChildNode(size_t nodeIndex) const { return (AZStd::find(begin(mChildIndices), end(mChildIndices), nodeIndex) != end(mChildIndices)); } /** * Add a child to this node. * @param nodeIndex The index of the child node to add. */ - void AddChild(uint32 nodeIndex); + void AddChild(size_t nodeIndex); /** * Set the value for a given child node. * @param childNr The child number, which must be in range of [0..GetNumChildNodes()-1]. * @param childNodeIndex The node index for this child. */ - void SetChild(uint32 childNr, uint32 childNodeIndex); + void SetChild(size_t childNr, size_t childNodeIndex); /** * Resize the array of child nodes. * This will grow the child node array so that the value returned by GetNumChildNodes() will return the same value as you specify as parameter here. * @param numChildNodes The number of child nodes to create. Be sure to initialize all of the child nodes using SetChild() though! */ - void SetNumChildNodes(uint32 numChildNodes); + void SetNumChildNodes(size_t numChildNodes); /** * Preallocate the array of child nodes. * Unlike SetNumChildNodes, this will NOT grow the child node array as reported by GetNumChildNodes(). However, it internally pre-allocates memory to make the AddChild() calls faster. * @param numChildNodes The number of child nodes to pre-allocate space for. */ - void PreAllocNumChildNodes(uint32 numChildNodes); + void PreAllocNumChildNodes(size_t numChildNodes); /** * Removes a given child (does not delete it from memory though). @@ -224,7 +224,7 @@ namespace EMotionFX * So you have to adjust the parent pointer of the child node manually. * @param nodeIndex The index of the child to remove. */ - void RemoveChild(uint32 nodeIndex); + void RemoveChild(size_t nodeIndex); /** * Removes all child nodes (not from memory though but just clears the childs pointers in this node). @@ -273,7 +273,7 @@ namespace EMotionFX * @result A pointer to the node attribute. * @see FindNodeAttributeNumber */ - NodeAttribute* GetAttribute(uint32 attributeNr); + NodeAttribute* GetAttribute(size_t attributeNr); /** * Get a given node attribute of a given type. @@ -289,7 +289,7 @@ namespace EMotionFX * @param attributeTypeID The attribute type ID (returned by NodeAttribute::GetType()). * @result The first located attribute number which is of the given type, or MCORE_INVALIDINDEX32 when the attribute of this type could not be located. */ - uint32 FindAttributeNumber(uint32 attributeTypeID) const; + size_t FindAttributeNumber(uint32 attributeTypeID) const; /** * Removes all node attributes from this node. @@ -301,7 +301,7 @@ namespace EMotionFX * Remove the given node attribute from this node. * @param index The index of the node attribute to remove. */ - void RemoveAttribute(uint32 index); + void RemoveAttribute(size_t index); /** * Remove the given node attribute from this node which occurs at the given position. @@ -311,14 +311,14 @@ namespace EMotionFX * @param occurrence The number of node attributes which will be skipped until we reached the * node to remove. */ - void RemoveAttributeByType(uint32 attributeTypeID, uint32 occurrence = 0); + void RemoveAttributeByType(uint32 attributeTypeID, size_t occurrence = 0); /** * Removes all node attributes from this node of the given type. * @param attributeTypeID The attribute type ID (returned by NodeAttribute::GetType()). * @result The number of attributes that have been removed. */ - uint32 RemoveAllAttributesByType(uint32 attributeTypeID); + size_t RemoveAllAttributesByType(uint32 attributeTypeID); //-------------------------------------------- @@ -328,7 +328,7 @@ namespace EMotionFX * So Actor::GetNode( nodeIndex ) will return this node. * @param index The index to use. */ - void SetNodeIndex(uint32 index); + void SetNodeIndex(size_t index); /** * Get the node index value. @@ -336,7 +336,7 @@ namespace EMotionFX * So Actor::GetNode( nodeIndex ) will return this node. * @result The index of the node. */ - MCORE_INLINE uint32 GetNodeIndex() const { return mNodeIndex; } + MCORE_INLINE size_t GetNodeIndex() const { return mNodeIndex; } //------------------------------ @@ -364,7 +364,7 @@ namespace EMotionFX * @param lodLevel The skeletal LOD level to check. * @result Returns true when this node is enabled in the specified LOD level. Otherwise false is returned. */ - MCORE_INLINE bool GetSkeletalLODStatus(uint32 lodLevel) const { return (mSkeletalLODs & (1 << lodLevel)) != 0; } + MCORE_INLINE bool GetSkeletalLODStatus(size_t lodLevel) const { return (mSkeletalLODs & (1 << lodLevel)) != 0; } //-------------------------------------------- @@ -415,13 +415,13 @@ namespace EMotionFX void SetIsAttachmentNode(bool isAttachmentNode); private: - uint32 mNodeIndex; /**< The node index, which is the index into the array of nodes inside the Skeleton class. */ - uint32 mParentIndex; /**< The parent node index, or MCORE_INVALIDINDEX32 when there is no parent. */ + size_t mNodeIndex; /**< The node index, which is the index into the array of nodes inside the Skeleton class. */ + size_t mParentIndex; /**< The parent node index, or MCORE_INVALIDINDEX32 when there is no parent. */ uint32 mSkeletalLODs; /**< The skeletal LOD status values. Each bit represents if this node is enabled or disabled in the given LOD. */ - uint32 mNameID; /**< The ID, which is generated from the name. You can use this for fast compares between nodes. */ - uint32 mSemanticNameID; /**< The semantic name ID, for example "LeftHand" or "RightFoot" or so, this can be used for retargeting. */ + size_t mNameID; /**< The ID, which is generated from the name. You can use this for fast compares between nodes. */ + size_t mSemanticNameID; /**< The semantic name ID, for example "LeftHand" or "RightFoot" or so, this can be used for retargeting. */ Skeleton* mSkeleton; /**< The skeleton where this node belongs to. */ - AZStd::vector mChildIndices; /**< The indices that point to the child nodes. */ + AZStd::vector mChildIndices; /**< The indices that point to the child nodes. */ AZStd::vector mAttributes; /**< The node attributes. */ uint8 mNodeFlags; /**< The node flags are used to store boolean attributes of the node as single bits. */ @@ -437,7 +437,7 @@ namespace EMotionFX * @param nameID The name ID, generated using the MCore::GetStringIdPool(). * @param skeleton The skeleton where this node will belong to. */ - Node(uint32 nameID, Skeleton* skeleton); + Node(size_t nameID, Skeleton* skeleton); /** * The destructor. @@ -450,6 +450,6 @@ namespace EMotionFX * Recursively count the number of nodes down the hierarchy of this node. * @param numNodes The integer containing the current node count. This counter will be increased during recursion. */ - void RecursiveCountChildNodes(uint32& numNodes); + void RecursiveCountChildNodes(size_t& numNodes); }; } // namespace EMotionFX diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/NodeAttribute.h b/Gems/EMotionFX/Code/EMotionFX/Source/NodeAttribute.h index 30bfbe280c..6fb310d15d 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/NodeAttribute.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/NodeAttribute.h @@ -42,7 +42,7 @@ namespace EMotionFX * Clone the node attribute. * @result Returns a pointer to a newly created exact copy of the node attribute. */ - virtual NodeAttribute* Clone() = 0; + virtual NodeAttribute* Clone() const = 0; protected: /** diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Pose.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Pose.cpp index e42393212d..08581e919e 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Pose.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Pose.cpp @@ -114,16 +114,16 @@ namespace EMotionFX } // - void Pose::SetNumTransforms(uint32 numTransforms) + void Pose::SetNumTransforms(size_t numTransforms) { // resize the buffers mLocalSpaceTransforms.ResizeFast(numTransforms); mModelSpaceTransforms.ResizeFast(numTransforms); - const uint32 oldSize = mFlags.GetLength(); + const size_t oldSize = mFlags.GetLength(); mFlags.ResizeFast(numTransforms); - for (uint32 i = oldSize; i < numTransforms; ++i) + for (size_t i = oldSize; i < numTransforms; ++i) { mFlags[i] = 0; SetLocalSpaceTransform(i, Transform::CreateIdentity()); @@ -257,7 +257,7 @@ namespace EMotionFX // recursively update - void Pose::UpdateModelSpaceTransform(uint32 nodeIndex) const + void Pose::UpdateModelSpaceTransform(size_t nodeIndex) const { Skeleton* skeleton = mActor->GetSkeleton(); @@ -286,7 +286,7 @@ namespace EMotionFX // update the local transform - void Pose::UpdateLocalSpaceTransform(uint32 nodeIndex) const + void Pose::UpdateLocalSpaceTransform(size_t nodeIndex) const { const uint32 flags = mFlags[nodeIndex]; if (flags & FLAG_LOCALTRANSFORMREADY) @@ -316,28 +316,28 @@ namespace EMotionFX // get the local transform - const Transform& Pose::GetLocalSpaceTransform(uint32 nodeIndex) const + const Transform& Pose::GetLocalSpaceTransform(size_t nodeIndex) const { UpdateLocalSpaceTransform(nodeIndex); return mLocalSpaceTransforms[nodeIndex]; } - const Transform& Pose::GetModelSpaceTransform(uint32 nodeIndex) const + const Transform& Pose::GetModelSpaceTransform(size_t nodeIndex) const { UpdateModelSpaceTransform(nodeIndex); return mModelSpaceTransforms[nodeIndex]; } - Transform Pose::GetWorldSpaceTransform(uint32 nodeIndex) const + Transform Pose::GetWorldSpaceTransform(size_t nodeIndex) const { UpdateModelSpaceTransform(nodeIndex); return mModelSpaceTransforms[nodeIndex].Multiplied(mActorInstance->GetWorldSpaceTransform()); } - void Pose::GetWorldSpaceTransform(uint32 nodeIndex, Transform* outResult) const + void Pose::GetWorldSpaceTransform(size_t nodeIndex, Transform* outResult) const { UpdateModelSpaceTransform(nodeIndex); *outResult = mModelSpaceTransforms[nodeIndex]; @@ -346,7 +346,7 @@ namespace EMotionFX // calculate a local transform - void Pose::GetLocalSpaceTransform(uint32 nodeIndex, Transform* outResult) const + void Pose::GetLocalSpaceTransform(size_t nodeIndex, Transform* outResult) const { if ((mFlags[nodeIndex] & FLAG_LOCALTRANSFORMREADY) == false) { @@ -357,7 +357,7 @@ namespace EMotionFX } - void Pose::GetModelSpaceTransform(uint32 nodeIndex, Transform* outResult) const + void Pose::GetModelSpaceTransform(size_t nodeIndex, Transform* outResult) const { UpdateModelSpaceTransform(nodeIndex); *outResult = mModelSpaceTransforms[nodeIndex]; @@ -365,7 +365,7 @@ namespace EMotionFX // set the local transform - void Pose::SetLocalSpaceTransform(uint32 nodeIndex, const Transform& newTransform, bool invalidateGlobalTransforms) + void Pose::SetLocalSpaceTransform(size_t nodeIndex, const Transform& newTransform, bool invalidateGlobalTransforms) { mLocalSpaceTransforms[nodeIndex] = newTransform; mFlags[nodeIndex] |= FLAG_LOCALTRANSFORMREADY; @@ -382,7 +382,7 @@ namespace EMotionFX // mark all child nodes recursively as dirty - void Pose::RecursiveInvalidateModelSpaceTransforms(const Actor* actor, uint32 nodeIndex) + void Pose::RecursiveInvalidateModelSpaceTransforms(const Actor* actor, size_t nodeIndex) { // if this model space transform ain't ready yet assume all child nodes are also not if ((mFlags[nodeIndex] & FLAG_MODELTRANSFORMREADY) == false) @@ -396,15 +396,15 @@ namespace EMotionFX // recurse through all child nodes Skeleton* skeleton = actor->GetSkeleton(); Node* node = skeleton->GetNode(nodeIndex); - const uint32 numChildNodes = node->GetNumChildNodes(); - for (uint32 i = 0; i < numChildNodes; ++i) + const size_t numChildNodes = node->GetNumChildNodes(); + for (size_t i = 0; i < numChildNodes; ++i) { RecursiveInvalidateModelSpaceTransforms(actor, node->GetChildIndex(i)); } } - void Pose::SetModelSpaceTransform(uint32 nodeIndex, const Transform& newTransform, bool invalidateChildGlobalTransforms) + void Pose::SetModelSpaceTransform(size_t nodeIndex, const Transform& newTransform, bool invalidateChildGlobalTransforms) { mModelSpaceTransforms[nodeIndex] = newTransform; @@ -423,7 +423,7 @@ namespace EMotionFX } - void Pose::SetWorldSpaceTransform(uint32 nodeIndex, const Transform& newTransform, bool invalidateChildGlobalTransforms) + void Pose::SetWorldSpaceTransform(size_t nodeIndex, const Transform& newTransform, bool invalidateChildGlobalTransforms) { mModelSpaceTransforms[nodeIndex] = newTransform.Multiplied(mActorInstance->GetWorldSpaceTransformInversed()); mFlags[nodeIndex] &= ~FLAG_LOCALTRANSFORMREADY; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Pose.h b/Gems/EMotionFX/Code/EMotionFX/Source/Pose.h index ae3cfc7031..ef9653e728 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Pose.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Pose.h @@ -53,7 +53,7 @@ namespace EMotionFX void LinkToActorInstance(const ActorInstance* actorInstance, uint8 initialFlags = 0); void LinkToActor(const Actor* actor, uint8 initialFlags = 0, bool clearAllFlags = true); - void SetNumTransforms(uint32 numTransforms); + void SetNumTransforms(size_t numTransforms); void ApplyMorphWeightsToActorInstance(); void ZeroMorphWeights(); @@ -63,20 +63,20 @@ namespace EMotionFX void ForceUpdateFullLocalSpacePose(); void ForceUpdateFullModelSpacePose(); - const Transform& GetLocalSpaceTransform(uint32 nodeIndex) const; - const Transform& GetModelSpaceTransform(uint32 nodeIndex) const; - Transform GetWorldSpaceTransform(uint32 nodeIndex) const; + const Transform& GetLocalSpaceTransform(size_t nodeIndex) const; + const Transform& GetModelSpaceTransform(size_t nodeIndex) const; + Transform GetWorldSpaceTransform(size_t nodeIndex) const; - void GetLocalSpaceTransform(uint32 nodeIndex, Transform* outResult) const; - void GetModelSpaceTransform(uint32 nodeIndex, Transform* outResult) const; - void GetWorldSpaceTransform(uint32 nodeIndex, Transform* outResult) const; + void GetLocalSpaceTransform(size_t nodeIndex, Transform* outResult) const; + void GetModelSpaceTransform(size_t nodeIndex, Transform* outResult) const; + void GetWorldSpaceTransform(size_t nodeIndex, Transform* outResult) const; - void SetLocalSpaceTransform(uint32 nodeIndex, const Transform& newTransform, bool invalidateModelSpaceTransforms = true); - void SetModelSpaceTransform(uint32 nodeIndex, const Transform& newTransform, bool invalidateChildModelSpaceTransforms = true); - void SetWorldSpaceTransform(uint32 nodeIndex, const Transform& newTransform, bool invalidateChildModelSpaceTransforms = true); + void SetLocalSpaceTransform(size_t nodeIndex, const Transform& newTransform, bool invalidateModelSpaceTransforms = true); + void SetModelSpaceTransform(size_t nodeIndex, const Transform& newTransform, bool invalidateChildModelSpaceTransforms = true); + void SetWorldSpaceTransform(size_t nodeIndex, const Transform& newTransform, bool invalidateChildModelSpaceTransforms = true); - void UpdateModelSpaceTransform(uint32 nodeIndex) const; - void UpdateLocalSpaceTransform(uint32 nodeIndex) const; + void UpdateModelSpaceTransform(size_t nodeIndex) const; + void UpdateLocalSpaceTransform(size_t nodeIndex) const; void CompensateForMotionExtraction(EMotionExtractionFlags motionExtractionFlags = (EMotionExtractionFlags)0); void CompensateForMotionExtractionDirect(EMotionExtractionFlags motionExtractionFlags = (EMotionExtractionFlags)0); @@ -202,7 +202,7 @@ namespace EMotionFX const Actor* mActor; const Skeleton* mSkeleton; - void RecursiveInvalidateModelSpaceTransforms(const Actor* actor, uint32 nodeIndex); + void RecursiveInvalidateModelSpaceTransforms(const Actor* actor, size_t nodeIndex); /** * Perform a non-mixed blend into the specified destination pose. diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/RagdollInstance.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/RagdollInstance.cpp index 98b4275791..93d4cd19d1 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/RagdollInstance.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/RagdollInstance.cpp @@ -67,7 +67,7 @@ namespace EMotionFX } else { - m_ragdollNodeIndices[jointIndex] = MCORE_INVALIDINDEX32; + m_ragdollNodeIndices[jointIndex] = InvalidIndex; } } @@ -256,7 +256,7 @@ namespace EMotionFX const AZ::Outcome RagdollInstance::GetRagdollNodeIndex(size_t jointIndex) const { const size_t ragdollNodeIndex = m_ragdollNodeIndices[jointIndex]; - if (ragdollNodeIndex == MCORE_INVALIDINDEX32) + if (ragdollNodeIndex == InvalidIndex) { return AZ::Failure(); } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Recorder.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Recorder.cpp index 41c7c1e929..923c74aa02 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Recorder.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Recorder.cpp @@ -930,7 +930,7 @@ namespace EMotionFX } // check if we have an active node for the given item - size_t index = MCORE_INVALIDINDEX32; + size_t index = InvalidIndex; for (size_t x = 0; x < numActiveNodes; ++x) { if (mActiveNodes[x]->GetId() == curItem->mNodeId) @@ -941,7 +941,7 @@ namespace EMotionFX } // the node got deactivated, finalize the item - if (index == MCORE_INVALIDINDEX32) + if (index == InvalidIndex) { curItem->mGlobalWeights.Optimize(0.0001f); curItem->mLocalWeights.Optimize(0.0001f); diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/SimulatedObjectSetup.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/SimulatedObjectSetup.cpp index 8c98bad5a4..006be1d9a5 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/SimulatedObjectSetup.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/SimulatedObjectSetup.cpp @@ -280,7 +280,7 @@ namespace EMotionFX { if (m_object) { - return m_object->GetSimulatedRootJointIndex(this) != MCORE_INVALIDINDEX32; + return m_object->GetSimulatedRootJointIndex(this) != InvalidIndex; } return false; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Skeleton.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Skeleton.cpp index 5860a0b452..24983c3a71 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Skeleton.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Skeleton.cpp @@ -44,14 +44,13 @@ namespace EMotionFX { Skeleton* result = Skeleton::Create(); - const uint32 numNodes = m_nodes.size(); - result->ReserveNodes(numNodes); + result->ReserveNodes(m_nodes.size()); result->m_rootNodes = m_rootNodes; // clone the nodes - for (uint32 i = 0; i < numNodes; ++i) + for (const Node* node : m_nodes) { - result->AddNode(m_nodes[i]->Clone(result)); + result->AddNode(node->Clone(result)); } result->m_bindPose = m_bindPose; @@ -61,7 +60,7 @@ namespace EMotionFX // reserve memory - void Skeleton::ReserveNodes(uint32 numNodes) + void Skeleton::ReserveNodes(size_t numNodes) { m_nodes.reserve(numNodes); } @@ -76,7 +75,7 @@ namespace EMotionFX // remove a node - void Skeleton::RemoveNode(uint32 nodeIndex, bool delFromMem) + void Skeleton::RemoveNode(size_t nodeIndex, bool delFromMem) { m_nodesMap.erase(m_nodes[nodeIndex]->GetNameString()); if (delFromMem) @@ -93,10 +92,9 @@ namespace EMotionFX { if (delFromMem) { - const uint32 numNodes = m_nodes.size(); - for (uint32 i = 0; i < numNodes; ++i) + for (Node* node : m_nodes) { - m_nodes[i]->Destroy(); + node->Destroy(); } } @@ -132,38 +130,28 @@ namespace EMotionFX Node* Skeleton::FindNodeByNameNoCase(const char* name) const { // check the names for all nodes - const uint32 numNodes = m_nodes.size(); - for (uint32 i = 0; i < numNodes; ++i) + const auto foundNode = AZStd::find_if(begin(m_nodes), end(m_nodes), [name](const Node* node) { - if (AzFramework::StringFunc::Equal(m_nodes[i]->GetNameString().c_str(), name, false /* no case */)) - { - return m_nodes[i]; - } - } - - return nullptr; + return AzFramework::StringFunc::Equal(node->GetNameString(), name, false /* no case */); + }); + return foundNode != end(m_nodes) ? *foundNode : nullptr; } // search for a node on ID - Node* Skeleton::FindNodeByID(uint32 id) const + Node* Skeleton::FindNodeByID(size_t id) const { // check the ID's for all nodes - const uint32 numNodes = m_nodes.size(); - for (uint32 i = 0; i < numNodes; ++i) + const auto foundNode = AZStd::find_if(begin(m_nodes), end(m_nodes), [id](const Node* node) { - if (m_nodes[i]->GetID() == id) - { - return m_nodes[i]; - } - } - - return nullptr; + return node->GetID() == id; + }); + return foundNode != end(m_nodes) ? *foundNode : nullptr; } // set a given node - void Skeleton::SetNode(uint32 index, Node* node) + void Skeleton::SetNode(size_t index, Node* node) { if (m_nodes[index]) { @@ -176,11 +164,11 @@ namespace EMotionFX // set the number of nodes - void Skeleton::SetNumNodes(uint32 numNodes) + void Skeleton::SetNumNodes(size_t numNodes) { - uint32 oldLength = m_nodes.size(); + size_t oldLength = m_nodes.size(); m_nodes.resize(numNodes); - for (uint32 i = oldLength; i < numNodes; ++i) + for (size_t i = oldLength; i < numNodes; ++i) { m_nodes[i] = nullptr; } @@ -189,10 +177,10 @@ namespace EMotionFX // update the node indices - void Skeleton::UpdateNodeIndexValues(uint32 startNode) + void Skeleton::UpdateNodeIndexValues(size_t startNode) { - const uint32 numNodes = m_nodes.size(); - for (uint32 i = startNode; i < numNodes; ++i) + const size_t numNodes = m_nodes.size(); + for (size_t i = startNode; i < numNodes; ++i) { m_nodes[i]->SetNodeIndex(i); } @@ -200,21 +188,21 @@ namespace EMotionFX // reserve memory for the root nodes array - void Skeleton::ReserveRootNodes(uint32 numNodes) + void Skeleton::ReserveRootNodes(size_t numNodes) { m_rootNodes.reserve(numNodes); } // add a root node - void Skeleton::AddRootNode(uint32 nodeIndex) + void Skeleton::AddRootNode(size_t nodeIndex) { m_rootNodes.emplace_back(nodeIndex); } // remove a given root node - void Skeleton::RemoveRootNode(uint32 nr) + void Skeleton::RemoveRootNode(size_t nr) { m_rootNodes.erase(AZStd::next(begin(m_rootNodes), nr)); } @@ -230,8 +218,8 @@ namespace EMotionFX // log all node names void Skeleton::LogNodes() { - const uint32 numNodes = m_nodes.size(); - for (uint32 i = 0; i < numNodes; ++i) + const size_t numNodes = m_nodes.size(); + for (size_t i = 0; i < numNodes; ++i) { MCore::LogInfo("%d = '%s'", i, m_nodes[i]->GetName()); } @@ -239,10 +227,10 @@ namespace EMotionFX // calculate the hierarchy depth for a given node - uint32 Skeleton::CalcHierarchyDepthForNode(uint32 nodeIndex) const + size_t Skeleton::CalcHierarchyDepthForNode(size_t nodeIndex) const { - uint32 result = 0; - Node* curNode = m_nodes[nodeIndex]; + size_t result = 0; + const Node* curNode = m_nodes[nodeIndex]; while (curNode->GetParentNode()) { result++; @@ -253,18 +241,18 @@ namespace EMotionFX } - Node* Skeleton::FindNodeAndIndexByName(const AZStd::string& name, AZ::u32& outIndex) const + Node* Skeleton::FindNodeAndIndexByName(const AZStd::string& name, size_t& outIndex) const { if (name.empty()) { - outIndex = MCORE_INVALIDINDEX32; + outIndex = InvalidIndex; return nullptr; } Node* joint = FindNodeByNameNoCase(name.c_str()); if (!joint) { - outIndex = MCORE_INVALIDINDEX32; + outIndex = InvalidIndex; return nullptr; } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Skeleton.h b/Gems/EMotionFX/Code/EMotionFX/Source/Skeleton.h index e5887df0f6..01d3e9dee8 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Skeleton.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Skeleton.h @@ -33,11 +33,11 @@ namespace EMotionFX Skeleton* Clone(); MCORE_INLINE size_t GetNumNodes() const { return m_nodes.size(); } - MCORE_INLINE Node* GetNode(uint32 index) const { return m_nodes[index]; } + MCORE_INLINE Node* GetNode(size_t index) const { return m_nodes[index]; } - void ReserveNodes(uint32 numNodes); + void ReserveNodes(size_t numNodes); void AddNode(Node* node); - void RemoveNode(uint32 nodeIndex, bool delFromMem = true); + void RemoveNode(size_t nodeIndex, bool delFromMem = true); void RemoveAllNodes(bool delFromMem = true); MCORE_INLINE const Pose* GetBindPose() const { return &m_bindPose; } @@ -57,7 +57,7 @@ namespace EMotionFX * @param outIndex This will contain the resulting index, or MCORE_INVALIDINDEX32 in case not found. * @result This returns a pointer to the joint or nullptr when not found. In case of a nullptr, the outIndex will be set to MCORE_INVALIDINDEX32 as well. */ - Node* FindNodeAndIndexByName(const AZStd::string& name, AZ::u32& outIndex) const; + Node* FindNodeAndIndexByName(const AZStd::string& name, size_t& outIndex) const; /** * Search for a node by name (non case sensitive), returns nullptr when no node can be found. @@ -75,21 +75,21 @@ namespace EMotionFX * @param id The ID to search for. * @return A pointer to the node, or nullptr when no node with the given ID found. */ - Node* FindNodeByID(uint32 id) const; + Node* FindNodeByID(size_t id) const; /** * Set the value of a given node. * @param index The node number, which must be in range of [0..GetNumNodes()-1]. * @param node The node value to set at this index. */ - void SetNode(uint32 index, Node* node); + void SetNode(size_t index, Node* node); /** * Set the number of nodes. * This resizes the array of pointers to nodes, but doesn't actually create the nodes. * @param numNodes The number of nodes to allocate space for. */ - void SetNumNodes(uint32 numNodes); + void SetNumNodes(size_t numNodes); /** * Update all the node index values that are returned by the Node::GetNodeIndex() method. @@ -97,7 +97,7 @@ namespace EMotionFX * the nodes have to be updated. As node number 5 could become node number 4 in the example case. * @param startNode The node number to start updating from. */ - void UpdateNodeIndexValues(uint32 startNode = 0); + void UpdateNodeIndexValues(size_t startNode = 0); /** * Get the number of root nodes in the actor. A root node is a node without any parent. @@ -110,28 +110,28 @@ namespace EMotionFX * @param nr The root node number, which must be in range of [0..GetNumRootNodes()-1]. * @result The node index of the given root node. */ - MCORE_INLINE uint32 GetRootNodeIndex(uint32 nr) const { return m_rootNodes[nr]; } + MCORE_INLINE size_t GetRootNodeIndex(size_t nr) const { return m_rootNodes[nr]; } /** * Pre-allocate space for the root nodes array. * This does not alter the value returned by GetNumRootNodes() though. * @param numNodes The absolute number of nodes to pre-allocate space for. */ - void ReserveRootNodes(uint32 numNodes); + void ReserveRootNodes(size_t numNodes); /** * Add a root node to the actor. * This doesn't modify the node itself, but it will add the node to the list of root nodes. * @param nodeIndex The node number/index to add and mark as root node inside the actor. */ - void AddRootNode(uint32 nodeIndex); + void AddRootNode(size_t nodeIndex); /** * Remove a given root node from the list of root nodes stored inside the actor. * This doesn't really remove the node itself, but it just unregisters it as root node inside the actor. * @param nr The root node to remove, which must be in range of [0..GetNumRootNodes()-1]. */ - void RemoveRootNode(uint32 nr); + void RemoveRootNode(size_t nr); /** * Removes all root nodes from the actor. @@ -141,12 +141,12 @@ namespace EMotionFX void RemoveAllRootNodes(); void LogNodes(); - uint32 CalcHierarchyDepthForNode(uint32 nodeIndex) const; + size_t CalcHierarchyDepthForNode(size_t nodeIndex) const; private: AZStd::vector m_nodes; /**< The nodes, including root nodes. */ mutable AZStd::unordered_map m_nodesMap; - AZStd::vector m_rootNodes; /**< The root nodes only. */ + AZStd::vector m_rootNodes; /**< The root nodes only. */ Pose m_bindPose; /**< The bind pose. */ Skeleton(); diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/SoftSkinDeformer.h b/Gems/EMotionFX/Code/EMotionFX/Source/SoftSkinDeformer.h index 497f38f764..33596e6809 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/SoftSkinDeformer.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/SoftSkinDeformer.h @@ -114,7 +114,7 @@ namespace EMotionFX * This does not alter the value returned by GetNumLocalBones(). * @param numBones The number of bones to pre-allocate space for. */ - MCORE_INLINE void ReserveLocalBones(uint32 numBones) { mNodeNumbers.reserve(numBones); mBoneMatrices.reserve(numBones); } + MCORE_INLINE void ReserveLocalBones(size_t numBones) { mNodeNumbers.reserve(numBones); mBoneMatrices.reserve(numBones); } protected: diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp index adaea2e6c2..8765a0e991 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp @@ -47,7 +47,7 @@ namespace EMotionFX m_collisionObjects.reserve(3); } - void SpringSolver::CreateCollider(AZ::u32 skeletonJointIndex, const AzPhysics::ShapeColliderPair& shapePair) + void SpringSolver::CreateCollider(size_t skeletonJointIndex, const AzPhysics::ShapeColliderPair& shapePair) { const Physics::ShapeConfiguration* shapeConfig = shapePair.second.get(); if (!shapeConfig) @@ -77,7 +77,7 @@ namespace EMotionFX { if (exclusionColliderTag == colliderTag) { - const AZ::u32 colliderIndex = aznumeric_caster(m_collisionObjects.size() - 1); + const size_t colliderIndex = m_collisionObjects.size() - 1; particle.m_colliderExclusions.emplace_back(colliderIndex); break; } @@ -105,7 +105,7 @@ namespace EMotionFX if (shapePair.first->m_tag == colliderTag) { // Make sure we can find the joint in the skeleton. - AZ::u32 skeletonJointIndex; + size_t skeletonJointIndex; if (!actor->GetSkeleton()->FindNodeAndIndexByName(nodeConfig.m_name, skeletonJointIndex)) { AZ_Warning("EMotionFX", false, "Cannot find joint '%s' to attach the collider to. Skipping this collider inside simulation '%s'.", nodeConfig.m_name.c_str(), m_name.c_str()); @@ -176,7 +176,7 @@ namespace EMotionFX } } - void SpringSolver::CheckAndExcludeCollider(AZ::u32 colliderIndex, const SimulatedJoint* joint) + void SpringSolver::CheckAndExcludeCollider(size_t colliderIndex, const SimulatedJoint* joint) { const size_t particleIndex = FindParticle(joint->GetSkeletonJointIndex()); AZ_Assert(particleIndex != InvalidIndex, "Expected particle to be found for this joint."); @@ -208,7 +208,7 @@ namespace EMotionFX const size_t numColliders = m_collisionObjects.size(); for (size_t colliderIndex = 0; colliderIndex < numColliders; ++colliderIndex) { - CheckAndExcludeCollider(static_cast(colliderIndex), joint); + CheckAndExcludeCollider(colliderIndex, joint); } break; } @@ -221,7 +221,7 @@ namespace EMotionFX { if (m_collisionObjects[colliderIndex].m_jointIndex == joint->GetSkeletonJointIndex()) { - CheckAndExcludeCollider(static_cast(colliderIndex), joint); + CheckAndExcludeCollider(colliderIndex, joint); } } break; @@ -235,13 +235,13 @@ namespace EMotionFX { if (joint->GetSkeletonJointIndex() == m_collisionObjects[colliderIndex].m_jointIndex) { - CheckAndExcludeCollider(static_cast(colliderIndex), joint); + CheckAndExcludeCollider(colliderIndex, joint); } const SimulatedJoint* parentJoint = joint->FindParentSimulatedJoint(); if (parentJoint && parentJoint->GetSkeletonJointIndex() == m_collisionObjects[colliderIndex].m_jointIndex) { - CheckAndExcludeCollider(static_cast(colliderIndex), joint); + CheckAndExcludeCollider(colliderIndex, joint); } const size_t numChildJoints = joint->CalculateNumChildSimulatedJoints(); @@ -250,7 +250,7 @@ namespace EMotionFX const SimulatedJoint* childJoint = joint->FindChildSimulatedJoint(childIndex); if (m_collisionObjects[colliderIndex].m_jointIndex == childJoint->GetSkeletonJointIndex()) { - CheckAndExcludeCollider(static_cast(colliderIndex), joint); + CheckAndExcludeCollider(colliderIndex, joint); } } } @@ -271,8 +271,8 @@ namespace EMotionFX SpringSolver::Particle* SpringSolver::AddJoint(const SimulatedJoint* joint) { AZ_Assert(joint, "Expected the joint be a valid pointer."); - const AZ::u32 jointIndex = joint->GetSkeletonJointIndex(); - if (jointIndex == InvalidIndex32) + const size_t jointIndex = joint->GetSkeletonJointIndex(); + if (jointIndex == InvalidIndex) { return nullptr; } @@ -409,8 +409,8 @@ namespace EMotionFX // Initialize all rest lengths. for (Spring& spring : m_springs) { - const AZ::u32 jointIndexA = m_particles[spring.m_particleA].m_joint->GetSkeletonJointIndex(); - const AZ::u32 jointIndexB = m_particles[spring.m_particleB].m_joint->GetSkeletonJointIndex(); + const size_t jointIndexA = m_particles[spring.m_particleA].m_joint->GetSkeletonJointIndex(); + const size_t jointIndexB = m_particles[spring.m_particleB].m_joint->GetSkeletonJointIndex(); const Pose* bindPose = m_actorInstance->GetTransformData()->GetBindPose(); const float restLength = (bindPose->GetModelSpaceTransform(jointIndexB).mPosition - bindPose->GetModelSpaceTransform(jointIndexA).mPosition).GetLength(); if (restLength > AZ::Constants::FloatEpsilon) @@ -526,7 +526,7 @@ namespace EMotionFX return m_gravity; } - size_t SpringSolver::FindParticle(AZ::u32 jointIndex) const + size_t SpringSolver::FindParticle(size_t jointIndex) const { const size_t numParticles = m_particles.size(); for (size_t i = 0; i < numParticles; ++i) @@ -564,14 +564,14 @@ namespace EMotionFX particle.m_joint = joint; particle.m_pos = m_actorInstance->GetTransformData()->GetBindPose()->GetModelSpaceTransform(joint->GetSkeletonJointIndex()).mPosition; particle.m_oldPos = particle.m_pos; - particle.m_parentParticleIndex = static_cast(m_parentParticle); + particle.m_parentParticleIndex = m_parentParticle; m_particles.emplace_back(particle); return m_particles.size() - 1; } - bool SpringSolver::AddSupportSpring(AZ::u32 nodeA, AZ::u32 nodeB, float restLength) + bool SpringSolver::AddSupportSpring(size_t nodeA, size_t nodeB, float restLength) { - if (nodeA == InvalidIndex32 || nodeB == InvalidIndex32) + if (nodeA == InvalidIndex || nodeB == InvalidIndex) { return false; } @@ -608,7 +608,7 @@ namespace EMotionFX return AddSupportSpring(nodeA->GetNodeIndex(), nodeB->GetNodeIndex(), restLength); } - bool SpringSolver::RemoveJoint(AZ::u32 jointIndex) + bool SpringSolver::RemoveJoint(size_t jointIndex) { const size_t particleIndex = FindParticle(jointIndex); if (particleIndex == InvalidIndex) @@ -646,7 +646,7 @@ namespace EMotionFX return RemoveJoint(node->GetNodeIndex()); } - bool SpringSolver::RemoveSupportSpring(AZ::u32 jointIndexA, AZ::u32 jointIndexB) + bool SpringSolver::RemoveSupportSpring(size_t jointIndexA, size_t jointIndexB) { const size_t particleA = FindParticle(jointIndexA); if (particleA == InvalidIndex) @@ -833,7 +833,7 @@ namespace EMotionFX // Apply cone limit when needed. if (particleB.m_joint->GetConeAngleLimit() < 180.0f - 0.001f) { - if (particleB.m_parentParticleIndex != InvalidIndex32) + if (particleB.m_parentParticleIndex != InvalidIndex) { particleB.m_limitDir = particleB.m_pos - m_particles[particleB.m_parentParticleIndex].m_pos; } @@ -1008,7 +1008,7 @@ namespace EMotionFX { for (CollisionObject& colObject : m_collisionObjects) { - if (colObject.m_jointIndex != InvalidIndex32) + if (colObject.m_jointIndex != InvalidIndex) { const Transform jointWorldTransform = pose.GetWorldSpaceTransform(colObject.m_jointIndex); colObject.m_globalStart = jointWorldTransform.TransformPoint(colObject.m_start); @@ -1028,7 +1028,7 @@ namespace EMotionFX { for (CollisionObject& colObject : m_collisionObjects) { - if (colObject.m_jointIndex != InvalidIndex32) + if (colObject.m_jointIndex != InvalidIndex) { const Transform& jointTransform = pose.GetModelSpaceTransform(colObject.m_jointIndex); colObject.m_globalStart = jointTransform.TransformPoint(colObject.m_start); @@ -1072,7 +1072,7 @@ namespace EMotionFX for (size_t colliderIndex = 0; colliderIndex < numColliders; ++colliderIndex) { // Skip colliders in the exclusion list. - if (AZStd::find(particle.m_colliderExclusions.begin(), particle.m_colliderExclusions.end(), static_cast(colliderIndex)) != particle.m_colliderExclusions.end()) + if (AZStd::find(particle.m_colliderExclusions.begin(), particle.m_colliderExclusions.end(), colliderIndex) != particle.m_colliderExclusions.end()) { continue; } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h index 6d4b2e8128..ce77d1c655 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h @@ -54,8 +54,8 @@ namespace EMotionFX AZ::Vector3 m_force = AZ::Vector3::CreateZero(); /**< The internal force, which contains the gravity and other pulling and pushing forces. */ AZ::Vector3 m_externalForce = AZ::Vector3::CreateZero(); /**< A user defined external force, which is added on top of the internal force. Can be used to simulate wind etc. */ AZ::Vector3 m_limitDir = AZ::Vector3::CreateZero(); /**< The joint limit direction vector, used for the cone angle limit. This is the center direction of the cone. */ - AZStd::vector m_colliderExclusions; /**< Index values inside the collider array. Colliders listed in this list should be ignored durin collision detection. */ - AZ::u32 m_parentParticleIndex = ~0U; /**< The parent particle index. */ + AZStd::vector m_colliderExclusions; /**< Index values inside the collider array. Colliders listed in this list should be ignored durin collision detection. */ + size_t m_parentParticleIndex = InvalidIndex; /**< The parent particle index. */ }; class EMFX_API CollisionObject @@ -76,7 +76,7 @@ namespace EMotionFX private: CollisionType m_type = CollisionType::Sphere; /**< The collision primitive type (a sphere, or capsule, etc). */ - AZ::u32 m_jointIndex = ~0U; /**< The joint index to attach to, or ~0 for non-attached. */ + size_t m_jointIndex = InvalidIndex; /**< The joint index to attach to, or ~0 for non-attached. */ AZ::Vector3 m_globalStart = AZ::Vector3::CreateZero(); /**< The world space start position, or the world space center in case of a sphere. */ AZ::Vector3 m_globalEnd = AZ::Vector3::CreateZero(); /**< The world space end position. This is ignored in case of a sphere. */ AZ::Vector3 m_start = AZ::Vector3::CreateZero(); /**< The start of the primitive. In case of a sphere the center, in case of a capsule the start of the capsule. */ @@ -108,7 +108,7 @@ namespace EMotionFX AZ_INLINE Particle& GetParticle(size_t index) { return m_particles[index]; } AZ_INLINE size_t GetNumParticles() const { return m_particles.size(); } - AZ_INLINE Spring& GetSpring(AZ::u32 index) { return m_springs[index]; } + AZ_INLINE Spring& GetSpring(size_t index) { return m_springs[index]; } AZ_INLINE size_t GetNumSprings() const { return m_springs.size(); } void SetParentParticle(size_t parentParticleIndex) { m_parentParticle = parentParticleIndex; } @@ -119,12 +119,12 @@ namespace EMotionFX size_t GetNumIterations() const; Particle* AddJoint(const SimulatedJoint* joint); - bool AddSupportSpring(AZ::u32 nodeA, AZ::u32 nodeB, float restLength = -1.0f); + bool AddSupportSpring(size_t nodeA, size_t nodeB, float restLength = -1.0f); bool AddSupportSpring(AZStd::string_view nodeNameA, AZStd::string_view nodeNameB, float restLength = -1.0f); - bool RemoveJoint(AZ::u32 jointIndex); + bool RemoveJoint(size_t jointIndex); bool RemoveJoint(AZStd::string_view nodeName); - bool RemoveSupportSpring(AZ::u32 jointIndexA, AZ::u32 jointIndexB); + bool RemoveSupportSpring(size_t jointIndexA, size_t jointIndexB); bool RemoveSupportSpring(AZStd::string_view nodeNameA, AZStd::string_view nodeNameB); void SetStiffnessFactor(float factor) { m_stiffnessFactor = factor; } @@ -135,19 +135,19 @@ namespace EMotionFX float GetGravityFactor() const { return m_gravityFactor; } float GetDampingFactor() const { return m_dampingFactor; } - size_t FindParticle(AZ::u32 jointIndex) const; + size_t FindParticle(size_t jointIndex) const; Particle* FindParticle(AZStd::string_view nodeName); AZ_INLINE void RemoveCollisionObject(size_t index) { m_collisionObjects.erase(m_collisionObjects.begin() + index); } AZ_INLINE void RemoveAllCollisionObjects() { m_collisionObjects.clear(); } - AZ_INLINE CollisionObject& GetCollisionObject(AZ::u32 index) { return m_collisionObjects[index]; } + AZ_INLINE CollisionObject& GetCollisionObject(size_t index) { return m_collisionObjects[index]; } AZ_INLINE size_t GetNumCollisionObjects() const { return m_collisionObjects.size(); } AZ_INLINE bool GetCollisionEnabled() const { return m_collisionDetection; } AZ_INLINE void SetCollisionEnabled(bool enabled) { m_collisionDetection = enabled; } private: void InitColliders(const InitSettings& initSettings); - void CreateCollider(AZ::u32 skeletonJointIndex, const AzPhysics::ShapeColliderPair& shapePair); + void CreateCollider(size_t skeletonJointIndex, const AzPhysics::ShapeColliderPair& shapePair); void InitColliderFromColliderSetupShape(CollisionObject& collider); void InitCollidersFromColliderSetupShapes(); bool RecursiveAddJoint(const SimulatedJoint* joint, size_t parentParticleIndex); @@ -166,7 +166,7 @@ namespace EMotionFX bool PerformCollision(AZ::Vector3& inOutPos, float jointRadius, const Particle& particle); void PerformConeLimit(Particle& particleA, Particle& particleB, const AZ::Vector3& inputDir); bool CheckIsJointInsideCollider(const CollisionObject& colObject, const Particle& particle) const; - void CheckAndExcludeCollider(AZ::u32 colliderIndex, const SimulatedJoint* joint); + void CheckAndExcludeCollider(size_t colliderIndex, const SimulatedJoint* joint); void UpdateFixedParticles(const Pose& pose); void Stabilize(const Pose& inputPose, Pose& pose, size_t numFrames=5); void InitAutoColliderExclusion(); diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/SubMesh.h b/Gems/EMotionFX/Code/EMotionFX/Source/SubMesh.h index 1cec56efc6..9455b6b7df 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/SubMesh.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/SubMesh.h @@ -198,28 +198,28 @@ namespace EMotionFX * @param index The bone number, which must be in range of [0..GetNumBones()-1]. * @result The node index value for the given bone. */ - MCORE_INLINE uint32 GetBone(uint32 index) const { return mBones[index]; } + MCORE_INLINE size_t GetBone(size_t index) const { return mBones[index]; } /** * Get direct access to the bone values, by getting a pointer to the first bone index. * Each integer in the array represents the node number that acts as bone on this submesh. * @result A pointer to the array of bones used by this submesh. */ - MCORE_INLINE uint32* GetBones() { return mBones.data(); } + MCORE_INLINE size_t* GetBones() { return mBones.data(); } /** * Get direct access to the bones array. * Each integer in the array represents the node number that acts as bone on this submesh. * @result A read only reference to the array of bones used by this submesh. */ - MCORE_INLINE const AZStd::vector& GetBonesArray() const { return mBones; } + MCORE_INLINE const AZStd::vector& GetBonesArray() const { return mBones; } /** * Get direct access to the bones array. * Each integer in the array represents the node number that acts as bone on this submesh. * @result A reference to the array of bones used by this submesh. */ - MCORE_INLINE AZStd::vector& GetBonesArray() { return mBones; } + MCORE_INLINE AZStd::vector& GetBonesArray() { return mBones; } /** * Reinitialize the bones. @@ -268,7 +268,7 @@ namespace EMotionFX protected: - AZStd::vector mBones; /**< The collection of bones. These are stored as node numbers that point into the actor. */ + AZStd::vector mBones; /**< The collection of bones. These are stored as node numbers that point into the actor. */ uint32 mStartVertex; /**< The start vertex number in the vertex data arrays of the parent mesh. */ uint32 mStartIndex; /**< The start index number in the index array of the parent mesh. */ uint32 mStartPolygon; /**< The start polygon number in the polygon vertex count array of the parent mesh. */ diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentNodesWindow.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentNodesWindow.cpp index 3b24552035..d84b22f5d5 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentNodesWindow.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentNodesWindow.cpp @@ -144,11 +144,11 @@ namespace EMStudio mRemoveNodesButton->setEnabled((mNodeTable->rowCount() != 0) && (mNodeTable->selectedItems().size() != 0)); // counter for attachment nodes - uint16 numAttachmentNodes = 0; + size_t numAttachmentNodes = 0; // set the row count - const uint16 numNodes = mActor->GetNumNodes(); - for (uint16 i = 0; i < numNodes; ++i) + const size_t numNodes = mActor->GetNumNodes(); + for (size_t i = 0; i < numNodes; ++i) { // get the nodegroup EMotionFX::Node* node = mActor->GetSkeleton()->GetNode(i); @@ -162,7 +162,7 @@ namespace EMStudio mNodeTable->setRowCount(numAttachmentNodes); // set header items for the table - QTableWidgetItem* nameHeaderItem = new QTableWidgetItem(AZStd::string::format("Attachment Nodes (%i / %i)", numAttachmentNodes, mActor->GetNumNodes()).c_str()); + QTableWidgetItem* nameHeaderItem = new QTableWidgetItem(AZStd::string::format("Attachment Nodes (%zu / %zu)", numAttachmentNodes, mActor->GetNumNodes()).c_str()); nameHeaderItem->setTextAlignment(Qt::AlignVCenter | Qt::AlignCenter); mNodeTable->setHorizontalHeaderItem(0, nameHeaderItem); diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeGroups/NodeGroupWidget.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeGroups/NodeGroupWidget.cpp index 481718ab66..552a6d45e7 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeGroups/NodeGroupWidget.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeGroups/NodeGroupWidget.cpp @@ -168,7 +168,7 @@ namespace EMStudio mNodeTable->setRowCount(mNodeGroup->GetNumNodes()); // set header items for the table - AZStd::string headerText = AZStd::string::format("%s Nodes (%i / %i)", ((mNodeGroup->GetIsEnabledOnDefault()) ? "Enabled" : "Disabled"), mNodeGroup->GetNumNodes(), mActor->GetNumNodes()); + AZStd::string headerText = AZStd::string::format("%s Nodes (%i / %zu)", ((mNodeGroup->GetIsEnabledOnDefault()) ? "Enabled" : "Disabled"), mNodeGroup->GetNumNodes(), mActor->GetNumNodes()); QTableWidgetItem* nameHeaderItem = new QTableWidgetItem(headerText.c_str()); nameHeaderItem->setTextAlignment(Qt::AlignVCenter | Qt::AlignCenter); mNodeTable->setHorizontalHeaderItem(0, nameHeaderItem); diff --git a/Gems/EMotionFX/Code/MCore/Source/Endian.h b/Gems/EMotionFX/Code/MCore/Source/Endian.h index 296f53a208..ba93fbed97 100644 --- a/Gems/EMotionFX/Code/MCore/Source/Endian.h +++ b/Gems/EMotionFX/Code/MCore/Source/Endian.h @@ -53,6 +53,8 @@ namespace MCore */ static MCORE_INLINE void ConvertUnsignedInt32(uint32* value, uint32 count = 1); + static MCORE_INLINE void ConvertUnsignedInt64(uint64* value, uint32 count = 1); + /** * Swap the endian of one or more shorts. * @param value The value to convert the endian for. @@ -178,6 +180,8 @@ namespace MCore */ static MCORE_INLINE void ConvertUnsignedInt32(uint32* value, EEndianType sourceEndianType, uint32 count = 1); + static MCORE_INLINE void ConvertUnsignedInt64(uint64* value, EEndianType sourceEndianType, uint32 count = 1); + /** * Convert one or more 16 bit short values into the endian used by our current platform. * @param value The value(s) to convert. The number of values to follow at the specified address must be at least the number @@ -273,6 +277,8 @@ namespace MCore */ static MCORE_INLINE void ConvertUnsignedInt32(uint32* value, EEndianType sourceEndianType, EEndianType targetEndianType, uint32 count = 1); + static MCORE_INLINE void ConvertUnsignedInt64(uint64* value, EEndianType sourceEndianType, EEndianType targetEndianType, uint32 count = 1); + /** * Convert an 16 bit short into another endian type. * @param value A pointer to the object to convert/modify. diff --git a/Gems/EMotionFX/Code/MCore/Source/Endian.inl b/Gems/EMotionFX/Code/MCore/Source/Endian.inl index bafd816398..e0dd5acb0a 100644 --- a/Gems/EMotionFX/Code/MCore/Source/Endian.inl +++ b/Gems/EMotionFX/Code/MCore/Source/Endian.inl @@ -28,6 +28,17 @@ MCORE_INLINE void Endian::ConvertUnsignedInt32(uint32* value, uint32 count) } } +MCORE_INLINE void Endian::ConvertUnsignedInt64(uint64* value, uint32 count) +{ + for (uint32 i = 0; i < count; ++i) + { + uint64 arg = *value; + *value = (arg >> 56) + ((arg >> 40) & 0xFF00) + ((arg >> 24) & 0xFF0000) + ((arg >> 8) & 0xFF000000) + + ((arg & 0xFF000000) << 8) + ((arg & 0xFF0000) << 24) + ((arg & 0xFF00) << 40) + (arg << 56); + value++; + } +} + // swap bytes for a short MCORE_INLINE void Endian::ConvertSignedInt16(int16* value, uint32 count) @@ -168,6 +179,20 @@ MCORE_INLINE void Endian::ConvertUnsignedInt32(uint32* value, Endian::EEndianTyp ; } +MCORE_INLINE void Endian::ConvertUnsignedInt64(uint64* value, Endian::EEndianType sourceEndianType, uint32 count) +{ + // convert into the new endian, depending on the platform we are running on + switch (sourceEndianType) + { + case ENDIAN_LITTLE: + MCORE_FROM_LITTLE_ENDIAN64((uint8*)value, count); + break; + case ENDIAN_BIG: + MCORE_FROM_BIG_ENDIAN64 ((uint8*)value, count); + break; + } +} + // convert a short MCORE_INLINE void Endian::ConvertSignedInt16(int16* value, EEndianType sourceEndianType, uint32 count) @@ -364,6 +389,19 @@ MCORE_INLINE void Endian::ConvertUnsignedInt32(uint32* value, EEndianType source ConvertUnsignedInt32(value, count); } +// convert an uint64 into another endian type +MCORE_INLINE void Endian::ConvertUnsignedInt64(uint64* value, EEndianType sourceEndianType, EEndianType targetEndianType, uint32 count) +{ + // if we don't need to convert anything + if (sourceEndianType == targetEndianType) + { + return; + } + + // perform conversion + ConvertUnsignedInt64(value, count); +} + // convert a short into another endian type MCORE_INLINE void Endian::ConvertSignedInt16(int16* value, EEndianType sourceEndianType, EEndianType targetEndianType, uint32 count) diff --git a/Gems/EMotionFX/Code/Platform/Windows/platform_windows.cmake b/Gems/EMotionFX/Code/Platform/Windows/platform_windows.cmake index 98a5170e23..7a325ca97e 100644 --- a/Gems/EMotionFX/Code/Platform/Windows/platform_windows.cmake +++ b/Gems/EMotionFX/Code/Platform/Windows/platform_windows.cmake @@ -5,7 +5,3 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # # - -if (PAL_TRAIT_COMPILER_ID STREQUAL "MSVC") - set(LY_COMPILE_OPTIONS PUBLIC /wd4267) -endif() diff --git a/Gems/EMotionFX/Code/Source/Editor/SkeletonModel.cpp b/Gems/EMotionFX/Code/Source/Editor/SkeletonModel.cpp index 5a4f14921d..8530521458 100644 --- a/Gems/EMotionFX/Code/Source/Editor/SkeletonModel.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/SkeletonModel.cpp @@ -632,15 +632,10 @@ namespace EMotionFX NodeInfo& nodeInfo = m_nodeInfos[nodeIndex]; // Is bone? - nodeInfo.m_isBone = false; - for (AZ::u32 lodLevel = 0; lodLevel < numLodLevels; ++lodLevel) + nodeInfo.m_isBone = AZStd::any_of(begin(boneListPerLodLevel), end(boneListPerLodLevel), [nodeIndex](const AZStd::vector& lodLevel) { - if (AZStd::find(begin(boneListPerLodLevel[lodLevel]), end(boneListPerLodLevel[lodLevel]), nodeIndex) != end(boneListPerLodLevel[lodLevel])) - { - nodeInfo.m_isBone = true; - break; - } - } + return AZStd::find(begin(lodLevel), end(lodLevel), nodeIndex) != end(lodLevel); + }); // Has mesh? nodeInfo.m_hasMesh = false; diff --git a/Gems/EMotionFX/Code/Tests/AdditiveMotionSamplingTests.cpp b/Gems/EMotionFX/Code/Tests/AdditiveMotionSamplingTests.cpp index ae8b42441a..4171598801 100644 --- a/Gems/EMotionFX/Code/Tests/AdditiveMotionSamplingTests.cpp +++ b/Gems/EMotionFX/Code/Tests/AdditiveMotionSamplingTests.cpp @@ -27,10 +27,10 @@ namespace EMotionFX void CreateSubMotionLikeBindPose(const std::string& name) { const Skeleton* skeleton = m_actor->GetSkeleton(); - AZ::u32 jointIndex = InvalidIndex32; + size_t jointIndex = InvalidIndex; const Node* node = skeleton->FindNodeAndIndexByName(name.c_str(), jointIndex); ASSERT_NE(node, nullptr); - ASSERT_NE(jointIndex, InvalidIndex32); + ASSERT_NE(jointIndex, InvalidIndex); const Pose* bindPose = m_actorInstance->GetTransformData()->GetBindPose(); const Transform& transform = bindPose->GetLocalSpaceTransform(jointIndex); @@ -41,7 +41,7 @@ namespace EMotionFX { // Find and store the joint index. const Skeleton* skeleton = m_actor->GetSkeleton(); - AZ::u32 jointIndex = InvalidIndex32; + size_t jointIndex = InvalidIndex; const Node* node = skeleton->FindNodeAndIndexByName(name.c_str(), jointIndex); ASSERT_NE(node, nullptr); ASSERT_NE(jointIndex, InvalidIndex32); @@ -91,9 +91,9 @@ namespace EMotionFX protected: Motion* m_motion = nullptr; MotionInstance* m_motionInstance = nullptr; // Automatically deleted internally when deleting the actor instance. - std::vector m_jointIndices; + std::vector m_jointIndices; std::vector m_jointNames { "l_upLeg", "l_loLeg", "l_ankle" }; - AZ::u32 m_footIndex = InvalidIndex32; + size_t m_footIndex = InvalidIndex; }; TEST_F(MotionSamplingFixture, SampleAdditiveJoint) @@ -102,7 +102,7 @@ namespace EMotionFX // Sample the joints that exist in our actor skeleton as well as inside the motion data. const Pose* bindPose = m_actorInstance->GetTransformData()->GetBindPose(); - for (AZ::u32 jointIndex : m_jointIndices) + for (size_t jointIndex : m_jointIndices) { // Sample the motion. Transform transform = Transform::CreateZero(); // Set all to Zero, not identity as this methods might return identity and we want to verify that. @@ -140,7 +140,7 @@ namespace EMotionFX // Test if the joints that exist in both motion and actor have the expected transforms. const Pose* bindPose = m_actorInstance->GetTransformData()->GetBindPose(); - for (AZ::u32 jointIndex : m_jointIndices) + for (size_t jointIndex : m_jointIndices) { const Transform& transform = pose.GetLocalSpaceTransform(jointIndex); const Transform& bindTransform = bindPose->GetLocalSpaceTransform(jointIndex); diff --git a/Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp b/Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp index 6fa1d962ab..2a199f5e8b 100644 --- a/Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/AnimGraphMotionNodeTests.cpp @@ -118,16 +118,16 @@ namespace EMotionFX } protected: - AZ::u32 m_l_handIndex = InvalidIndex32; - AZ::u32 m_l_loArmIndex = InvalidIndex32; - AZ::u32 m_l_loLegIndex = InvalidIndex32; - AZ::u32 m_l_ankleIndex = InvalidIndex32; - AZ::u32 m_r_handIndex = InvalidIndex32; - AZ::u32 m_r_loArmIndex = InvalidIndex32; - AZ::u32 m_r_loLegIndex = InvalidIndex32; - AZ::u32 m_r_ankleIndex = InvalidIndex32; - AZ::u32 m_jack_rootIndex = InvalidIndex32; - AZ::u32 m_bip01__pelvisIndex = InvalidIndex32; + size_t m_l_handIndex = InvalidIndex; + size_t m_l_loArmIndex = InvalidIndex; + size_t m_l_loLegIndex = InvalidIndex; + size_t m_l_ankleIndex = InvalidIndex; + size_t m_r_handIndex = InvalidIndex; + size_t m_r_loArmIndex = InvalidIndex; + size_t m_r_loLegIndex = InvalidIndex; + size_t m_r_ankleIndex = InvalidIndex; + size_t m_jack_rootIndex = InvalidIndex; + size_t m_bip01__pelvisIndex = InvalidIndex; AnimGraphMotionNode* m_motionNode = nullptr; BlendTree* m_blendTree = nullptr; BlendTreeFloatConstantNode* m_fltConstNode = nullptr; @@ -351,7 +351,7 @@ namespace EMotionFX AZ::Vector3 rootFinalPosUnderSpeed1 = m_jackPose->GetModelSpaceTransform(m_jack_rootIndex).mPosition; std::vector speedFactors = { 2.0f, 3.0f, 10.0f, 100.0f }; std::vector playTimes = { 0.6f, 0.4f, 0.11f, 0.011f }; - for (AZ::u32 i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { m_motionNode->Rewind(m_animGraphInstance); m_fltConstNode->SetValue(speedFactors[i]); @@ -385,7 +385,7 @@ namespace EMotionFX rootFinalPosUnderSpeed1 = m_jackPose->GetModelSpaceTransform(m_jack_rootIndex).mPosition; // Similar test to using the InPlace input port. - for (AZ::u32 i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { m_motionNode->Rewind(m_animGraphInstance); m_motionNode->SetMotionPlaySpeed(speedFactors[i]); @@ -426,7 +426,7 @@ namespace EMotionFX // In randomized index mode, all motions should at least appear once over 10 loops. bool motion1Displayed = false; bool motion2Displayed = false; - for (AZ::u32 i = 0; i < 20; i++) + for (size_t i = 0; i < 20; i++) { // Run the test loop multiple times to make sure all the motion index is picked. uniqueData->mReload = true; @@ -460,7 +460,7 @@ namespace EMotionFX uint32 currentMotionIndex = uniqueData->mActiveMotionIndex; // In randomized no repeat index mode, motions should change in each loop. - for (AZ::u32 i = 0; i < 10; i++) + for (size_t i = 0; i < 10; i++) { uniqueData->mReload = true; m_motionNode->Reinit(); @@ -476,7 +476,7 @@ namespace EMotionFX m_motionNode->SetIndexMode(AnimGraphMotionNode::INDEXMODE_SEQUENTIAL); // In sequential index mode, motions should increase its index each time and wrap around. Basically iterating over the list of motions. - for (AZ::u32 i = 0; i < 10; i++) + for (size_t i = 0; i < 10; i++) { uniqueData->mReload = true; m_motionNode->Reinit(); diff --git a/Gems/EMotionFX/Code/Tests/BlendTreeFootIKNodeTests.cpp b/Gems/EMotionFX/Code/Tests/BlendTreeFootIKNodeTests.cpp index 5fddb5a94b..48350ce071 100644 --- a/Gems/EMotionFX/Code/Tests/BlendTreeFootIKNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/BlendTreeFootIKNodeTests.cpp @@ -136,10 +136,10 @@ namespace EMotionFX void ValidateFootHeight(BlendTreeFootIKNode::LegId legId, const char* jointName, float height, float tolerance) { // Check the left foot height. - AZ::u32 footIndex; + size_t footIndex = InvalidIndex; Skeleton* skeleton = m_actor->GetSkeleton(); skeleton->FindNodeAndIndexByName(jointName, footIndex); - ASSERT_NE(footIndex, MCORE_INVALIDINDEX32); + ASSERT_NE(footIndex, InvalidIndex); EMotionFX::Transform transform = m_actorInstance->GetTransformData()->GetCurrentPose()->GetWorldSpaceTransform(footIndex); const BlendTreeFootIKNode::UniqueData* uniqueData = static_cast(m_animGraphInstance->FindOrCreateUniqueNodeData(m_ikNode)); const float correction = (m_actorInstance->GetWorldSpaceTransform().mRotation.TransformVector(AZ::Vector3(0.0f, 0.0f, uniqueData->m_legs[legId].m_footHeight))).GetZ(); diff --git a/Gems/EMotionFX/Code/Tests/BlendTreeMirrorPoseNodeTests.cpp b/Gems/EMotionFX/Code/Tests/BlendTreeMirrorPoseNodeTests.cpp index 53e0e7de77..9851409a94 100644 --- a/Gems/EMotionFX/Code/Tests/BlendTreeMirrorPoseNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/BlendTreeMirrorPoseNodeTests.cpp @@ -111,12 +111,12 @@ namespace EMotionFX TEST_F(BlendTreeMirrorPoseNodeFixture, OutputsCorrectPose) { GetEMotionFX().Update(1.0f / 60.0f); - AZ::u32 l_upArmIndex; - AZ::u32 r_upArmIndex; - AZ::u32 l_loArmIndex; - AZ::u32 r_loArmIndex; - AZ::u32 l_handIndex; - AZ::u32 r_handIndex; + size_t l_upArmIndex; + size_t r_upArmIndex; + size_t l_loArmIndex; + size_t r_loArmIndex; + size_t l_handIndex; + size_t r_handIndex; m_jackSkeleton->FindNodeAndIndexByName("l_upArm", l_upArmIndex); m_jackSkeleton->FindNodeAndIndexByName("r_upArm", r_upArmIndex); m_jackSkeleton->FindNodeAndIndexByName("l_loArm", l_loArmIndex); diff --git a/Gems/EMotionFX/Code/Tests/BlendTreeSimulatedObjectNodeTests.cpp b/Gems/EMotionFX/Code/Tests/BlendTreeSimulatedObjectNodeTests.cpp index a53a3d7e0b..df2f644eb4 100644 --- a/Gems/EMotionFX/Code/Tests/BlendTreeSimulatedObjectNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/BlendTreeSimulatedObjectNodeTests.cpp @@ -47,7 +47,7 @@ namespace EMotionFX ASSERT_EQ(jointNames.size(), 3); for (size_t i= 0; i < 3; ++i) { - AZ::u32 jointIndex = InvalidIndex32; + size_t jointIndex = InvalidIndex; const Node* node = skeleton->FindNodeAndIndexByName(jointNames[i].c_str(), jointIndex); ASSERT_NE(node, nullptr); m_jointIndices[i] = jointIndex; @@ -116,7 +116,7 @@ namespace EMotionFX FloatSliderParameter* m_weightParameter = nullptr; BlendTreeSimulatedObjectNode* m_simNode = nullptr; BlendTreeParameterNode* m_parameterNode = nullptr; - AZ::u32 m_jointIndices[3] { InvalidIndex32, InvalidIndex32, InvalidIndex32 }; + size_t m_jointIndices[3] { InvalidIndex, InvalidIndex, InvalidIndex }; }; TEST_F(BlendTreeSimulatedObjectNodeFixture, TransformsCheck) diff --git a/Gems/EMotionFX/Code/Tests/BlendTreeTwoLinkIKNodeTests.cpp b/Gems/EMotionFX/Code/Tests/BlendTreeTwoLinkIKNodeTests.cpp index 91b7687a02..820e6d9fa4 100644 --- a/Gems/EMotionFX/Code/Tests/BlendTreeTwoLinkIKNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/BlendTreeTwoLinkIKNodeTests.cpp @@ -147,7 +147,7 @@ namespace EMotionFX // Remeber specific joint's original position to compare with its new position later const Pose* jackPose = m_actorInstance->GetTransformData()->GetCurrentPose(); - AZ::u32 testJointIndex; + size_t testJointIndex; m_jackSkeleton->FindNodeAndIndexByName(m_param.testJointName, testJointIndex); const AZ::Vector3& testJointPos = jackPose->GetModelSpaceTransform(testJointIndex).mPosition; @@ -187,7 +187,7 @@ namespace EMotionFX ParamSetValue("WeightParam", weight); const Pose* jackPose = m_actorInstance->GetTransformData()->GetCurrentPose(); - AZ::u32 testJointIndex; + size_t testJointIndex; m_jackSkeleton->FindNodeAndIndexByName(m_param.testJointName, testJointIndex); const AZ::Vector3& testJointPos = jackPose->GetModelSpaceTransform(testJointIndex).mPosition; @@ -202,7 +202,7 @@ namespace EMotionFX // Unique data only updates once unless reset mMustUpdate to true again BlendTreeTwoLinkIKNode::UniqueData* uniqueData = static_cast(m_animGraphInstance->FindOrCreateUniqueNodeData(m_twoLinkIKNode)); uniqueData->Invalidate(); - AZ::u32 alignToNodeIndex; + size_t alignToNodeIndex; m_jackSkeleton->FindNodeAndIndexByName(nodeName, alignToNodeIndex); GetEMotionFX().Update(1.0f / 60.0f); @@ -234,9 +234,9 @@ namespace EMotionFX ParamSetValue("WeightParam", weight); const Pose* jackPose = m_actorInstance->GetTransformData()->GetCurrentPose(); - AZ::u32 testJointIndex; - AZ::u32 linkedJoint0Index; - AZ::u32 linkedJoint1Index; + size_t testJointIndex; + size_t linkedJoint0Index; + size_t linkedJoint1Index; m_jackSkeleton->FindNodeAndIndexByName(m_param.testJointName, testJointIndex); m_jackSkeleton->FindNodeAndIndexByName(m_param.linkedJointNames[0], linkedJoint0Index); m_jackSkeleton->FindNodeAndIndexByName(m_param.linkedJointNames[1], linkedJoint1Index); @@ -287,7 +287,7 @@ namespace EMotionFX ParamSetValue("GoalPosParam", AZ::Vector3(0.0f, 1.0f, 1.0f)); const Pose* jackPose = m_actorInstance->GetTransformData()->GetCurrentPose(); - AZ::u32 testJointIndex; + size_t testJointIndex; m_jackSkeleton->FindNodeAndIndexByName(m_param.testJointName, testJointIndex); const AZ::Quaternion testJointRotation = jackPose->GetModelSpaceTransform(testJointIndex).mRotation; @@ -334,8 +334,8 @@ namespace EMotionFX GetEMotionFX().Update(1.0f / 60.0f); Pose* jackPose = m_actorInstance->GetTransformData()->GetCurrentPose(); - AZ::u32 testBendJointIndex; - AZ::u32 testJointIndex; + size_t testBendJointIndex; + size_t testJointIndex; AZStd::string& bendLoArm = m_param.linkedJointNames[0]; m_jackSkeleton->FindNodeAndIndexByName(bendLoArm, testBendJointIndex); m_jackSkeleton->FindNodeAndIndexByName(m_param.testJointName, testJointIndex); @@ -395,8 +395,8 @@ namespace EMotionFX GetEMotionFX().Update(1.0f / 60.0f); const Pose* jackPose = m_actorInstance->GetTransformData()->GetCurrentPose(); - AZ::u32 testJointIndex; - AZ::u32 testBendJointIndex; + size_t testJointIndex; + size_t testBendJointIndex; AZStd::string& bendLoArm = m_param.linkedJointNames[0]; m_jackSkeleton->FindNodeAndIndexByName(m_param.testJointName, testJointIndex); m_jackSkeleton->FindNodeAndIndexByName(bendLoArm, testBendJointIndex); diff --git a/Gems/EMotionFX/Code/Tests/Mocks/CommandManagerCallback.h b/Gems/EMotionFX/Code/Tests/Mocks/CommandManagerCallback.h index 7f9a8d6530..0e805b72e1 100644 --- a/Gems/EMotionFX/Code/Tests/Mocks/CommandManagerCallback.h +++ b/Gems/EMotionFX/Code/Tests/Mocks/CommandManagerCallback.h @@ -21,8 +21,8 @@ namespace MCore MOCK_METHOD2(OnPreExecuteCommandGroup, void(MCore::CommandGroup*, bool)); MOCK_METHOD2(OnPostExecuteCommandGroup, void(MCore::CommandGroup*, bool)); - MOCK_METHOD4(OnAddCommandToHistory, void(uint32, MCore::CommandGroup*, MCore::Command*, const MCore::CommandLine&)); - MOCK_METHOD1(OnRemoveCommand, void(uint32)); - MOCK_METHOD1(OnSetCurrentCommand, void(uint32)); + MOCK_METHOD4(OnAddCommandToHistory, void(size_t, MCore::CommandGroup*, MCore::Command*, const MCore::CommandLine&)); + MOCK_METHOD1(OnRemoveCommand, void(size_t)); + MOCK_METHOD1(OnSetCurrentCommand, void(size_t)); }; } // namespace MCore diff --git a/Gems/EMotionFX/Code/Tests/MotionExtractionTests.cpp b/Gems/EMotionFX/Code/Tests/MotionExtractionTests.cpp index e1839d8d9f..85c0e4201f 100644 --- a/Gems/EMotionFX/Code/Tests/MotionExtractionTests.cpp +++ b/Gems/EMotionFX/Code/Tests/MotionExtractionTests.cpp @@ -119,8 +119,8 @@ namespace EMotionFX } protected: - AZ::u32 m_jack_rootIndex = MCORE_INVALIDINDEX32; - AZ::u32 m_jack_hipIndex = MCORE_INVALIDINDEX32; + size_t m_jack_rootIndex = InvalidIndex; + size_t m_jack_hipIndex = InvalidIndex; AnimGraphMotionNode* m_motionNode = nullptr; BlendTree* m_blendTree = nullptr; Motion* m_motion = nullptr; @@ -243,7 +243,7 @@ namespace EMotionFX // The expected delta used is the distance of the jack walk forward motion will move in 1 complete duration const float expectedDelta = ExtractLastFramePos().GetY(); - for (AZ::u32 paramIndex = 0; paramIndex < m_param.durationMultipliers.size(); paramIndex++) + for (size_t paramIndex = 0; paramIndex < m_param.durationMultipliers.size(); paramIndex++) { // Test motion extraction under different durations/time deltas const float motionDuration = 1.066f * m_param.durationMultipliers[paramIndex]; @@ -262,7 +262,7 @@ namespace EMotionFX const AZ::Quaternion actorRotation(0.0f, 0.0f, -1.0f, 1.0f); m_actorInstance->SetLocalSpaceRotation(actorRotation.GetNormalized()); GetEMotionFX().Update(0.0f); - for (AZ::u32 paramIndex = 0; paramIndex < m_param.durationMultipliers.size(); paramIndex++) + for (size_t paramIndex = 0; paramIndex < m_param.durationMultipliers.size(); paramIndex++) { const float motionDuration = 1.066f * m_param.durationMultipliers[paramIndex]; const float originalPositionX = m_actorInstance->GetWorldSpaceTransform().mPosition.GetX(); @@ -290,7 +290,7 @@ namespace EMotionFX const AZ::Quaternion diagonalRotation = m_reverse ? AZ::Quaternion(0.0f, 0.0f, 0.5f, 1.0f) : AZ::Quaternion(0.0f, 0.0f, -0.5f, 1.0f); m_actorInstance->SetLocalSpaceRotation(diagonalRotation.GetNormalized()); GetEMotionFX().Update(0.0f); - for (AZ::u32 paramIndex = 0; paramIndex < m_param.durationMultipliers.size(); paramIndex++) + for (size_t paramIndex = 0; paramIndex < m_param.durationMultipliers.size(); paramIndex++) { const float originalPositionX = m_actorInstance->GetWorldSpaceTransform().mPosition.GetX(); const float originalPositionY = m_actorInstance->GetWorldSpaceTransform().mPosition.GetY(); diff --git a/Gems/EMotionFX/Code/Tests/PoseTests.cpp b/Gems/EMotionFX/Code/Tests/PoseTests.cpp index 0957176813..1785a4d512 100644 --- a/Gems/EMotionFX/Code/Tests/PoseTests.cpp +++ b/Gems/EMotionFX/Code/Tests/PoseTests.cpp @@ -742,7 +742,7 @@ namespace EMotionFX pose.LinkToActorInstance(m_actorInstance); pose.InitFromBindPose(m_actor.get()); - AZ::u32 jointIndex = InvalidIndex32; + size_t jointIndex = InvalidIndex; Node* joint = m_actor->GetSkeleton()->FindNodeAndIndexByName("joint4", jointIndex); ASSERT_NE(joint, nullptr) << "Can't find the joint named 'joint4'."; @@ -779,7 +779,7 @@ namespace EMotionFX Pose destPose; destPose.LinkToActorInstance(m_actorInstance); destPose.InitFromBindPose(m_actor.get()); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const float floatI = static_cast(i); Transform transform(AZ::Vector3(0.0f, 0.0f, -floatI), @@ -798,7 +798,7 @@ namespace EMotionFX blendedPose.Blend(&destPose, blendWeight); // Check the blended result. - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const Transform& sourceTransform = sourcePose->GetLocalSpaceTransform(i); const Transform& destTransform = destPose.GetLocalSpaceTransform(i); @@ -820,7 +820,7 @@ namespace EMotionFX Pose sourcePose; sourcePose.LinkToActorInstance(m_actorInstance); sourcePose.InitFromBindPose(m_actor.get()); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const float floatI = static_cast(i); Transform transform(AZ::Vector3(floatI, 0.0f, 0.0f), @@ -837,7 +837,7 @@ namespace EMotionFX Pose destPose; destPose.LinkToActorInstance(m_actorInstance); destPose.InitFromBindPose(m_actor.get()); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const float floatI = static_cast(i); Transform transform(AZ::Vector3(0.0f, 0.0f, -floatI), @@ -856,7 +856,7 @@ namespace EMotionFX blendedPose.InitFromPose(&sourcePose); blendedPose.BlendAdditiveUsingBindPose(&destPose, blendWeight); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const Transform& bindPoseTransform = bindPose->GetLocalSpaceTransform(i); const Transform& sourceTransform = sourcePose.GetLocalSpaceTransform(i); @@ -897,7 +897,7 @@ namespace EMotionFX poseB.LinkToActorInstance(m_actorInstance); poseB.InitFromBindPose(m_actor.get()); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const float floatI = static_cast(i); const Transform transformA(AZ::Vector3(floatI, 0.0f, 0.0f), @@ -920,7 +920,7 @@ namespace EMotionFX default: { ASSERT_TRUE(false) << "Case not handled."; } } - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const Transform& transformA = poseA.GetLocalSpaceTransform(i); const Transform& transformB = poseB.GetLocalSpaceTransform(i); @@ -960,7 +960,7 @@ namespace EMotionFX poseB.LinkToActorInstance(m_actorInstance); poseB.InitFromBindPose(m_actor.get()); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const float floatI = static_cast(i); const Transform transformA(AZ::Vector3(floatI, 0.0f, 0.0f), AZ::Quaternion::CreateIdentity()); @@ -982,7 +982,7 @@ namespace EMotionFX poseSum.InitFromPose(&poseA); poseSum.Sum(&poseB, weight); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const Transform& transformA = poseA.GetLocalSpaceTransform(i); const Transform& transformB = poseB.GetLocalSpaceTransform(i); @@ -1012,7 +1012,7 @@ namespace EMotionFX poseB.LinkToActorInstance(m_actorInstance); poseB.InitFromBindPose(m_actor.get()); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const float floatI = static_cast(i); const Transform transformA(AZ::Vector3(floatI, floatI, floatI), AZ::Quaternion::CreateIdentity()); @@ -1026,7 +1026,7 @@ namespace EMotionFX poseRel.InitFromPose(&poseA); poseRel.MakeRelativeTo(poseB); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const Transform& transformRel = poseRel.GetLocalSpaceTransform(i); @@ -1095,7 +1095,7 @@ namespace EMotionFX } poseB.InitFromBindPose(m_actor.get()); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const float floatI = static_cast(i); const Transform transformA(AZ::Vector3(floatI, 0.0f, 0.0f), @@ -1133,7 +1133,7 @@ namespace EMotionFX default: { ASSERT_TRUE(false) << "Case not handled."; } } - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { const Transform& transformA = poseA.GetLocalSpaceTransform(i); const Transform& transformB = poseB.GetLocalSpaceTransform(i); @@ -1222,7 +1222,7 @@ namespace EMotionFX pose.Zero(); // Check if local space transforms are correctly zeroed. - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { EXPECT_EQ(pose.GetLocalSpaceTransform(i), Transform::CreateZero()); } @@ -1244,7 +1244,7 @@ namespace EMotionFX AZ::SimpleLcgRandom random; random.SetSeed(875960); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { Transform transformRandomRot(AZ::Vector3::CreateZero(), CreateRandomUnnormalizedQuaternion(random)); @@ -1255,7 +1255,7 @@ namespace EMotionFX pose.NormalizeQuaternions(); - for (AZ::u32 i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) + for (size_t i = 0; i < m_actor->GetSkeleton()->GetNumNodes(); ++i) { CheckIfRotationIsNormalized(pose.GetLocalSpaceTransform(i).mRotation); } diff --git a/Gems/EMotionFX/Code/Tests/SimulatedObjectSerializeTests.cpp b/Gems/EMotionFX/Code/Tests/SimulatedObjectSerializeTests.cpp index 5f48cc145f..9ba4e4f6cb 100644 --- a/Gems/EMotionFX/Code/Tests/SimulatedObjectSerializeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/SimulatedObjectSerializeTests.cpp @@ -32,7 +32,7 @@ namespace EMotionFX Skeleton* skeleton = m_actor->GetSkeleton(); for (const AZStd::string& name : jointNames) { - AZ::u32 skeletonJointIndex; + size_t skeletonJointIndex; const Node* skeletonJoint = skeleton->FindNodeAndIndexByName(name, skeletonJointIndex); ASSERT_NE(skeletonJoint, nullptr); ASSERT_NE(skeletonJointIndex, MCORE_INVALIDINDEX32); @@ -63,7 +63,7 @@ namespace EMotionFX ASSERT_FLOAT_EQ(loadedObject->GetStiffnessFactor(), 4.0f); for (size_t i = 0; i < jointNames.size(); ++i) { - const SimulatedJoint* loadedJoint = loadedObject->GetSimulatedJoint(static_cast(i)); + const SimulatedJoint* loadedJoint = loadedObject->GetSimulatedJoint(i); ASSERT_STREQ(skeleton->GetNode(loadedJoint->GetSkeletonJointIndex())->GetName(), jointNames[i].c_str()); ASSERT_FLOAT_EQ(loadedJoint->GetDamping(), 0.1f); ASSERT_FLOAT_EQ(loadedJoint->GetMass(), 2.0f); diff --git a/Gems/EMotionFX/Code/Tests/TestAssetCode/JackActor.cpp b/Gems/EMotionFX/Code/Tests/TestAssetCode/JackActor.cpp index 414879568e..96461826c7 100644 --- a/Gems/EMotionFX/Code/Tests/TestAssetCode/JackActor.cpp +++ b/Gems/EMotionFX/Code/Tests/TestAssetCode/JackActor.cpp @@ -14,7 +14,7 @@ namespace EMotionFX JackNoMeshesActor::JackNoMeshesActor(const char* name) : Actor(name) { - uint32 nodeId = 0; + size_t nodeId = 0; auto root = AddNode(nodeId++, "jack_root"); auto Bip01__pelvis = AddNode(nodeId++, "Bip01__pelvis", root->GetNodeIndex()); auto l_upLeg = AddNode(nodeId++, "l_upLeg", Bip01__pelvis->GetNodeIndex());