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
@@ -43,32 +43,32 @@ namespace EMotionFX
Call(FN_OnAnimGraphInstanceDestroyed, animGraphInstance);
}
void OnAnimGraphFloatParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, AZ::u32 parameterIndex, float beforeValue, float afterValue) override
void OnAnimGraphFloatParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, size_t parameterIndex, float beforeValue, float afterValue) override
{
Call(FN_OnAnimGraphFloatParameterChanged, animGraphInstance, parameterIndex, beforeValue, afterValue);
}
void OnAnimGraphBoolParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, AZ::u32 parameterIndex, bool beforeValue, bool afterValue) override
void OnAnimGraphBoolParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, size_t parameterIndex, bool beforeValue, bool afterValue) override
{
Call(FN_OnAnimGraphBoolParameterChanged, animGraphInstance, parameterIndex, beforeValue, afterValue);
}
void OnAnimGraphStringParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, AZ::u32 parameterIndex, const char* beforeValue, const char* afterValue) override
void OnAnimGraphStringParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, size_t parameterIndex, const char* beforeValue, const char* afterValue) override
{
Call(FN_OnAnimGraphStringParameterChanged, animGraphInstance, parameterIndex, beforeValue, afterValue);
}
void OnAnimGraphVector2ParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, AZ::u32 parameterIndex, const AZ::Vector2& beforeValue, const AZ::Vector2& afterValue) override
void OnAnimGraphVector2ParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, size_t parameterIndex, const AZ::Vector2& beforeValue, const AZ::Vector2& afterValue) override
{
Call(FN_OnAnimGraphVector2ParameterChanged, animGraphInstance, parameterIndex, beforeValue, afterValue);
}
void OnAnimGraphVector3ParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, AZ::u32 parameterIndex, const AZ::Vector3& beforeValue, const AZ::Vector3& afterValue) override
void OnAnimGraphVector3ParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, size_t parameterIndex, const AZ::Vector3& beforeValue, const AZ::Vector3& afterValue) override
{
Call(FN_OnAnimGraphVector3ParameterChanged, animGraphInstance, parameterIndex, beforeValue, afterValue);
}
void OnAnimGraphRotationParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, AZ::u32 parameterIndex, const AZ::Quaternion& beforeValue, const AZ::Quaternion& afterValue) override
void OnAnimGraphRotationParameterChanged(EMotionFX::AnimGraphInstance* animGraphInstance, size_t parameterIndex, const AZ::Quaternion& beforeValue, const AZ::Quaternion& afterValue) override
{
Call(FN_OnAnimGraphVector3ParameterChanged, animGraphInstance, parameterIndex, beforeValue, afterValue);
}
@@ -138,7 +138,7 @@ namespace EMotionFX
auto* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context);
if (behaviorContext)
{
behaviorContext->Constant("InvalidParameterIndex", BehaviorConstant(static_cast<AZ::u32>(MCORE_INVALIDINDEX32)));
behaviorContext->Constant("InvalidParameterIndex", BehaviorConstant(InvalidIndex));
behaviorContext->EBus<AnimGraphComponentRequestBus>("AnimGraphComponentRequestBus")
// General API
@@ -546,24 +546,24 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
AZ::u32 AnimGraphComponent::FindParameterIndex(const char* parameterName)
size_t AnimGraphComponent::FindParameterIndex(const char* parameterName)
{
if (m_animGraphInstance)
{
const AZ::Outcome<size_t> parameterIndex = m_animGraphInstance->FindParameterIndex(parameterName);
if (parameterIndex.IsSuccess())
{
return static_cast<AZ::u32>(parameterIndex.GetValue());
return parameterIndex.GetValue();
}
}
return MCORE_INVALIDINDEX32;
return InvalidIndex;
}
//////////////////////////////////////////////////////////////////////////
const char* AnimGraphComponent::FindParameterName(AZ::u32 parameterIndex)
const char* AnimGraphComponent::FindParameterName(size_t parameterIndex)
{
if (parameterIndex == MCORE_INVALIDINDEX32 || !m_animGraphInstance || !m_animGraphInstance->GetAnimGraph())
if (parameterIndex == InvalidIndex || !m_animGraphInstance || !m_animGraphInstance->GetAnimGraph())
{
return "";
}
@@ -572,11 +572,11 @@ namespace EMotionFX
//////////////////////////////////////////////////////////////////////////
void AnimGraphComponent::SetParameterFloat(AZ::u32 parameterIndex, float value)
void AnimGraphComponent::SetParameterFloat(size_t parameterIndex, float value)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return;
}
@@ -610,7 +610,7 @@ namespace EMotionFX
}
default:
{
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %u can not be set as float, is of type: %s", parameterIndex, param->GetTypeString());
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %zu can not be set as float, is of type: %s", parameterIndex, param->GetTypeString());
return;
}
}
@@ -627,11 +627,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
void AnimGraphComponent::SetParameterBool(AZ::u32 parameterIndex, bool value)
void AnimGraphComponent::SetParameterBool(size_t parameterIndex, bool value)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return;
}
@@ -665,7 +665,7 @@ namespace EMotionFX
}
default:
{
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %u can not be set as bool, is of type: %s", parameterIndex, param->GetTypeString());
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %zu can not be set as bool, is of type: %s", parameterIndex, param->GetTypeString());
return;
}
}
@@ -682,11 +682,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
void AnimGraphComponent::SetParameterString(AZ::u32 parameterIndex, const char* value)
void AnimGraphComponent::SetParameterString(size_t parameterIndex, const char* value)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return;
}
@@ -713,17 +713,17 @@ namespace EMotionFX
}
else
{
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %u is not a string", parameterIndex);
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %zu is not a string", parameterIndex);
}
}
}
//////////////////////////////////////////////////////////////////////////
void AnimGraphComponent::SetParameterVector2(AZ::u32 parameterIndex, const AZ::Vector2& value)
void AnimGraphComponent::SetParameterVector2(size_t parameterIndex, const AZ::Vector2& value)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return;
}
@@ -746,17 +746,17 @@ namespace EMotionFX
}
else
{
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %u is not a vector2", parameterIndex);
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %zu is not a vector2", parameterIndex);
}
}
}
//////////////////////////////////////////////////////////////////////////
void AnimGraphComponent::SetParameterVector3(AZ::u32 parameterIndex, const AZ::Vector3& value)
void AnimGraphComponent::SetParameterVector3(size_t parameterIndex, const AZ::Vector3& value)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return;
}
@@ -779,17 +779,17 @@ namespace EMotionFX
}
else
{
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %u is not a vector3", parameterIndex);
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %zu is not a vector3", parameterIndex);
}
}
}
//////////////////////////////////////////////////////////////////////////
void AnimGraphComponent::SetParameterRotationEuler(AZ::u32 parameterIndex, const AZ::Vector3& value)
void AnimGraphComponent::SetParameterRotationEuler(size_t parameterIndex, const AZ::Vector3& value)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return;
}
@@ -808,7 +808,7 @@ namespace EMotionFX
break;
}
default:
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %u can not be set as rotation euler, is of type: %s", parameterIndex, param->GetTypeString());
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %zu can not be set as rotation euler, is of type: %s", parameterIndex, param->GetTypeString());
return;
}
@@ -824,11 +824,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
void AnimGraphComponent::SetParameterRotation(AZ::u32 parameterIndex, const AZ::Quaternion& value)
void AnimGraphComponent::SetParameterRotation(size_t parameterIndex, const AZ::Quaternion& value)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return;
}
@@ -847,7 +847,7 @@ namespace EMotionFX
break;
}
default:
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %u can not be set as rotation, is of type: %s", parameterIndex, param->GetTypeString());
AZ_Warning("EMotionFX", false, "Anim graph parameter index: %zu can not be set as rotation, is of type: %s", parameterIndex, param->GetTypeString());
return;
}
@@ -986,11 +986,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
float AnimGraphComponent::GetParameterFloat(AZ::u32 parameterIndex)
float AnimGraphComponent::GetParameterFloat(size_t parameterIndex)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return 0.f;
}
@@ -1003,11 +1003,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
bool AnimGraphComponent::GetParameterBool(AZ::u32 parameterIndex)
bool AnimGraphComponent::GetParameterBool(size_t parameterIndex)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return false;
}
@@ -1020,11 +1020,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
AZStd::string AnimGraphComponent::GetParameterString(AZ::u32 parameterIndex)
AZStd::string AnimGraphComponent::GetParameterString(size_t parameterIndex)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return AZStd::string();
}
@@ -1040,11 +1040,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
AZ::Vector2 AnimGraphComponent::GetParameterVector2(AZ::u32 parameterIndex)
AZ::Vector2 AnimGraphComponent::GetParameterVector2(size_t parameterIndex)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return AZ::Vector2::CreateZero();
}
@@ -1058,11 +1058,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
AZ::Vector3 AnimGraphComponent::GetParameterVector3(AZ::u32 parameterIndex)
AZ::Vector3 AnimGraphComponent::GetParameterVector3(size_t parameterIndex)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return AZ::Vector3::CreateZero();
}
@@ -1076,11 +1076,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
AZ::Vector3 AnimGraphComponent::GetParameterRotationEuler(AZ::u32 parameterIndex)
AZ::Vector3 AnimGraphComponent::GetParameterRotationEuler(size_t parameterIndex)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return AZ::Vector3::CreateZero();
}
@@ -1094,11 +1094,11 @@ namespace EMotionFX
}
//////////////////////////////////////////////////////////////////////////
AZ::Quaternion AnimGraphComponent::GetParameterRotation(AZ::u32 parameterIndex)
AZ::Quaternion AnimGraphComponent::GetParameterRotation(size_t parameterIndex)
{
if (parameterIndex == MCORE_INVALIDINDEX32)
if (parameterIndex == InvalidIndex)
{
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %u", parameterIndex);
AZ_Warning("EMotionFX", false, "Invalid anim graph parameter index: %zu", parameterIndex);
return AZ::Quaternion::CreateZero();
}