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
@@ -45,7 +45,7 @@ namespace EMotionFX
{
AZStd::unique_ptr<EMotionFX::Parameter> newParameter(EMotionFX::ParameterFactory::Create(azrtti_typeid<FloatSliderParameter>()));
newParameter->SetName("Float Slider Parameter");
CommandSystem::ConstructCreateParameterCommand(commandString, m_animGraph.get(), newParameter.get(), MCORE_INVALIDINDEX32);
CommandSystem::ConstructCreateParameterCommand(commandString, m_animGraph.get(), newParameter.get(), InvalidIndex);
EXPECT_TRUE(commandManager.ExecuteCommand(commandString, result)) << result.c_str();
}
@@ -54,7 +54,7 @@ namespace EMotionFX
{
AZStd::unique_ptr<EMotionFX::Parameter> newParameter(EMotionFX::ParameterFactory::Create(azrtti_typeid<Vector2Parameter>()));
newParameter->SetName(parameterName);
CommandSystem::ConstructCreateParameterCommand(commandString, m_animGraph.get(), newParameter.get(), MCORE_INVALIDINDEX32);
CommandSystem::ConstructCreateParameterCommand(commandString, m_animGraph.get(), newParameter.get(), InvalidIndex);
EXPECT_TRUE(commandManager.ExecuteCommand(commandString, result)) << result.c_str();
}
@@ -62,7 +62,8 @@ namespace EMotionFX
condition->Reinit();
AZ::Outcome<size_t> parameterIndex = m_animGraph->FindValueParameterIndexByName(parameterName);
EXPECT_TRUE(parameterIndex.IsSuccess() && parameterIndex.GetValue() == 1) << "The Vector2 parameter should be at the 2nd position.";
ASSERT_TRUE(parameterIndex.IsSuccess());
EXPECT_EQ(parameterIndex.GetValue(), 1) << "The Vector2 parameter should be at the 2nd position.";
// 1. Move the Vector2 parameter from the 2nd place to the 1st place.
commandString = AZStd::string::format("AnimGraphMoveParameter -animGraphID %d -name \"%s\" -index %d ",
@@ -71,19 +72,19 @@ namespace EMotionFX
0);
EXPECT_TRUE(commandManager.ExecuteCommand(commandString, result)) << result.c_str();
parameterIndex = m_animGraph->FindValueParameterIndexByName(parameterName);
EXPECT_TRUE(parameterIndex.IsSuccess() && parameterIndex.GetValue() == 0) << "The Vector2 parameter should now be at the 1st position.";
ASSERT_TRUE(parameterIndex.IsSuccess() && parameterIndex.GetValue() == 0) << "The Vector2 parameter should now be at the 1st position.";
EXPECT_EQ(parameterIndex.GetValue(), condition->GetParameterIndex().GetValue()) << "The Vector2 condition should now refer to the 1st parameter in the anim graph.";
// 2. Undo.
EXPECT_TRUE(commandManager.Undo(result)) << result.c_str();
parameterIndex = m_animGraph->FindValueParameterIndexByName(parameterName);
EXPECT_TRUE(parameterIndex.IsSuccess() && parameterIndex.GetValue() == 1) << "The Vector2 parameter should now be back at the 2nd position.";
ASSERT_TRUE(parameterIndex.IsSuccess() && parameterIndex.GetValue() == 1) << "The Vector2 parameter should now be back at the 2nd position.";
EXPECT_EQ(parameterIndex.GetValue(), condition->GetParameterIndex().GetValue()) << "The Vector2 condition should now refer to the 2nd parameter in the anim graph.";
// 3. Redo.
EXPECT_TRUE(commandManager.Redo(result)) << result.c_str();
parameterIndex = m_animGraph->FindValueParameterIndexByName(parameterName);
EXPECT_TRUE(parameterIndex.IsSuccess() && parameterIndex.GetValue() == 0) << "The Vector2 parameter should now be back at the 1st position.";
ASSERT_TRUE(parameterIndex.IsSuccess() && parameterIndex.GetValue() == 0) << "The Vector2 parameter should now be back at the 1st position.";
EXPECT_EQ(parameterIndex.GetValue(), condition->GetParameterIndex().GetValue()) << "The Vector2 condition should now refer to the 1st parameter in the anim graph.";
}
} // namespace EMotionFX