Convert EMotionFX runtime uint32 -> size_t

This allows the EMotionFX runtime to compile with `/we4267` enabled, which
emits a warning when converting from `size_t` to a smaller type. All tests
for the runtime have been updated accordingly, and they pass.

In instances where a range-for loop could be used, or a std algorithm, that
was used instead of using `size_t numItems = vec.size()` and a for loop.

Casts to `uint32` were removed where possible. Some places remain, like in
the file formats.

Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
Chris Burel
2021-05-24 12:04:16 -07:00
parent 8314f8caf3
commit 4034195bdc
211 changed files with 2440 additions and 3244 deletions
@@ -32,7 +32,7 @@ namespace EMotionFX
return object->GetNumSimulatedJoints();
}
size_t CountChildJoints(const Actor* actor, size_t objectIndex, AZ::u32 jointIndex)
size_t CountChildJoints(const Actor* actor, size_t objectIndex, size_t jointIndex)
{
const AZStd::shared_ptr<SimulatedObjectSetup>& simulatedObjectSetup = actor->GetSimulatedObjectSetup();
const SimulatedObject* object = simulatedObjectSetup->GetSimulatedObject(objectIndex);
@@ -55,7 +55,7 @@ namespace EMotionFX
CommandSystem::CommandManager commandManager;
MCore::CommandGroup commandGroup;
const AZ::u32 actorId = m_actor->GetID();
const uint32 actorId = m_actor->GetID();
const AZStd::vector<AZStd::string> jointNames = GetTestJointNames();
// 1. Add simulated object.
@@ -106,11 +106,11 @@ namespace EMotionFX
// --l_ankle
// --l_ball
const Skeleton* skeleton = m_actor->GetSkeleton();
const AZ::u32 l_upLegIdx = skeleton->FindNodeByName("l_upLeg")->GetNodeIndex();
const AZ::u32 l_upLegRollIdx = skeleton->FindNodeByName("l_upLegRoll")->GetNodeIndex();
const AZ::u32 l_loLegIdx = skeleton->FindNodeByName("l_loLeg")->GetNodeIndex();
const AZ::u32 l_ankleIdx = skeleton->FindNodeByName("l_ankle")->GetNodeIndex();
const AZ::u32 l_ballIdx = skeleton->FindNodeByName("l_ball")->GetNodeIndex();
const size_t l_upLegIdx = skeleton->FindNodeByName("l_upLeg")->GetNodeIndex();
const size_t l_upLegRollIdx = skeleton->FindNodeByName("l_upLegRoll")->GetNodeIndex();
const size_t l_loLegIdx = skeleton->FindNodeByName("l_loLeg")->GetNodeIndex();
const size_t l_ankleIdx = skeleton->FindNodeByName("l_ankle")->GetNodeIndex();
const size_t l_ballIdx = skeleton->FindNodeByName("l_ball")->GetNodeIndex();
CommandSimulatedObjectHelpers::AddSimulatedJoints(actorId, {l_upLegIdx, l_upLegRollIdx, l_loLegIdx, l_ankleIdx, l_ballIdx}, 0, false, &commandGroup);
EXPECT_TRUE(commandManager.ExecuteCommandGroup(commandGroup, result));
const AZStd::string serialized3_2 = SerializeSimulatedObjectSetup(m_actor.get());
@@ -172,7 +172,7 @@ namespace EMotionFX
CommandSystem::CommandManager commandManager;
MCore::CommandGroup commandGroup;
const AZ::u32 actorId = m_actor->GetID();
const uint32 actorId = m_actor->GetID();
const AZStd::vector<AZStd::string> jointNames = GetTestJointNames();
// 1. Add simulated object
@@ -183,8 +183,8 @@ namespace EMotionFX
// 2. Add r_upLeg simulated joints
const Skeleton* skeleton = m_actor->GetSkeleton();
const AZ::u32 r_upLegIdx = skeleton->FindNodeByName("r_upLeg")->GetNodeIndex();
const AZ::u32 r_loLegIdx = skeleton->FindNodeByName("r_loLeg")->GetNodeIndex();
const size_t r_upLegIdx = skeleton->FindNodeByName("r_upLeg")->GetNodeIndex();
const size_t r_loLegIdx = skeleton->FindNodeByName("r_loLeg")->GetNodeIndex();
CommandSimulatedObjectHelpers::AddSimulatedJoints(actorId, { r_upLegIdx, r_loLegIdx }, 0, false);
EXPECT_EQ(2, CountSimulatedJoints(m_actor.get(), 0));
const AZStd::string serializedUpLeg = SerializeSimulatedObjectSetup(m_actor.get());