Translate EMotionFX code to use AZStd::vector instead of MCore::Array #1611

Merge pull request #1611 from aws-lumberyard-dev/burelc/removeMCoreArray
This commit is contained in:
Benjamin Jillich
2021-08-09 11:01:30 -07:00
committed by GitHub
471 changed files with 6586 additions and 10985 deletions
@@ -58,8 +58,8 @@ namespace
const AZ::RHI::Format BoneIndexFormat = AZ::RHI::Format::R32G32B32A32_UINT;
const AZ::RHI::Format BoneWeightFormat = AZ::RHI::Format::R32G32B32A32_FLOAT;
const size_t LinearSkinningFloatsPerBone = 12;
const size_t DualQuaternionSkinningFloatsPerBone = 8;
const uint32_t LinearSkinningFloatsPerBone = 12;
const uint32_t DualQuaternionSkinningFloatsPerBone = 8;
const uint32_t MaxSupportedSkinInfluences = 4;
}
@@ -266,7 +266,7 @@ namespace AZ
}
}
static void ProcessMorphsForLod(const EMotionFX::Actor* actor, const Data::Asset<RPI::BufferAsset>& morphBufferAsset, uint32_t lodIndex, const AZStd::string& fullFileName, SkinnedMeshInputLod& skinnedMeshLod)
static void ProcessMorphsForLod(const EMotionFX::Actor* actor, const Data::Asset<RPI::BufferAsset>& morphBufferAsset, size_t lodIndex, const AZStd::string& fullFileName, SkinnedMeshInputLod& skinnedMeshLod)
{
EMotionFX::MorphSetup* morphSetup = actor->GetMorphSetup(lodIndex);
if (morphSetup)
@@ -275,8 +275,8 @@ namespace AZ
const AZStd::vector<AZ::RPI::MorphTargetMetaAsset::MorphTarget>& metaDatas = actor->GetMorphTargetMetaAsset()->GetMorphTargets();
// Loop over all the EMotionFX morph targets
const AZ::u32 numMorphTargets = morphSetup->GetNumMorphTargets();
for (AZ::u32 morphTargetIndex = 0; morphTargetIndex < numMorphTargets; ++morphTargetIndex)
const size_t numMorphTargets = morphSetup->GetNumMorphTargets();
for (size_t morphTargetIndex = 0; morphTargetIndex < numMorphTargets; ++morphTargetIndex)
{
EMotionFX::MorphTargetStandard* morphTarget = static_cast<EMotionFX::MorphTargetStandard*>(morphSetup->GetMorphTarget(morphTargetIndex));
for (const auto& metaData : metaDatas)
@@ -288,7 +288,7 @@ namespace AZ
if (metaData.m_morphTargetName == morphTarget->GetNameString() && metaData.m_numVertices > 0)
{
// The skinned mesh lod gets a unique morph for each meta, since each one has unique min/max delta values to use for decompression
AZStd::string morphString = AZStd::string::format("%s_Lod%u_Morph_%s", fullFileName.c_str(), lodIndex, metaData.m_meshNodeName.c_str());
const AZStd::string morphString = AZStd::string::format("%s_Lod%zu_Morph_%s", fullFileName.c_str(), lodIndex, metaData.m_meshNodeName.c_str());
float minWeight = morphTarget->GetRangeMin();
float maxWeight = morphTarget->GetRangeMax();
@@ -574,7 +574,7 @@ namespace AZ
AZStd::vector<float> boneTransforms;
GetBoneTransformsFromActorInstance(actorInstance, boneTransforms, skinningMethod);
size_t floatsPerBone = 0;
uint32_t floatsPerBone = 0;
if (skinningMethod == EMotionFX::Integration::SkinningMethod::Linear)
{
floatsPerBone = LinearSkinningFloatsPerBone;
@@ -131,14 +131,13 @@ namespace AZ
const EMotionFX::Skeleton* skeleton = m_actorInstance->GetActor()->GetSkeleton();
const EMotionFX::Pose* pose = transformData->GetCurrentPose();
const AZ::u32 transformCount = transformData->GetNumTransforms();
const AZ::u32 lodLevel = m_actorInstance->GetLODLevel();
const AZ::u32 numJoints = skeleton->GetNumNodes();
const size_t lodLevel = m_actorInstance->GetLODLevel();
const size_t numJoints = skeleton->GetNumNodes();
m_auxVertices.clear();
m_auxVertices.reserve(numJoints * 2);
for (AZ::u32 jointIndex = 0; jointIndex < numJoints; ++jointIndex)
for (size_t jointIndex = 0; jointIndex < numJoints; ++jointIndex)
{
const EMotionFX::Node* joint = skeleton->GetNode(jointIndex);
if (!joint->GetSkeletalLODStatus(lodLevel))
@@ -146,8 +145,8 @@ namespace AZ
continue;
}
const AZ::u32 parentIndex = joint->GetParentIndex();
if (parentIndex == InvalidIndex32)
const size_t parentIndex = joint->GetParentIndex();
if (parentIndex == InvalidIndex)
{
continue;
}
@@ -162,7 +161,7 @@ namespace AZ
const AZ::Color skeletonColor(0.604f, 0.804f, 0.196f, 1.0f);
RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs;
lineArgs.m_verts = m_auxVertices.data();
lineArgs.m_vertCount = static_cast<uint32_t>(m_auxVertices.size());
lineArgs.m_vertCount = aznumeric_caster(m_auxVertices.size());
lineArgs.m_colors = &skeletonColor;
lineArgs.m_colorCount = 1;
lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off;
@@ -203,9 +202,9 @@ namespace AZ
RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments lineArgs;
lineArgs.m_verts = m_auxVertices.data();
lineArgs.m_vertCount = static_cast<uint32_t>(m_auxVertices.size());
lineArgs.m_vertCount = aznumeric_caster(m_auxVertices.size());
lineArgs.m_colors = m_auxColors.data();
lineArgs.m_colorCount = static_cast<uint32_t>(m_auxColors.size());
lineArgs.m_colorCount = aznumeric_caster(m_auxColors.size());
lineArgs.m_depthTest = RPI::AuxGeomDraw::DepthTest::Off;
auxGeom->DrawLines(lineArgs);
}
@@ -450,13 +449,13 @@ namespace AZ
AZ::u32 AtomActorInstance::GetJointCount()
{
return m_actorInstance->GetActor()->GetSkeleton()->GetNumNodes();
return aznumeric_caster(m_actorInstance->GetActor()->GetSkeleton()->GetNumNodes());
}
const char* AtomActorInstance::GetJointNameByIndex(AZ::u32 jointIndex)
{
EMotionFX::Skeleton* skeleton = m_actorInstance->GetActor()->GetSkeleton();
const AZ::u32 numNodes = skeleton->GetNumNodes();
const size_t numNodes = skeleton->GetNumNodes();
if (jointIndex < numNodes)
{
return skeleton->GetNode(jointIndex)->GetName();
@@ -470,12 +469,12 @@ namespace AZ
if (jointName)
{
EMotionFX::Skeleton* skeleton = m_actorInstance->GetActor()->GetSkeleton();
const AZ::u32 numNodes = skeleton->GetNumNodes();
for (AZ::u32 nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex)
const size_t numNodes = skeleton->GetNumNodes();
for (size_t nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex)
{
if (0 == azstricmp(jointName, skeleton->GetNode(nodeIndex)->GetName()))
{
return nodeIndex;
return aznumeric_caster(nodeIndex);
}
}
}
@@ -584,7 +583,8 @@ namespace AZ
// Update the morph weights for every lod. This does not mean they will all be dispatched, but they will all have up to date weights
// TODO: once culling is hooked up such that EMotionFX and Atom are always in sync about which lod to update, only update the currently visible lods [ATOM-13564]
for (uint32_t lodIndex = 0; lodIndex < m_actorInstance->GetActor()->GetNumLODLevels(); ++lodIndex)
const auto lodCount = aznumeric_cast<uint32_t>(m_actorInstance->GetActor()->GetNumLODLevels());
for (uint32_t lodIndex = 0; lodIndex < lodCount; ++lodIndex)
{
EMotionFX::MorphSetup* morphSetup = m_actorInstance->GetActor()->GetMorphSetup(lodIndex);
if (morphSetup)
@@ -593,9 +593,9 @@ namespace AZ
m_wrinkleMasks.clear();
m_wrinkleMaskWeights.clear();
uint32_t morphTargetCount = morphSetup->GetNumMorphTargets();
size_t morphTargetCount = morphSetup->GetNumMorphTargets();
m_morphTargetWeights.clear();
for (uint32_t morphTargetIndex = 0; morphTargetIndex < morphTargetCount; ++morphTargetIndex)
for (size_t morphTargetIndex = 0; morphTargetIndex < morphTargetCount; ++morphTargetIndex)
{
EMotionFX::MorphTarget* morphTarget = morphSetup->GetMorphTarget(morphTargetIndex);
// check if we are dealing with a standard morph target
@@ -611,7 +611,7 @@ namespace AZ
// Each morph target is split into several deform datas, all of which share the same weight but have unique min/max delta values
// and thus correspond with unique dispatches in the morph target pass
for (uint32_t deformDataIndex = 0; deformDataIndex < morphTargetStandard->GetNumDeformDatas(); ++deformDataIndex)
for (size_t deformDataIndex = 0; deformDataIndex < morphTargetStandard->GetNumDeformDatas(); ++deformDataIndex)
{
// Morph targets that don't deform any vertices (e.g. joint-based morph targets) are not registered in the render proxy. Skip adding their weights.
const EMotionFX::MorphTargetStandard::DeformData* deformData = morphTargetStandard->GetDeformData(deformDataIndex);
@@ -816,8 +816,8 @@ namespace AZ
{
const AZStd::vector<AZ::RPI::MorphTargetMetaAsset::MorphTarget>& metaDatas = actor->GetMorphTargetMetaAsset()->GetMorphTargets();
// Loop over all the EMotionFX morph targets
uint32_t numMorphTargets = morphSetup->GetNumMorphTargets();
for (uint32_t morphTargetIndex = 0; morphTargetIndex < numMorphTargets; ++morphTargetIndex)
size_t numMorphTargets = morphSetup->GetNumMorphTargets();
for (size_t morphTargetIndex = 0; morphTargetIndex < numMorphTargets; ++morphTargetIndex)
{
EMotionFX::MorphTargetStandard* morphTarget = static_cast<EMotionFX::MorphTargetStandard*>(morphSetup->GetMorphTarget(morphTargetIndex));
for (const RPI::MorphTargetMetaAsset::MorphTarget& metaData : metaDatas)
@@ -861,7 +861,7 @@ namespace AZ
// Set the weights for any active masks
for (size_t i = 0; i < m_wrinkleMaskWeights.size(); ++i)
{
wrinkleMaskObjectSrg->SetConstant(wrinkleMaskWeightsIndex, m_wrinkleMaskWeights[i], static_cast<uint32_t>(i));
wrinkleMaskObjectSrg->SetConstant(wrinkleMaskWeightsIndex, m_wrinkleMaskWeights[i], aznumeric_caster(i));
}
AZ_Error("AtomActorInstance", m_wrinkleMaskWeights.size() <= s_maxActiveWrinkleMasks, "The skinning shader supports no more than %d active morph targets with wrinkle masks.", s_maxActiveWrinkleMasks);
}
@@ -67,21 +67,21 @@ namespace CommandSystem
}
else
{
EMotionFX::Node* node = skeleton->FindNodeByName(motionExtractionNodeName.c_str());
EMotionFX::Node* node = skeleton->FindNodeByName(motionExtractionNodeName);
actor->SetMotionExtractionNode(node);
}
// Inform all animgraph nodes about this.
const uint32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (uint32 i = 0; i < numAnimGraphs; ++i)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t i = 0; i < numAnimGraphs; ++i)
{
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
if (animGraph->GetIsOwnedByRuntime())
{
continue;
}
const uint32 numObjects = animGraph->GetNumObjects();
for (uint32 n = 0; n < numObjects; ++n)
const size_t numObjects = animGraph->GetNumObjects();
for (size_t n = 0; n < numObjects; ++n)
{
animGraph->GetObject(n)->OnActorMotionExtractionNodeChanged();
}
@@ -100,7 +100,7 @@ namespace CommandSystem
}
else
{
EMotionFX::Node* node = skeleton->FindNodeByName(retargetRootNodeName.c_str());
EMotionFX::Node* node = skeleton->FindNodeByName(retargetRootNodeName);
actor->SetRetargetRootNode(node);
}
}
@@ -120,8 +120,8 @@ namespace CommandSystem
{
// Store old attachment nodes for undo.
mOldAttachmentNodes = "";
const uint32 numNodes = actor->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = actor->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
EMotionFX::Node* node = skeleton->GetNode(i);
if (!node)
@@ -150,9 +150,9 @@ namespace CommandSystem
// Remove the given nodes from the attachment node list by unsetting the flag.
if (AzFramework::StringFunc::Equal(nodeAction.c_str(), "remove"))
{
for (size_t i = 0; i < numNodeNames; ++i)
for (const AZStd::string& nodeName : nodeNames)
{
EMotionFX::Node* node = skeleton->FindNodeByName(nodeNames[i].c_str());
EMotionFX::Node* node = skeleton->FindNodeByName(nodeName);
if (!node)
{
continue;
@@ -164,9 +164,9 @@ namespace CommandSystem
// Add the given nodes to the attachment node list by setting attachment flag.
else if (AzFramework::StringFunc::Equal(nodeAction.c_str(), "add"))
{
for (size_t i = 0; i < numNodeNames; ++i)
for (const AZStd::string& nodeName : nodeNames)
{
EMotionFX::Node* node = skeleton->FindNodeByName(nodeNames[i].c_str());
EMotionFX::Node* node = skeleton->FindNodeByName(nodeName);
if (!node)
{
continue;
@@ -181,9 +181,9 @@ namespace CommandSystem
SetIsAttachmentNode(actor, false);
// Set attachment node flag based on selection list.
for (size_t i = 0; i < numNodeNames; ++i)
for (const AZStd::string& nodeName : nodeNames)
{
EMotionFX::Node* node = skeleton->FindNodeByName(nodeNames[i].c_str());
EMotionFX::Node* node = skeleton->FindNodeByName(nodeName);
if (!node)
{
continue;
@@ -199,8 +199,8 @@ namespace CommandSystem
{
// Store old nodes for undo.
mOldExcludedFromBoundsNodes = "";
const uint32 numNodes = actor->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = actor->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
EMotionFX::Node* node = skeleton->GetNode(i);
if (!node)
@@ -229,9 +229,9 @@ namespace CommandSystem
// Remove the selected nodes from the bounding volume calculations.
if (AzFramework::StringFunc::Equal(nodeAction.c_str(), "remove"))
{
for (size_t i = 0; i < numNodeNames; ++i)
for (const AZStd::string& nodeName : nodeNames)
{
EMotionFX::Node* node = skeleton->FindNodeByName(nodeNames[i].c_str());
EMotionFX::Node* node = skeleton->FindNodeByName(nodeName);
if (!node)
{
continue;
@@ -243,9 +243,9 @@ namespace CommandSystem
// Add the given nodes to the bounding volume calculations.
if (AzFramework::StringFunc::Equal(nodeAction.c_str(), "add"))
{
for (size_t i = 0; i < numNodeNames; ++i)
for (const AZStd::string& nodeName : nodeNames)
{
EMotionFX::Node* node = skeleton->FindNodeByName(nodeNames[i].c_str());
EMotionFX::Node* node = skeleton->FindNodeByName(nodeName);
if (!node)
{
continue;
@@ -260,9 +260,9 @@ namespace CommandSystem
SetIsExcludedFromBoundsNode(actor, false);
// Remove the nodes from bounding volume calculation based on the selection.
for (size_t i = 0; i < numNodeNames; ++i)
for (const AZStd::string& nodeName : nodeNames)
{
EMotionFX::Node* node = skeleton->FindNodeByName(nodeNames[i].c_str());
EMotionFX::Node* node = skeleton->FindNodeByName(nodeName);
if (!node)
{
continue;
@@ -294,19 +294,18 @@ namespace CommandSystem
AzFramework::StringFunc::Tokenize(mirrorSetupString.c_str(), pairs, ";", false, true);
// Parse the mirror setup string, which is like "nodeA,nodeB;nodeC,nodeD;".
const size_t numPairs = pairs.size();
for (size_t p = 0; p < numPairs; ++p)
for (const AZStd::string& pair : pairs)
{
// Split the pairs into the node names.
AZStd::vector<AZStd::string> pairValues;
AzFramework::StringFunc::Tokenize(pairs[p].c_str(), pairValues, ",", false, true);
AzFramework::StringFunc::Tokenize(pair.c_str(), pairValues, ",", false, true);
if (pairValues.size() != 2)
{
continue;
}
EMotionFX::Node* nodeA = actor->GetSkeleton()->FindNodeByName(pairValues[0].c_str());
EMotionFX::Node* nodeB = actor->GetSkeleton()->FindNodeByName(pairValues[1].c_str());
EMotionFX::Node* nodeA = actor->GetSkeleton()->FindNodeByName(pairValues[0]);
EMotionFX::Node* nodeB = actor->GetSkeleton()->FindNodeByName(pairValues[1]);
if (nodeA && nodeB)
{
actor->GetNodeMirrorInfo(nodeA->GetNodeIndex()).mSourceNode = static_cast<uint16>(nodeB->GetNodeIndex());
@@ -411,8 +410,8 @@ namespace CommandSystem
// Static function to set all IsAttachmentNode flags of the actor to the given value.
void CommandAdjustActor::SetIsAttachmentNode(EMotionFX::Actor* actor, bool isAttachmentNode)
{
const uint32 numNodes = actor->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = actor->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
EMotionFX::Node* node = actor->GetSkeleton()->GetNode(i);
if (!node)
@@ -428,8 +427,8 @@ namespace CommandSystem
// Static function to set all IsAttachmentNode flags of the actor to the given value.
void CommandAdjustActor::SetIsExcludedFromBoundsNode(EMotionFX::Actor* actor, bool excludedFromBounds)
{
const uint32 numNodes = actor->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = actor->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
EMotionFX::Node* node = actor->GetSkeleton()->GetNode(i);
if (!node)
@@ -476,12 +475,12 @@ namespace CommandSystem
return false;
}
const uint32 numNodes = actor->GetNumNodes();
const size_t numNodes = actor->GetNumNodes();
EMotionFX::Skeleton* skeleton = actor->GetSkeleton();
// Store the old nodes for the undo.
mOldNodeList = "";
for (uint32 i = 0; i < numNodes; ++i)
for (size_t i = 0; i < numNodes; ++i)
{
EMotionFX::Mesh* mesh = actor->GetMesh(lod, i);
if (mesh && mesh->GetIsCollisionMesh())
@@ -504,7 +503,7 @@ namespace CommandSystem
AzFramework::StringFunc::Tokenize(nodeList.c_str(), nodeNames, ";", false, true);
// Update the collision mesh flags.
for (uint32 i = 0; i < numNodes; ++i)
for (size_t i = 0; i < numNodes; ++i)
{
const EMotionFX::Node* node = skeleton->GetNode(i);
EMotionFX::Mesh* mesh = actor->GetMesh(lod, i);
@@ -574,7 +573,7 @@ namespace CommandSystem
{
MCORE_UNUSED(parameters);
const uint32 numSelectedActorInstances = GetCommandManager()->GetCurrentSelection().GetNumSelectedActorInstances();
const size_t numSelectedActorInstances = GetCommandManager()->GetCurrentSelection().GetNumSelectedActorInstances();
if (numSelectedActorInstances == 0)
{
outResult = "Cannot reset actor instances to bind pose. No actor instance selected.";
@@ -582,7 +581,7 @@ namespace CommandSystem
}
// Iterate through all selected actor instances and reset them to bind pose.
for (uint32 i = 0; i < numSelectedActorInstances; ++i)
for (size_t i = 0; i < numSelectedActorInstances; ++i)
{
EMotionFX::ActorInstance* actorInstance = GetCommandManager()->GetCurrentSelection().GetActorInstance(i);
@@ -792,8 +791,8 @@ namespace CommandSystem
}
// get number of actors and instances
const uint32 numActors = EMotionFX::GetActorManager().GetNumActors();
const uint32 numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
const size_t numActors = EMotionFX::GetActorManager().GetNumActors();
const size_t numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
// create the command group
MCore::CommandGroup internalCommandGroup("Clear scene");
@@ -811,7 +810,7 @@ namespace CommandSystem
if (deleteActors || deleteActorInstances)
{
// get rid of all actor instances
for (uint32 i = 0; i < numActorInstances; ++i)
for (size_t i = 0; i < numActorInstances; ++i)
{
// get pointer to the current actor instance
EMotionFX::ActorInstance* actorInstance = EMotionFX::GetActorManager().GetActorInstance(i);
@@ -847,7 +846,7 @@ namespace CommandSystem
if (deleteActors)
{
// iterate through all available actors
for (uint32 i = 0; i < numActors; ++i)
for (size_t i = 0; i < numActors; ++i)
{
// get the current actor
EMotionFX::Actor* actor = EMotionFX::GetActorManager().GetActor(i);
@@ -903,7 +902,7 @@ namespace CommandSystem
// walk over the meshes and check which of them we want to set as collision mesh
void PrepareCollisionMeshesNodesString(EMotionFX::Actor* actor, uint32 lod, AZStd::string* outNodeNames)
void PrepareCollisionMeshesNodesString(EMotionFX::Actor* actor, size_t lod, AZStd::string* outNodeNames)
{
// reset the resulting string
outNodeNames->clear();
@@ -922,8 +921,8 @@ namespace CommandSystem
}
// get the number of nodes and iterate through them
const uint32 numNodes = actor->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = actor->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
EMotionFX::Mesh* mesh = actor->GetMesh(lod, i);
if (mesh && mesh->GetIsCollisionMesh())
@@ -951,8 +950,8 @@ namespace CommandSystem
}
// get the number of nodes and iterate through them
const uint32 numNodes = actor->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = actor->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
EMotionFX::Node* node = actor->GetSkeleton()->GetNode(i);
@@ -1054,8 +1053,8 @@ namespace CommandSystem
}
// update the static aabb's of all actor instances
const uint32 numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (uint32 i = 0; i < numActorInstances; ++i)
const size_t numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (size_t i = 0; i < numActorInstances; ++i)
{
EMotionFX::ActorInstance* actorInstance = EMotionFX::GetActorManager().GetActorInstance(i);
if (actorInstance->GetActor() != actor)
@@ -19,13 +19,13 @@ namespace CommandSystem
{
// Adjust the given actor.
MCORE_DEFINECOMMAND_START(CommandAdjustActor, "Adjust actor", true)
uint32 mOldMotionExtractionNodeIndex;
uint32 mOldRetargetRootNodeIndex;
uint32 mOldTrajectoryNodeIndex;
size_t mOldMotionExtractionNodeIndex;
size_t mOldRetargetRootNodeIndex;
size_t mOldTrajectoryNodeIndex;
AZStd::string mOldAttachmentNodes;
AZStd::string mOldExcludedFromBoundsNodes;
AZStd::string mOldName;
MCore::Array<EMotionFX::Actor::NodeMirrorInfo> mOldMirrorSetup;
AZStd::vector<EMotionFX::Actor::NodeMirrorInfo> mOldMirrorSetup;
bool mOldDirtyFlag;
void SetIsAttachmentNode(EMotionFX::Actor* actor, bool isAttachmentNode);
@@ -71,6 +71,6 @@ public:
// Helper functions
//////////////////////////////////////////////////////////////////////////////////////////////////////////
void COMMANDSYSTEM_API ClearScene(bool deleteActors = true, bool deleteActorInstances = true, MCore::CommandGroup* commandGroup = nullptr);
void COMMANDSYSTEM_API PrepareCollisionMeshesNodesString(EMotionFX::Actor* actor, uint32 lod, AZStd::string* outNodeNames);
void COMMANDSYSTEM_API PrepareCollisionMeshesNodesString(EMotionFX::Actor* actor, size_t lod, AZStd::string* outNodeNames);
void COMMANDSYSTEM_API PrepareExcludedNodesString(EMotionFX::Actor* actor, AZStd::string* outNodeNames);
} // namespace CommandSystem
@@ -141,7 +141,7 @@ namespace CommandSystem
// add the actor instance to the selection
if (select)
{
GetCommandManager()->ExecuteCommandInsideCommand(AZStd::string::format("Select -actorInstanceID %i", newInstance->GetID()).c_str(), outResult);
GetCommandManager()->ExecuteCommandInsideCommand(AZStd::string::format("Select -actorInstanceID %u", newInstance->GetID()).c_str(), outResult);
if (EMotionFX::GetActorManager().GetNumActorInstances() == 1 && GetCommandManager()->GetLockSelection() == false)
{
@@ -492,7 +492,7 @@ namespace CommandSystem
commandString = AZStd::string::format("CreateActorInstance -actorID %i -actorInstanceID %i", mOldActorID, actorInstanceID);
commandGroup.AddCommandString(commandString.c_str());
commandString = AZStd::string::format("AdjustActorInstance -actorInstanceID %i -pos \"%s\" -rot \"%s\" -scale \"%s\" -lodLevel %d -isVisible \"%s\" -doRender \"%s\"",
commandString = AZStd::string::format("AdjustActorInstance -actorInstanceID %i -pos \"%s\" -rot \"%s\" -scale \"%s\" -lodLevel %zu -isVisible \"%s\" -doRender \"%s\"",
actorInstanceID,
AZStd::to_string(mOldPosition).c_str(),
AZStd::to_string(mOldRotation).c_str(),
@@ -561,7 +561,7 @@ namespace CommandSystem
{
// get the selection and number of selected actor instances
const SelectionList& selection = GetCommandManager()->GetCurrentSelection();
const uint32 numActorInstances = selection.GetNumSelectedActorInstances();
const size_t numActorInstances = selection.GetNumSelectedActorInstances();
// create the command group
MCore::CommandGroup commandGroup("Clone actor instances", numActorInstances);
@@ -570,7 +570,7 @@ namespace CommandSystem
commandGroup.AddCommandString("Unselect -actorInstanceID SELECT_ALL -actorID SELECT_ALL");
// iterate over the selected instances and clone them
for (uint32 i = 0; i < numActorInstances; ++i)
for (size_t i = 0; i < numActorInstances; ++i)
{
// get the current actor instance
EMotionFX::ActorInstance* actorInstance = selection.GetActorInstance(i);
@@ -612,14 +612,14 @@ namespace CommandSystem
{
// get the selection and number of selected actor instances
const SelectionList& selection = GetCommandManager()->GetCurrentSelection();
const uint32 numActorInstances = selection.GetNumSelectedActorInstances();
const size_t numActorInstances = selection.GetNumSelectedActorInstances();
// create the command group
MCore::CommandGroup commandGroup("Remove actor instances", numActorInstances);
AZStd::string tempString;
// iterate over the selected instances and clone them
for (uint32 i = 0; i < numActorInstances; ++i)
for (size_t i = 0; i < numActorInstances; ++i)
{
// get the current actor instance
EMotionFX::ActorInstance* actorInstance = selection.GetActorInstance(i);
@@ -645,7 +645,7 @@ namespace CommandSystem
{
// get the selection and number of selected actor instances
const SelectionList& selection = GetCommandManager()->GetCurrentSelection();
const uint32 numActorInstances = selection.GetNumSelectedActorInstances();
const size_t numActorInstances = selection.GetNumSelectedActorInstances();
// create the command group
AZStd::string outResult;
@@ -653,7 +653,7 @@ namespace CommandSystem
MCore::CommandGroup commandGroup("Hide actor instances", numActorInstances * 2);
// iterate over the selected instances
for (uint32 i = 0; i < numActorInstances; ++i)
for (size_t i = 0; i < numActorInstances; ++i)
{
// get the current actor instance
EMotionFX::ActorInstance* actorInstance = selection.GetActorInstance(i);
@@ -685,7 +685,7 @@ namespace CommandSystem
{
// get the selection and number of selected actor instances
const SelectionList& selection = GetCommandManager()->GetCurrentSelection();
const uint32 numActorInstances = selection.GetNumSelectedActorInstances();
const size_t numActorInstances = selection.GetNumSelectedActorInstances();
// create the command group
AZStd::string outResult;
@@ -693,7 +693,7 @@ namespace CommandSystem
MCore::CommandGroup commandGroup("Unhide actor instances", numActorInstances * 2);
// iterate over the selected instances
for (uint32 i = 0; i < numActorInstances; ++i)
for (size_t i = 0; i < numActorInstances; ++i)
{
// get the current actor instance
EMotionFX::ActorInstance* actorInstance = selection.GetActorInstance(i);
@@ -722,7 +722,7 @@ namespace CommandSystem
{
// get the selection and number of selected actor instances
SelectionList selection = GetCommandManager()->GetCurrentSelection();
const uint32 numActorInstances = selection.GetNumSelectedActorInstances();
const size_t numActorInstances = selection.GetNumSelectedActorInstances();
// create the command group
AZStd::string outResult;
@@ -730,7 +730,7 @@ namespace CommandSystem
MCore::CommandGroup commandGroup("Unselect all actor instances", numActorInstances + 1);
// iterate over the selected instances and clone them
for (uint32 i = 0; i < numActorInstances; ++i)
for (size_t i = 0; i < numActorInstances; ++i)
{
// get the current actor instance
EMotionFX::ActorInstance* actorInstance = selection.GetActorInstance(i);
@@ -31,7 +31,7 @@ public:
AZ::Vector3 mOldPosition;
AZ::Quaternion mOldRotation;
AZ::Vector3 mOldScale;
uint32 mOldLODLevel;
size_t mOldLODLevel;
bool mOldIsVisible;
bool mOldDoRender;
bool mOldWorkspaceDirtyFlag;
@@ -44,7 +44,7 @@ public:
AZ::Vector3 mOldPosition;
AZ::Quaternion mOldRotation;
AZ::Vector3 mOldScale;
uint32 mOldLODLevel;
size_t mOldLODLevel;
bool mOldIsVisible;
bool mOldDoRender;
bool mOldWorkspaceDirtyFlag;
@@ -77,8 +77,8 @@ namespace CommandSystem
}
// Check if the anim graph got already loaded via the command system.
const AZ::u32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (AZ::u32 i = 0; i < numAnimGraphs; ++i)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t i = 0; i < numAnimGraphs; ++i)
{
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
if (animGraph->GetFileNameString() == filename &&
@@ -312,7 +312,7 @@ namespace CommandSystem
// remove all anim graphs, to do so we will iterate over them and issue an internal command for
// that specific ID. This way we don't need to add complexity to this command to deal with all
// the anim graph's undo data
for (uint32 i = 0; i < EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();)
for (size_t i = 0; i < EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();)
{
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
if (!animGraph->GetIsOwnedByRuntime() && !animGraph->GetIsOwnedByAsset())
@@ -354,7 +354,7 @@ namespace CommandSystem
// remove the given anim graph
m_oldFileNamesAndIds.emplace_back(animGraph->GetFileName(), animGraph->GetID());
uint32 oldIndex = EMotionFX::GetAnimGraphManager().FindAnimGraphIndex(animGraph);
size_t oldIndex = EMotionFX::GetAnimGraphManager().FindAnimGraphIndex(animGraph);
// iterate through all anim graph instances and remove the ones that depend on the anim graph to be removed
for (size_t i = 0; i < EMotionFX::GetAnimGraphManager().GetNumAnimGraphInstances(); )
@@ -375,15 +375,9 @@ namespace CommandSystem
EMotionFX::GetAnimGraphManager().RemoveAnimGraph(animGraph);
// Reselect the anim graph at the index of the removed one if possible.
const int numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (int indexToSelect = oldIndex; indexToSelect >= 0; indexToSelect--)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t indexToSelect = oldIndex; indexToSelect < numAnimGraphs; indexToSelect--)
{
// Is the index to select in a valid range?
if (indexToSelect >= numAnimGraphs)
{
break;
}
EMotionFX::AnimGraph* selectionCandidate = EMotionFX::GetAnimGraphManager().GetAnimGraph(indexToSelect);
if (!selectionCandidate->GetIsOwnedByRuntime())
{
@@ -521,8 +515,8 @@ namespace CommandSystem
EMotionFX::MotionSystem* motionSystem = actorInstance->GetMotionSystem();
// remove all motion instances from this motion system
const uint32 numMotionInstances = motionSystem->GetNumMotionInstances();
for (uint32 j = 0; j < numMotionInstances; ++j)
const size_t numMotionInstances = motionSystem->GetNumMotionInstances();
for (size_t j = 0; j < numMotionInstances; ++j)
{
EMotionFX::MotionInstance* motionInstance = motionSystem->GetMotionInstance(j);
motionSystem->RemoveMotionInstance(motionInstance);
@@ -665,8 +659,8 @@ namespace CommandSystem
EMotionFX::MotionSystem* motionSystem = actorInstance->GetMotionSystem();
// remove all motion instances from this motion system
const uint32 numMotionInstances = motionSystem->GetNumMotionInstances();
for (uint32 j = 0; j < numMotionInstances; ++j)
const size_t numMotionInstances = motionSystem->GetNumMotionInstances();
for (size_t j = 0; j < numMotionInstances; ++j)
{
EMotionFX::MotionInstance* motionInstance = motionSystem->GetMotionInstance(j);
motionSystem->RemoveMotionInstance(motionInstance);
@@ -791,8 +785,8 @@ namespace CommandSystem
if (reload)
{
// Remove all anim graphs with the given filename.
const AZ::u32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (AZ::u32 j = 0; j < numAnimGraphs; ++j)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t j = 0; j < numAnimGraphs; ++j)
{
const EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(j);
@@ -124,10 +124,10 @@ namespace CommandSystem
// in case the source port got specified by name, overwrite the source port number
if (!mSourcePortName.empty())
{
mSourcePort = sourceNode->FindOutputPortIndex(mSourcePortName.c_str());
mSourcePort = sourceNode->FindOutputPortIndex(mSourcePortName);
// in case we want to add this connection to a parameter node while the parameter name doesn't exist, still return true so that copy paste doesn't fail
if (azrtti_typeid(sourceNode) == azrtti_typeid<EMotionFX::BlendTreeParameterNode>() && mSourcePort == -1)
if (azrtti_typeid(sourceNode) == azrtti_typeid<EMotionFX::BlendTreeParameterNode>() && mSourcePort == InvalidIndex)
{
m_connectionId.SetInvalid();
return true;
@@ -157,13 +157,13 @@ namespace CommandSystem
}
// verify port ranges
if (mSourcePort >= static_cast<int32>(sourceNode->GetOutputPorts().size()) || mSourcePort < 0)
if (mSourcePort >= sourceNode->GetOutputPorts().size())
{
outResult = AZStd::string::format("The output port number is not valid for the given node. Node '%s' only has %zu output ports.", sourceNode->GetName(), sourceNode->GetOutputPorts().size());
return false;
}
if (mTargetPort >= static_cast<int32>(targetNode->GetInputPorts().size()) || mTargetPort < 0)
if (mTargetPort >= targetNode->GetInputPorts().size())
{
outResult = AZStd::string::format("The input port number is not valid for the given node. Node '%s' only has %zu input ports.", targetNode->GetName(), targetNode->GetInputPorts().size());
return false;
@@ -345,7 +345,7 @@ namespace CommandSystem
}
// delete the connection
const AZStd::string commandString = AZStd::string::format("AnimGraphRemoveConnection -animGraphID %i -targetNode \"%s\" -targetPort %d -sourceNode \"%s\" -sourcePort %d -id %s",
const AZStd::string commandString = AZStd::string::format("AnimGraphRemoveConnection -animGraphID %i -targetNode \"%s\" -targetPort %zu -sourceNode \"%s\" -sourcePort %zu -id %s",
animGraph->GetID(),
targetNode->GetName(),
mTargetPort,
@@ -356,7 +356,7 @@ namespace CommandSystem
// execute the command without putting it in the history
if (!GetCommandManager()->ExecuteCommandInsideCommand(commandString, outResult))
{
if (outResult.size() > 0)
if (!outResult.empty())
{
MCore::LogError(outResult.c_str());
}
@@ -414,8 +414,8 @@ namespace CommandSystem
CommandAnimGraphRemoveConnection::CommandAnimGraphRemoveConnection(MCore::Command* orgCommand)
: MCore::Command("AnimGraphRemoveConnection", orgCommand)
{
mSourcePort = MCORE_INVALIDINDEX32;
mTargetPort = MCORE_INVALIDINDEX32;
mSourcePort = InvalidIndex;
mTargetPort = InvalidIndex;
mTransitionType = AZ::TypeId::CreateNull();
mStartOffsetX = 0;
mStartOffsetY = 0;
@@ -603,7 +603,7 @@ namespace CommandSystem
return false;
}
AZStd::string commandString = AZStd::string::format("AnimGraphCreateConnection -animGraphID %i -sourceNode \"%s\" -targetNode \"%s\" -sourcePort %d -targetPort %d -startOffsetX %d -startOffsetY %d -endOffsetX %d -endOffsetY %d -id %s -transitionType \"%s\" -updateUniqueData %s",
AZStd::string commandString = AZStd::string::format("AnimGraphCreateConnection -animGraphID %i -sourceNode \"%s\" -targetNode \"%s\" -sourcePort %zu -targetPort %zu -startOffsetX %d -startOffsetY %d -endOffsetX %d -endOffsetY %d -id %s -transitionType \"%s\" -updateUniqueData %s",
animGraph->GetID(),
mSourceNodeName.c_str(),
mTargetNodeName.c_str(),
@@ -623,7 +623,7 @@ namespace CommandSystem
if (!GetCommandManager()->ExecuteCommandInsideCommand(commandString, outResult))
{
if (outResult.size() > 0)
if (!outResult.empty())
{
MCore::LogError(outResult.c_str());
}
@@ -634,8 +634,8 @@ namespace CommandSystem
mTargetNodeId.SetInvalid();
mSourceNodeId.SetInvalid();
m_connectionId.SetInvalid();
mSourcePort = MCORE_INVALIDINDEX32;
mTargetPort = MCORE_INVALIDINDEX32;
mSourcePort = InvalidIndex;
mTargetPort = InvalidIndex;
mStartOffsetX = 0;
mStartOffsetY = 0;
mEndOffsetX = 0;
@@ -970,8 +970,8 @@ namespace CommandSystem
// Delete the connections that start from the given node.
if (parentNode)
{
const uint32 numChildNodes = parentNode->GetNumChildNodes();
for (uint32 i = 0; i < numChildNodes; ++i)
const size_t numChildNodes = parentNode->GetNumChildNodes();
for (size_t i = 0; i < numChildNodes; ++i)
{
EMotionFX::AnimGraphNode* childNode = parentNode->GetChildNode(i);
if (childNode == node)
@@ -979,8 +979,8 @@ namespace CommandSystem
continue;
}
const uint32 numChildConnections = childNode->GetNumConnections();
for (uint32 j = 0; j < numChildConnections; ++j)
const size_t numChildConnections = childNode->GetNumConnections();
for (size_t j = 0; j < numChildConnections; ++j)
{
EMotionFX::BlendTreeConnection* childConnection = childNode->GetConnection(j);
@@ -994,8 +994,8 @@ namespace CommandSystem
}
// Delete the connections that end in the given node.
const uint32 numConnections = node->GetNumConnections();
for (uint32 i = 0; i < numConnections; ++i)
const size_t numConnections = node->GetNumConnections();
for (size_t i = 0; i < numConnections; ++i)
{
EMotionFX::BlendTreeConnection* connection = node->GetConnection(i);
DeleteConnection(commandGroup, node, connection, connectionList);
@@ -1004,8 +1004,8 @@ namespace CommandSystem
// Recursively delete all connections.
if (recursive)
{
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)
{
EMotionFX::AnimGraphNode* childNode = node->GetChildNode(i);
DeleteNodeConnections(commandGroup, childNode, node, connectionList, recursive);
@@ -1194,8 +1194,8 @@ namespace CommandSystem
// Recursively delete all transitions.
if (recursive)
{
const uint32 numChildNodes = state->GetNumChildNodes();
for (uint32 i = 0; i < numChildNodes; ++i)
const size_t numChildNodes = state->GetNumChildNodes();
for (size_t i = 0; i < numChildNodes; ++i)
{
EMotionFX::AnimGraphNode* childNode = state->GetChildNode(i);
DeleteStateTransitions(commandGroup, childNode, state, transitionList, recursive);
@@ -35,8 +35,8 @@ namespace CommandSystem
int32 mStartOffsetY;
int32 mEndOffsetX;
int32 mEndOffsetY;
int32 mSourcePort;
int32 mTargetPort;
size_t mSourcePort;
size_t mTargetPort;
AZStd::string mSourcePortName;
AZStd::string mTargetPortName;
bool mOldDirtyFlag;
@@ -47,8 +47,8 @@ namespace CommandSystem
EMotionFX::AnimGraphNodeId GetTargetNodeId() const { return mTargetNodeId; }
EMotionFX::AnimGraphNodeId GetSourceNodeId() const { return mSourceNodeId; }
AZ::TypeId GetTransitionType() const { return mTransitionType; }
int32 GetSourcePort() const { return mSourcePort; }
int32 GetTargetPort() const { return mTargetPort; }
size_t GetSourcePort() const { return mSourcePort; }
size_t GetTargetPort() const { return mTargetPort; }
int32 GetStartOffsetX() const { return mStartOffsetX; }
int32 GetStartOffsetY() const { return mStartOffsetY; }
int32 GetEndOffsetX() const { return mEndOffsetX; }
@@ -69,8 +69,8 @@ namespace CommandSystem
int32 mStartOffsetY;
int32 mEndOffsetX;
int32 mEndOffsetY;
int32 mSourcePort;
int32 mTargetPort;
size_t mSourcePort;
size_t mTargetPort;
bool mOldDirtyFlag;
AZStd::string mOldContents;
@@ -78,8 +78,8 @@ namespace CommandSystem
EMotionFX::AnimGraphNodeId GetTargetNodeID() const { return mTargetNodeId; }
EMotionFX::AnimGraphNodeId GetSourceNodeID() const { return mSourceNodeId; }
AZ::TypeId GetTransitionType() const { return mTransitionType; }
int32 GetSourcePort() const { return mSourcePort; }
int32 GetTargetPort() const { return mTargetPort; }
size_t GetSourcePort() const { return mSourcePort; }
size_t GetTargetPort() const { return mTargetPort; }
int32 GetStartOffsetX() const { return mStartOffsetX; }
int32 GetStartOffsetY() const { return mStartOffsetY; }
int32 GetEndOffsetX() const { return mEndOffsetX; }
@@ -370,8 +370,8 @@ namespace CommandSystem
animGraph->RecursiveInvalidateUniqueDatas();
// init new node for all anim graph instances belonging to it
const uint32 numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (uint32 i = 0; i < numActorInstances; ++i)
const size_t numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (size_t i = 0; i < numActorInstances; ++i)
{
EMotionFX::AnimGraphInstance* animGraphInstance = EMotionFX::GetActorManager().GetActorInstance(i)->GetAnimGraphInstance();
if (animGraphInstance && animGraphInstance->GetAnimGraph() == animGraph)
@@ -416,7 +416,7 @@ namespace CommandSystem
const AZStd::string commandString = AZStd::string::format("AnimGraphRemoveNode -animGraphID %i -name \"%s\"", animGraph->GetID(), node->GetName());
if (GetCommandManager()->ExecuteCommandInsideCommand(commandString, outResult) == false)
{
if (outResult.size() > 0)
if (!outResult.empty())
{
MCore::LogError(outResult.c_str());
}
@@ -743,8 +743,8 @@ namespace CommandSystem
//--------------------------
// Find alternative entry state.
EMotionFX::AnimGraphNode* newEntryState = nullptr;
uint32 numStates = stateMachine->GetNumChildNodes();
for (uint32 s = 0; s < numStates; ++s)
size_t numStates = stateMachine->GetNumChildNodes();
for (size_t s = 0; s < numStates; ++s)
{
EMotionFX::AnimGraphNode* childNode = stateMachine->GetChildNode(s);
if (childNode != emfxNode)
@@ -848,7 +848,7 @@ namespace CommandSystem
if (!GetCommandManager()->ExecuteCommandGroupInsideCommand(group, outResult))
{
if (outResult.size() > 0)
if (!outResult.empty())
{
MCore::LogError(outResult.c_str());
}
@@ -870,7 +870,7 @@ namespace CommandSystem
);
if (GetCommandManager()->ExecuteCommandInsideCommand(command, outResult) == false)
{
if (outResult.size() > 0)
if (!outResult.empty())
{
MCore::LogError(outResult.c_str());
}
@@ -1204,19 +1204,18 @@ namespace CommandSystem
if (parentNode)
{
// Gather the number of nodes with the same type as the one we're trying to remove.
MCore::Array<EMotionFX::AnimGraphNode*> outNodes;
AZStd::vector<EMotionFX::AnimGraphNode*> outNodes;
const AZ::TypeId nodeType = azrtti_typeid(node);
parentNode->CollectChildNodesOfType(nodeType, &outNodes);
const uint32 numTypeNodes = outNodes.GetLength();
const size_t numTypeNodes = outNodes.size();
// Gather the number of already removed nodes with the same type as the one we're trying to remove.
const size_t numTotalDeletedNodes = nodeList.size();
uint32 numTypeDeletedNodes = 0;
for (size_t i = 0; i < numTotalDeletedNodes; ++i)
size_t numTypeDeletedNodes = 0;
for (const EMotionFX::AnimGraphNode* i : nodeList)
{
// Check if the nodes have the same parent, meaning they are in the same graph plus check if they have the same type
// if that both is the same we can increase the number of deleted nodes for the graph where the current node is in.
if (nodeList[i]->GetParentNode() == parentNode && azrtti_typeid(nodeList[i]) == nodeType)
if (i->GetParentNode() == parentNode && azrtti_typeid(i) == nodeType)
{
numTypeDeletedNodes++;
}
@@ -1242,8 +1241,8 @@ namespace CommandSystem
// 2. Delete all child nodes recursively before deleting the node.
// Get the number of child nodes, iterate through them and recursively call the function.
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)
{
EMotionFX::AnimGraphNode* childNode = node->GetChildNode(i);
DeleteNode(commandGroup, animGraph, childNode, nodeList, connectionList, transitionList, true, false, false);
@@ -1268,10 +1267,9 @@ namespace CommandSystem
void DeleteNodes(MCore::CommandGroup* commandGroup, EMotionFX::AnimGraph* animGraph, const AZStd::vector<AZStd::string>& nodeNames, AZStd::vector<EMotionFX::AnimGraphNode*>& nodeList, AZStd::vector<EMotionFX::BlendTreeConnection*>& connectionList, AZStd::vector<EMotionFX::AnimGraphStateTransition*>& transitionList, bool autoChangeEntryStates)
{
const size_t numNodeNames = nodeNames.size();
for (size_t i = 0; i < numNodeNames; ++i)
for (const AZStd::string& nodeName : nodeNames)
{
EMotionFX::AnimGraphNode* node = animGraph->RecursiveFindNodeByName(nodeNames[i].c_str());
EMotionFX::AnimGraphNode* node = animGraph->RecursiveFindNodeByName(nodeName.c_str());
// Add the delete node commands to the command group.
DeleteNode(commandGroup, animGraph, node, nodeList, connectionList, transitionList, true, true, autoChangeEntryStates);
@@ -1385,8 +1383,8 @@ namespace CommandSystem
}
// Recurse through the child nodes.
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)
{
EMotionFX::AnimGraphNode* childNode = node->GetChildNode(i);
CopyAnimGraphNodeCommand(commandGroup, targetAnimGraph, node, childNode,
@@ -1404,8 +1402,8 @@ namespace CommandSystem
}
// Recurse through the child nodes.
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)
{
EMotionFX::AnimGraphNode* childNode = node->GetChildNode(i);
CopyAnimGraphConnectionsCommand(commandGroup, targetAnimGraph, childNode,
@@ -1436,8 +1434,8 @@ namespace CommandSystem
}
else
{
const uint32 numConnections = node->GetNumConnections();
for (uint32 i = 0; i < numConnections; ++i)
const size_t numConnections = node->GetNumConnections();
for (size_t i = 0; i < numConnections; ++i)
{
EMotionFX::BlendTreeConnection* connection = node->GetConnection(i);
CopyBlendTreeConnection(commandGroup, targetAnimGraph, node, connection,
@@ -1455,29 +1453,14 @@ namespace CommandSystem
}
// Remove all nodes that are child nodes of other selected nodes.
for (size_t i = 0; i < nodesToCopy.size();)
AZStd::erase_if(nodesToCopy, [&nodesToCopy](const EMotionFX::AnimGraphNode* node)
{
EMotionFX::AnimGraphNode* node = nodesToCopy[i];
bool removeNode = false;
for (size_t j = 0; j < nodesToCopy.size(); ++j)
const auto found = AZStd::find_if(begin(nodesToCopy), end(nodesToCopy), [node](const EMotionFX::AnimGraphNode* parent)
{
if (node != nodesToCopy[j] && node->RecursiveIsParentNode(nodesToCopy[j]))
{
removeNode = true;
break;
}
}
if (removeNode)
{
nodesToCopy.erase(nodesToCopy.begin() + i);
}
else
{
i++;
}
}
return node != parent && node->RecursiveIsParentNode(parent);
});
return found != end(nodesToCopy);
});
// In case we are in cut and paste mode and delete the cut nodes.
if (cutMode)
@@ -71,9 +71,9 @@ namespace CommandSystem
{
AZStd::vector<EMotionFX::AnimGraphNodeId> result;
const uint32 numNodes = nodeGroup->GetNumNodes();
const size_t numNodes = nodeGroup->GetNumNodes();
result.reserve(numNodes);
for (uint32 i = 0; i < numNodes; ++i)
for (size_t i = 0; i < numNodes; ++i)
{
result.push_back(nodeGroup->GetNode(i));
}
@@ -91,8 +91,8 @@ namespace CommandSystem
}
// find the node group index
const uint32 groupIndex = animGraph->FindNodeGroupIndexByName(m_name.c_str());
if (groupIndex == MCORE_INVALIDINDEX32)
const size_t groupIndex = animGraph->FindNodeGroupIndexByName(m_name.c_str());
if (groupIndex == InvalidIndex)
{
outResult = AZStd::string::format("Node group \"%s\" can not be found.", m_name.c_str());
return false;
@@ -149,8 +149,8 @@ namespace CommandSystem
}
// remove the node from all node groups
const uint32 numNodeGroups = animGraph->GetNumNodeGroups();
for (uint32 n = 0; n < numNodeGroups; ++n)
const size_t numNodeGroups = animGraph->GetNumNodeGroups();
for (size_t n = 0; n < numNodeGroups; ++n)
{
animGraph->GetNodeGroup(n)->RemoveNodeById(animGraphNode->GetId());
}
@@ -173,8 +173,8 @@ namespace CommandSystem
}
// remove the node from all node groups
const uint32 numNodeGroups = animGraph->GetNumNodeGroups();
for (uint32 n = 0; n < numNodeGroups; ++n)
const size_t numNodeGroups = animGraph->GetNumNodeGroups();
for (size_t n = 0; n < numNodeGroups; ++n)
{
animGraph->GetNodeGroup(n)->RemoveNodeById(animGraphNode->GetId());
}
@@ -404,10 +404,10 @@ namespace CommandSystem
parameters.GetValue("name", this, groupName);
// find the node group index and remove it
const uint32 groupIndex = animGraph->FindNodeGroupIndexByName(groupName.c_str());
if (groupIndex == MCORE_INVALIDINDEX32)
const size_t groupIndex = animGraph->FindNodeGroupIndexByName(groupName.c_str());
if (groupIndex == InvalidIndex)
{
outResult = AZStd::string::format("Cannot add node group to anim graph. Node group index %u is invalid.", groupIndex);
outResult = AZStd::string::format("Cannot add node group to anim graph. Node group index %zu is invalid.", groupIndex);
return false;
}
@@ -487,7 +487,7 @@ namespace CommandSystem
void ClearNodeGroups(EMotionFX::AnimGraph* animGraph, MCore::CommandGroup* commandGroup)
{
// get number of node groups
const uint32 numNodeGroups = animGraph->GetNumNodeGroups();
const size_t numNodeGroups = animGraph->GetNumNodeGroups();
if (numNodeGroups == 0)
{
return;
@@ -498,7 +498,7 @@ namespace CommandSystem
// get rid of all node groups
AZStd::string commandString;
for (uint32 i = 0; i < numNodeGroups; ++i)
for (size_t i = 0; i < numNodeGroups; ++i)
{
// get pointer to the current actor instance
EMotionFX::AnimGraphNodeGroup* nodeGroup = animGraph->GetNodeGroup(i);
@@ -170,7 +170,7 @@ namespace CommandSystem
for (size_t i = 0; i < numInstances; ++i)
{
EMotionFX::AnimGraphInstance* animGraphInstance = animGraph->GetAnimGraphInstance(i);
animGraphInstance->InsertParameterValue(static_cast<uint32>(valueParameterIndex.GetValue()));
animGraphInstance->InsertParameterValue(valueParameterIndex.GetValue());
}
AZStd::vector<EMotionFX::AnimGraphObject*> affectedObjects;
@@ -316,7 +316,7 @@ namespace CommandSystem
{
EMotionFX::AnimGraphInstance* animGraphInstance = animGraph->GetAnimGraphInstance(i);
// Remove the parameter.
animGraphInstance->RemoveParameterValue(static_cast<uint32>(valueParameterIndex.GetValue()));
animGraphInstance->RemoveParameterValue(valueParameterIndex.GetValue());
}
// Save the current dirty flag and tell the anim graph that something got changed.
@@ -521,13 +521,13 @@ namespace CommandSystem
// Update all corresponding anim graph instances.
const size_t numInstances = animGraph->GetNumAnimGraphInstances();
for (uint32 i = 0; i < numInstances; ++i)
for (size_t i = 0; i < numInstances; ++i)
{
EMotionFX::AnimGraphInstance* animGraphInstance = animGraph->GetAnimGraphInstance(i);
// reinit the modified parameters
if (mOldType != azrtti_typeid<EMotionFX::GroupParameter>())
{
animGraphInstance->ReInitParameterValue(static_cast<uint32>(valueParameterIndex.GetValue()));
animGraphInstance->ReInitParameterValue(valueParameterIndex.GetValue());
}
else
{
@@ -773,7 +773,7 @@ namespace CommandSystem
{
EMotionFX::AnimGraphInstance* animGraphInstance = animGraph->GetAnimGraphInstance(i);
// Move the parameter from original position to the new position
animGraphInstance->MoveParameterValue(static_cast<uint32>(valueIndexBeforeMove.GetValue()), static_cast<uint32>(valueIndexAfterMove.GetValue()));
animGraphInstance->MoveParameterValue(valueIndexBeforeMove.GetValue(), valueIndexAfterMove.GetValue());
}
EMotionFX::ValueParameterVector valueParametersAfterChange = animGraph->RecursivelyGetValueParameters();
@@ -853,7 +853,7 @@ namespace CommandSystem
//--------------------------------------------------------------------------------
// Construct create parameter command strings
//--------------------------------------------------------------------------------
void ConstructCreateParameterCommand(AZStd::string& outResult, EMotionFX::AnimGraph* animGraph, const EMotionFX::Parameter* parameter, uint32 insertAtIndex)
void ConstructCreateParameterCommand(AZStd::string& outResult, EMotionFX::AnimGraph* animGraph, const EMotionFX::Parameter* parameter, size_t insertAtIndex)
{
// Build the command string.
AZStd::string parameterContents;
@@ -865,9 +865,9 @@ namespace CommandSystem
parameter->GetName().c_str(),
parameterContents.c_str());
if (insertAtIndex != MCORE_INVALIDINDEX32)
if (insertAtIndex != InvalidIndex)
{
outResult += AZStd::string::format(" -index \"%i\"", insertAtIndex);
outResult += AZStd::string::format(" -index \"%zu\"", insertAtIndex);
}
}
@@ -920,11 +920,11 @@ namespace CommandSystem
AZStd::vector<AZStd::pair<EMotionFX::BlendTreeConnection*, EMotionFX::AnimGraphNode*>> outgoingConnectionsFromThisPort;
for (const EMotionFX::AnimGraphNode* parameterNode : parameterNodes)
{
const AZ::u32 sourcePortIndex = parameterNode->FindOutputPortIndex(parameterName);
const size_t sourcePortIndex = parameterNode->FindOutputPortIndex(parameterName);
parameterNode->CollectOutgoingConnections(outgoingConnectionsFromThisPort, sourcePortIndex); // outgoingConnectionsFromThisPort will be cleared inside the function.
const size_t numConnections = outgoingConnectionsFromThisPort.size();
for (uint32 i = 0; i < numConnections; ++i)
for (size_t i = 0; i < numConnections; ++i)
{
const EMotionFX::AnimGraphNode* targetNode = outgoingConnectionsFromThisPort[i].second;
const EMotionFX::BlendTreeConnection* connection = outgoingConnectionsFromThisPort[i].first;
@@ -999,7 +999,7 @@ namespace CommandSystem
// 3. Remove the actual parameters.
size_t numIterations = parameterNamesToRemove.size();
for (uint32 i = 0; i < numIterations; ++i)
for (size_t i = 0; i < numIterations; ++i)
{
commandString = AZStd::string::format("AnimGraphRemoveParameter -animGraphID %i -name \"%s\"", animGraph->GetID(), parameterNamesToRemove[i].c_str());
if (i != 0 && i != numIterations - 1)
@@ -59,8 +59,6 @@ namespace CommandSystem
struct COMMANDSYSTEM_API ParameterConnectionItem
{
uint32 mTargetNodePort;
void SetParameterNodeName(const char* name) { mParameterNodeNameID = MCore::GetStringIdPool().GenerateIdForString(name); }
void SetTargetNodeName(const char* name) { mTargetNodeNameID = MCore::GetStringIdPool().GenerateIdForString(name); }
void SetParameterName(const char* name) { mParameterNameID = MCore::GetStringIdPool().GenerateIdForString(name); }
@@ -81,6 +79,6 @@ namespace CommandSystem
COMMANDSYSTEM_API void ClearParametersCommand(EMotionFX::AnimGraph* animGraph, MCore::CommandGroup* commandGroup = nullptr);
// Construct the create parameter command string using the the given information.
COMMANDSYSTEM_API void ConstructCreateParameterCommand(AZStd::string& outResult, EMotionFX::AnimGraph* animGraph, const EMotionFX::Parameter* parameter, uint32 insertAtIndex = MCORE_INVALIDINDEX32);
COMMANDSYSTEM_API void ConstructCreateParameterCommand(AZStd::string& outResult, EMotionFX::AnimGraph* animGraph, const EMotionFX::Parameter* parameter, size_t insertAtIndex = InvalidIndex);
} // namespace CommandSystem
@@ -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)
@@ -139,13 +139,11 @@ namespace CommandSystem
{
EMotionFX::AttachmentNode* newAttachment = EMotionFX::AttachmentNode::Create(attachToActorInstance, node->GetNodeIndex(), attachment);
attachToActorInstance->AddAttachment(newAttachment);
//attachToActorInstance->AddAttachment( node->GetNodeIndex(), attachment );
}
else
{
attachToActorInstance->RemoveAttachment(attachment, true);
}
// attachToActorInstance->RemoveAttachment( attachment, false );
return true;
}
@@ -300,10 +298,10 @@ namespace CommandSystem
bool CommandAddDeformableAttachment::AddAttachment(MCore::Command* command, const MCore::CommandLine& parameters, AZStd::string& outResult, bool remove)
{
uint32 attachToActorID = parameters.GetValueAsInt("attachToID", command);
uint32 attachToActorIndex = parameters.GetValueAsInt("attachToIndex", command);
size_t attachToActorIndex = parameters.GetValueAsInt("attachToIndex", command);
// in case we only specified an attach to index, get the id from that
if (attachToActorIndex != MCORE_INVALIDINDEX32 && attachToActorID == MCORE_INVALIDINDEX32)
if (attachToActorIndex != InvalidIndex && attachToActorID == MCORE_INVALIDINDEX32)
{
if (EMotionFX::GetActorManager().GetNumActorInstances() <= attachToActorIndex)
{
@@ -315,11 +313,11 @@ namespace CommandSystem
}
uint32 attachmentID = parameters.GetValueAsInt("attachmentID", command);
uint32 attachmentIndex = parameters.GetValueAsInt("attachmentIndex", command);
size_t attachmentIndex = parameters.GetValueAsInt("attachmentIndex", command);
if (attachmentID == MCORE_INVALIDINDEX32)
{
// in case we only specified an attachment index, get the id from that
if (attachmentIndex != MCORE_INVALIDINDEX32)
if (attachmentIndex != InvalidIndex)
{
EMotionFX::ActorInstance* actorInstance = EMotionFX::GetActorManager().GetActorInstance(attachmentIndex);
attachmentID = actorInstance->GetID();
@@ -71,8 +71,8 @@ namespace CommandSystem
void MetaData::GeneratePhonemeMetaData(EMotionFX::Actor* actor, AZStd::string& outMetaDataString)
{
const AZ::u32 numLODLevels = actor->GetNumLODLevels();
for (AZ::u32 lodLevel = 0; lodLevel < numLODLevels; ++lodLevel)
const size_t numLODLevels = actor->GetNumLODLevels();
for (size_t lodLevel = 0; lodLevel < numLODLevels; ++lodLevel)
{
EMotionFX::MorphSetup* morphSetup = actor->GetMorphSetup(lodLevel);
if (!morphSetup)
@@ -80,8 +80,8 @@ namespace CommandSystem
continue;
}
const uint32 numMorphTargets = morphSetup->GetNumMorphTargets();
for (uint32 i = 0; i < numMorphTargets; ++i)
const size_t numMorphTargets = morphSetup->GetNumMorphTargets();
for (size_t i = 0; i < numMorphTargets; ++i)
{
EMotionFX::MorphTarget* morphTarget = morphSetup->GetMorphTarget(i);
if (!morphTarget)
@@ -89,7 +89,7 @@ namespace CommandSystem
continue;
}
outMetaDataString += AZStd::string::format("AdjustMorphTarget -actorID $(ACTORID) -lodLevel %i -name \"%s\" -phonemeAction \"replace\" ", lodLevel, morphTarget->GetName());
outMetaDataString += AZStd::string::format("AdjustMorphTarget -actorID $(ACTORID) -lodLevel %zu -name \"%s\" -phonemeAction \"replace\" ", lodLevel, morphTarget->GetName());
outMetaDataString += AZStd::string::format("-phonemeSets \"%s\" ", morphTarget->GetPhonemeSetString(morphTarget->GetPhonemeSets()).c_str());
outMetaDataString += AZStd::string::format("-rangeMin %f -rangeMax %f\n", morphTarget->GetRangeMin(), morphTarget->GetRangeMax());
}
@@ -101,8 +101,8 @@ namespace CommandSystem
{
AZStd::string attachmentNodeNameList;
const AZ::u32 numNodes = actor->GetNumNodes();
for (AZ::u32 i = 0; i < numNodes; ++i)
const size_t numNodes = actor->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
EMotionFX::Node* node = actor->GetSkeleton()->GetNode(i);
if (!node)
@@ -233,10 +233,9 @@ namespace CommandSystem
// Construct a new command group and fill it with all meta data commands.
MCore::CommandGroup commandGroup;
const size_t numTokens = tokens.size();
for (size_t i = 0; i < numTokens; ++i)
for (const AZStd::string& token : tokens)
{
commandGroup.AddCommandString(tokens[i].c_str());
commandGroup.AddCommandString(token);
}
// Execute the command group and apply the meta data.
@@ -200,7 +200,7 @@ namespace CommandSystem
m_oldData.clear();
// check if there is any actor instance selected and if not return false so that the command doesn't get called and doesn't get inside the action history
const uint32 numSelectedActorInstances = GetCommandManager()->GetCurrentSelection().GetNumSelectedActorInstances();
const size_t numSelectedActorInstances = GetCommandManager()->GetCurrentSelection().GetNumSelectedActorInstances();
// verify if we actually have selected an actor instance
if (numSelectedActorInstances == 0)
@@ -236,7 +236,7 @@ namespace CommandSystem
CommandParametersToPlaybackInfo(this, parameters, &playbackInfo);
// iterate through all actor instances and start playing all selected motions
for (uint32 i = 0; i < numSelectedActorInstances; ++i)
for (size_t i = 0; i < numSelectedActorInstances; ++i)
{
EMotionFX::ActorInstance* actorInstance = GetCommandManager()->GetCurrentSelection().GetActorInstance(i);
@@ -467,8 +467,8 @@ namespace CommandSystem
MCORE_UNUSED(outResult);
// iterate through the motion instances and modify them
const uint32 numSelectedMotionInstances = GetCommandManager()->GetCurrentSelection().GetNumSelectedMotionInstances();
for (uint32 i = 0; i < numSelectedMotionInstances; ++i)
const size_t numSelectedMotionInstances = GetCommandManager()->GetCurrentSelection().GetNumSelectedMotionInstances();
for (size_t i = 0; i < numSelectedMotionInstances; ++i)
{
// get the current selected motion instance and adjust it based on the parameters
EMotionFX::MotionInstance* selectedMotionInstance = GetCommandManager()->GetCurrentSelection().GetMotionInstance(i);
@@ -618,7 +618,7 @@ namespace CommandSystem
//mOldData.Clear();
// get the number of selected actor instances
const uint32 numSelectedActorInstances = GetCommandManager()->GetCurrentSelection().GetNumSelectedActorInstances();
const size_t numSelectedActorInstances = GetCommandManager()->GetCurrentSelection().GetNumSelectedActorInstances();
// check if there is any actor instance selected and if not return false so that the command doesn't get called and doesn't get inside the action history
if (numSelectedActorInstances == 0)
@@ -645,7 +645,7 @@ namespace CommandSystem
}
// iterate through all actor instances and stop all selected motion instances
for (uint32 i = 0; i < numSelectedActorInstances; ++i)
for (size_t i = 0; i < numSelectedActorInstances; ++i)
{
// get the actor instance and the corresponding motion system
EMotionFX::ActorInstance* actorInstance = GetCommandManager()->GetCurrentSelection().GetActorInstance(i);
@@ -665,8 +665,8 @@ namespace CommandSystem
}
// get the number of motion instances and iterate through them
const uint32 numMotionInstances = motionSystem->GetNumMotionInstances();
for (uint32 j = 0; j < numMotionInstances; ++j)
const size_t numMotionInstances = motionSystem->GetNumMotionInstances();
for (size_t j = 0; j < numMotionInstances; ++j)
{
EMotionFX::MotionInstance* motionInstance = motionSystem->GetMotionInstance(j);
@@ -720,8 +720,8 @@ namespace CommandSystem
//mOldData.Clear();
// iterate through all actor instances and stop all selected motion instances
const uint32 numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (uint32 i = 0; i < numActorInstances; ++i)
const size_t numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (size_t i = 0; i < numActorInstances; ++i)
{
// get the actor instance and the corresponding motion system
EMotionFX::ActorInstance* actorInstance = EMotionFX::GetActorManager().GetActorInstance(i);
@@ -741,8 +741,8 @@ namespace CommandSystem
}
// get the number of motion instances and iterate through them
const uint32 numMotionInstances = motionSystem->GetNumMotionInstances();
for (uint32 j = 0; j < numMotionInstances; ++j)
const size_t numMotionInstances = motionSystem->GetNumMotionInstances();
for (size_t j = 0; j < numMotionInstances; ++j)
{
// get the motion instance and stop it
EMotionFX::MotionInstance* motionInstance = motionSystem->GetMotionInstance(j);
@@ -974,8 +974,8 @@ namespace CommandSystem
}
// make sure the motion is not part of any motion set
const uint32 numMotionSets = EMotionFX::GetMotionManager().GetNumMotionSets();
for (uint32 i = 0; i < numMotionSets; ++i)
const size_t numMotionSets = EMotionFX::GetMotionManager().GetNumMotionSets();
for (size_t i = 0; i < numMotionSets; ++i)
{
// get the current motion set and check if the motion we want to remove is used by it
EMotionFX::MotionSet* motionSet = EMotionFX::GetMotionManager().GetMotionSet(i);
@@ -1185,13 +1185,12 @@ namespace CommandSystem
const size_t numFileNames = filenames.size();
const AZStd::string commandGroupName = AZStd::string::format("%s %zu motion%s", reload ? "Reload" : "Load", numFileNames, (numFileNames > 1) ? "s" : "");
MCore::CommandGroup commandGroup(commandGroupName, static_cast<uint32>(numFileNames * 2));
MCore::CommandGroup commandGroup(commandGroupName, numFileNames * 2);
AZStd::string command;
const EMotionFX::MotionManager& motionManager = EMotionFX::GetMotionManager();
for (size_t i = 0; i < numFileNames; ++i)
for (const AZStd::string& filename : filenames)
{
const AZStd::string& filename = filenames[i];
const EMotionFX::Motion* motion = motionManager.FindMotionByFileName(filename.c_str());
if (reload && motion)
@@ -1234,11 +1233,11 @@ namespace CommandSystem
void ClearMotions(MCore::CommandGroup* commandGroup, bool forceRemove)
{
// iterate through the motions and put them into some array
const uint32 numMotions = EMotionFX::GetMotionManager().GetNumMotions();
const size_t numMotions = EMotionFX::GetMotionManager().GetNumMotions();
AZStd::vector<EMotionFX::Motion*> motionsToRemove;
motionsToRemove.reserve(numMotions);
for (uint32 i = 0; i < numMotions; ++i)
for (size_t i = 0; i < numMotions; ++i)
{
EMotionFX::Motion* motion = EMotionFX::GetMotionManager().GetMotion(i);
@@ -1283,10 +1282,8 @@ namespace CommandSystem
// Iterate through all motions and remove them.
AZStd::string commandString;
for (uint32 i = 0; i < numMotions; ++i)
for (const EMotionFX::Motion* motion : motions)
{
EMotionFX::Motion* motion = motions[i];
if (motion->GetIsOwnedByRuntime())
{
continue;
@@ -1294,10 +1291,10 @@ namespace CommandSystem
// Is the motion part of a motion set?
bool isUsed = false;
const uint32 numMotionSets = EMotionFX::GetMotionManager().GetNumMotionSets();
for (uint32 j = 0; j < numMotionSets; ++j)
const size_t numMotionSets = EMotionFX::GetMotionManager().GetNumMotionSets();
for (size_t i = 0; i < numMotionSets; ++i)
{
EMotionFX::MotionSet* motionSet = EMotionFX::GetMotionManager().GetMotionSet(j);
EMotionFX::MotionSet* motionSet = EMotionFX::GetMotionManager().GetMotionSet(i);
EMotionFX::MotionSet::MotionEntry* motionEntry = motionSet->FindMotionEntry(motion);
if (motionEntry)
@@ -38,9 +38,9 @@ namespace CommandSystem
bool SetCommandParameters(const MCore::CommandLine& parameters);
void SetMotionID(int32 motionID) { m_motionID = motionID; }
void SetMotionID(uint32 motionID) { m_motionID = motionID; }
protected:
int32 m_motionID = 0;
uint32 m_motionID = 0;
};
// Adjust motion command.
@@ -83,7 +83,7 @@ namespace CommandSystem
public:
uint32 mOldMotionID;
AZStd::string mOldFileName;
uint32 mOldIndex;
size_t mOldIndex;
bool mOldWorkspaceDirtyFlag;
MCORE_DEFINECOMMAND_END
@@ -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;
@@ -956,7 +956,7 @@ namespace CommandSystem
}
// get the event index and check if it is in range
if (m_eventNr < 0 || m_eventNr >= eventTrack->GetNumEvents())
if (m_eventNr >= eventTrack->GetNumEvents())
{
return AZ::Failure();
}
@@ -1006,7 +1006,7 @@ namespace CommandSystem
// remove event track
void CommandRemoveEventTrack(EMotionFX::Motion* motion, uint32 trackIndex)
void CommandRemoveEventTrack(EMotionFX::Motion* motion, size_t trackIndex)
{
if (!motion)
{
@@ -1035,7 +1035,7 @@ namespace CommandSystem
// remove event track
void CommandRemoveEventTrack(uint32 trackIndex)
void CommandRemoveEventTrack(size_t trackIndex)
{
EMotionFX::Motion* motion = GetCommandManager()->GetCurrentSelection().GetSingleMotion();
CommandRemoveEventTrack(motion, trackIndex);
@@ -1043,7 +1043,7 @@ namespace CommandSystem
// rename event track
void CommandRenameEventTrack(EMotionFX::Motion* motion, uint32 trackIndex, const char* newName)
void CommandRenameEventTrack(EMotionFX::Motion* motion, size_t trackIndex, const char* newName)
{
// make sure the motion is valid
if (motion == nullptr)
@@ -1065,7 +1065,7 @@ namespace CommandSystem
// rename event track
void CommandRenameEventTrack(uint32 trackIndex, const char* newName)
void CommandRenameEventTrack(size_t trackIndex, const char* newName)
{
EMotionFX::Motion* motion = GetCommandManager()->GetCurrentSelection().GetSingleMotion();
CommandRenameEventTrack(motion, trackIndex, newName);
@@ -1073,7 +1073,7 @@ namespace CommandSystem
// enable or disable event track
void CommandEnableEventTrack(EMotionFX::Motion* motion, uint32 trackIndex, bool isEnabled)
void CommandEnableEventTrack(EMotionFX::Motion* motion, size_t trackIndex, bool isEnabled)
{
// make sure the motion is valid
if (motion == nullptr)
@@ -1098,7 +1098,7 @@ namespace CommandSystem
// enable or disable event track
void CommandEnableEventTrack(uint32 trackIndex, bool isEnabled)
void CommandEnableEventTrack(size_t trackIndex, bool isEnabled)
{
EMotionFX::Motion* motion = GetCommandManager()->GetCurrentSelection().GetSingleMotion();
CommandEnableEventTrack(motion, trackIndex, isEnabled);
@@ -1114,7 +1114,7 @@ namespace CommandSystem
// remove motion event
void CommandHelperRemoveMotionEvent(EMotionFX::Motion* motion, const char* trackName, uint32 eventNr, MCore::CommandGroup* commandGroup)
void CommandHelperRemoveMotionEvent(EMotionFX::Motion* motion, const char* trackName, size_t eventNr, MCore::CommandGroup* commandGroup)
{
// make sure the motion is valid
if (motion == nullptr)
@@ -1127,7 +1127,7 @@ namespace CommandSystem
// execute the create motion event command
AZStd::string command;
command = AZStd::string::format("RemoveMotionEvent -motionID %i -eventTrackName \"%s\" -eventNr %i", motion->GetID(), trackName, eventNr);
command = AZStd::string::format("RemoveMotionEvent -motionID %i -eventTrackName \"%s\" -eventNr %zu", motion->GetID(), trackName, eventNr);
// add the command to the command group
if (commandGroup == nullptr)
@@ -1152,7 +1152,7 @@ namespace CommandSystem
// remove motion event
void CommandHelperRemoveMotionEvent(uint32 motionID, const char* trackName, uint32 eventNr, MCore::CommandGroup* commandGroup)
void CommandHelperRemoveMotionEvent(uint32 motionID, const char* trackName, size_t eventNr, MCore::CommandGroup* commandGroup)
{
// find the motion by id
EMotionFX::Motion* motion = EMotionFX::GetMotionManager().FindMotionByID(motionID);
@@ -1165,7 +1165,7 @@ namespace CommandSystem
}
// remove motion event
void CommandHelperRemoveMotionEvent(const char* trackName, uint32 eventNr, MCore::CommandGroup* commandGroup)
void CommandHelperRemoveMotionEvent(const char* trackName, size_t eventNr, MCore::CommandGroup* commandGroup)
{
EMotionFX::Motion* motion = GetCommandManager()->GetCurrentSelection().GetSingleMotion();
if (motion == nullptr)
@@ -1178,7 +1178,7 @@ namespace CommandSystem
// remove motion event
void CommandHelperRemoveMotionEvents(uint32 motionID, const char* trackName, const MCore::Array<uint32>& eventNumbers, MCore::CommandGroup* commandGroup)
void CommandHelperRemoveMotionEvents(uint32 motionID, const char* trackName, const AZStd::vector<size_t>& eventNumbers, MCore::CommandGroup* commandGroup)
{
// find the motion by id
EMotionFX::Motion* motion = EMotionFX::GetMotionManager().FindMotionByID(motionID);
@@ -1191,11 +1191,11 @@ namespace CommandSystem
MCore::CommandGroup internalCommandGroup("Remove motion events");
// get the number of events to remove and iterate through them
const int32 numEvents = eventNumbers.GetLength();
for (int32 i = 0; i < numEvents; ++i)
const size_t numEvents = eventNumbers.size();
for (size_t i = 0; i < numEvents; ++i)
{
// remove the events from back to front
uint32 eventNr = eventNumbers[numEvents - 1 - i];
size_t eventNr = eventNumbers[numEvents - 1 - i];
// add the command to the command group
if (commandGroup == nullptr)
@@ -1221,7 +1221,7 @@ namespace CommandSystem
// remove motion event
void CommandHelperRemoveMotionEvents(const char* trackName, const MCore::Array<uint32>& eventNumbers, MCore::CommandGroup* commandGroup)
void CommandHelperRemoveMotionEvents(const char* trackName, const AZStd::vector<size_t>& eventNumbers, MCore::CommandGroup* commandGroup)
{
EMotionFX::Motion* motion = GetCommandManager()->GetCurrentSelection().GetSingleMotion();
if (motion == nullptr)
@@ -1233,7 +1233,7 @@ namespace CommandSystem
}
void CommandHelperMotionEventTrackChanged(EMotionFX::Motion* motion, uint32 eventNr, float startTime, float endTime, const char* oldTrackName, const char* newTrackName)
void CommandHelperMotionEventTrackChanged(EMotionFX::Motion* motion, size_t eventNr, float startTime, float endTime, const char* oldTrackName, const char* newTrackName)
{
// get the motion event track
EMotionFX::MotionEventTable* eventTable = motion->GetEventTable();
@@ -1256,7 +1256,7 @@ namespace CommandSystem
// get the motion event
EMotionFX::MotionEvent& motionEvent = eventTrack->GetEvent(eventNr);
commandGroup.AddCommandString(AZStd::string::format("RemoveMotionEvent -motionID %i -eventTrackName \"%s\" -eventNr %i", motion->GetID(), oldTrackName, eventNr));
commandGroup.AddCommandString(AZStd::string::format("RemoveMotionEvent -motionID %i -eventTrackName \"%s\" -eventNr %zu", motion->GetID(), oldTrackName, eventNr));
CommandHelperAddMotionEvent(motion, newTrackName, startTime, endTime, motionEvent.GetEventDatas(), &commandGroup);
// execute the command group
@@ -1267,7 +1267,7 @@ namespace CommandSystem
}
void CommandHelperMotionEventTrackChanged(uint32 eventNr, float startTime, float endTime, const char* oldTrackName, const char* newTrackName)
void CommandHelperMotionEventTrackChanged(size_t eventNr, float startTime, float endTime, const char* oldTrackName, const char* newTrackName)
{
EMotionFX::Motion* motion = GetCommandManager()->GetCurrentSelection().GetSingleMotion();
CommandHelperMotionEventTrackChanged(motion, eventNr, startTime, endTime, oldTrackName, newTrackName);
@@ -55,7 +55,7 @@ namespace CommandSystem
private:
AZStd::string m_eventTrackName;
AZStd::optional<uint32> m_eventTrackIndex;
AZStd::optional<size_t> m_eventTrackIndex;
AZStd::optional<bool> m_isEnabled;
};
@@ -215,13 +215,13 @@ namespace CommandSystem
// Command helpers
//////////////////////////////////////////////////////////////////////////////////////////////////////////
void COMMANDSYSTEM_API CommandAddEventTrack();
void COMMANDSYSTEM_API CommandRemoveEventTrack(uint32 trackIndex);
void COMMANDSYSTEM_API CommandRemoveEventTrack(EMotionFX::Motion* motion, uint32 trackIndex);
void COMMANDSYSTEM_API CommandRenameEventTrack(uint32 trackIndex, const char* newName);
void COMMANDSYSTEM_API CommandEnableEventTrack(uint32 trackIndex, bool isEnabled);
void COMMANDSYSTEM_API CommandRemoveEventTrack(size_t trackIndex);
void COMMANDSYSTEM_API CommandRemoveEventTrack(EMotionFX::Motion* motion, size_t trackIndex);
void COMMANDSYSTEM_API CommandRenameEventTrack(size_t trackIndex, const char* newName);
void COMMANDSYSTEM_API CommandEnableEventTrack(size_t trackIndex, bool isEnabled);
void COMMANDSYSTEM_API CommandHelperAddMotionEvent(const char* trackName, float startTime, float endTime, const EMotionFX::EventDataSet& eventDatas = EMotionFX::EventDataSet {}, MCore::CommandGroup* commandGroup = nullptr);
void COMMANDSYSTEM_API CommandHelperRemoveMotionEvent(const char* trackName, uint32 eventNr, MCore::CommandGroup* commandGroup = nullptr);
void COMMANDSYSTEM_API CommandHelperRemoveMotionEvent(uint32 motionID, const char* trackName, uint32 eventNr, MCore::CommandGroup* commandGroup = nullptr);
void COMMANDSYSTEM_API CommandHelperRemoveMotionEvents(const char* trackName, const MCore::Array<uint32>& eventNumbers, MCore::CommandGroup* commandGroup = nullptr);
void COMMANDSYSTEM_API CommandHelperMotionEventTrackChanged(uint32 eventNr, float startTime, float endTime, const char* oldTrackName, const char* newTrackName);
void COMMANDSYSTEM_API CommandHelperRemoveMotionEvent(const char* trackName, size_t eventNr, MCore::CommandGroup* commandGroup = nullptr);
void COMMANDSYSTEM_API CommandHelperRemoveMotionEvent(uint32 motionID, const char* trackName, size_t eventNr, MCore::CommandGroup* commandGroup = nullptr);
void COMMANDSYSTEM_API CommandHelperRemoveMotionEvents(const char* trackName, const AZStd::vector<size_t>& eventNumbers, MCore::CommandGroup* commandGroup = nullptr);
void COMMANDSYSTEM_API CommandHelperMotionEventTrackChanged(size_t eventNr, float startTime, float endTime, const char* oldTrackName, const char* newTrackName);
} // namespace CommandSystem
@@ -159,8 +159,8 @@ namespace CommandSystem
AZStd::to_string(outResult, motionSet->GetID());
// Recursively update attributes of all nodes.
const uint32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (uint32 i = 0; i < numAnimGraphs; ++i)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t i = 0; i < numAnimGraphs; ++i)
{
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
@@ -266,8 +266,8 @@ namespace CommandSystem
EMotionFX::GetMotionManager().RemoveMotionSet(motionSet, true);
// Recursively update attributes of all nodes.
const uint32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (uint32 i = 0; i < numAnimGraphs; ++i)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t i = 0; i < numAnimGraphs; ++i)
{
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
@@ -471,8 +471,8 @@ namespace CommandSystem
motionSet->SetDirtyFlag(true);
// Recursively update attributes of all nodes.
const uint32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (uint32 i = 0; i < numAnimGraphs; ++i)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t i = 0; i < numAnimGraphs; ++i)
{
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
@@ -554,18 +554,15 @@ namespace CommandSystem
m_oldMotionFilenamesAndIds.clear();
// Get the motion ids from the parameter.
const AZStd::string motionIdsString = parameters.GetValue("motionIds", this);
const AZStd::string& motionIdsString = parameters.GetValue("motionIds", this);
AZStd::vector<AZStd::string> tokens;
AzFramework::StringFunc::Tokenize(motionIdsString.c_str(), tokens, ";", false, true);
// Iterate over all motion ids and remove the corresponding motion entries.
AZStd::string failedToRemoveMotionIdsString;
const size_t tokenCount = tokens.size();
for (size_t i = 0; i < tokenCount; ++i)
for (const AZStd::string& motionId : tokens)
{
const AZStd::string& motionId = tokens[i];
// Get the motion entry by id string.
// Get the motion entry by id string.
EMotionFX::MotionSet::MotionEntry* motionEntry = motionSet->FindMotionEntryById(motionId);
if (!motionEntry)
{
@@ -594,8 +591,8 @@ namespace CommandSystem
motionSet->SetDirtyFlag(true);
// Recursively update attributes of all nodes.
const uint32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (uint32 i = 0; i < numAnimGraphs; ++i)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t i = 0; i < numAnimGraphs; ++i)
{
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
@@ -673,8 +670,8 @@ namespace CommandSystem
void CommandMotionSetAdjustMotion::UpdateMotionNodes(const char* oldID, const char* newID)
{
// iterate through the anim graphs and update all motion nodes
const uint32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (uint32 i = 0; i < numAnimGraphs; ++i)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t i = 0; i < numAnimGraphs; ++i)
{
// get the current anim graph
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
@@ -790,8 +787,8 @@ namespace CommandSystem
}
// Recursively update attributes of all nodes.
const uint32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (uint32 i = 0; i < numAnimGraphs; ++i)
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
for (size_t i = 0; i < numAnimGraphs; ++i)
{
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
@@ -1058,8 +1055,8 @@ namespace CommandSystem
}
// Iterate through the child motion sets and recursively remove them.
const uint32 numChildSets = motionSet->GetNumChildSets();
for (uint32 i = 0; i < numChildSets; ++i)
const size_t numChildSets = motionSet->GetNumChildSets();
for (size_t i = 0; i < numChildSets; ++i)
{
EMotionFX::MotionSet* childSet = motionSet->GetChildSet(i);
RecursivelyRemoveMotionSets(childSet, commandGroup, toBeRemoved);
@@ -1077,9 +1074,9 @@ namespace CommandSystem
MCore::CommandGroup internalCommandGroup("Clear motion sets");
// Iterate through all root motion sets and remove them.
const uint32 numMotionSets = EMotionFX::GetMotionManager().GetNumMotionSets();
const size_t numMotionSets = EMotionFX::GetMotionManager().GetNumMotionSets();
AZStd::set<AZ::u32> toBeRemoved;
for (uint32 i = 0; i < numMotionSets; ++i)
for (size_t i = 0; i < numMotionSets; ++i)
{
// Is the given motion set a root one? Only process root motion sets in the loop and remove all others recursively.
EMotionFX::MotionSet* motionSet = EMotionFX::GetMotionManager().GetMotionSet(i);
@@ -1139,10 +1136,10 @@ namespace CommandSystem
// Iterate over all filenames and load the motion sets.
AZStd::string commandString;
AZStd::set<AZ::u32> toBeRemoved;
for (size_t i = 0; i < numFilenames; ++i)
for (const AZStd::string& filename : filenames)
{
// In case we want to reload the same motion set remove the old version first.
EMotionFX::MotionSet* motionSet = EMotionFX::GetMotionManager().FindMotionSetByFileName(filenames[i].c_str());
EMotionFX::MotionSet* motionSet = EMotionFX::GetMotionManager().FindMotionSetByFileName(filename.c_str());
if (reload && !clearUpfront && motionSet)
{
@@ -1150,15 +1147,15 @@ namespace CommandSystem
}
// Construct the load motion set command and add it to the group.
commandString = AZStd::string::format("LoadMotionSet -filename \"%s\"", filenames[i].c_str());
commandString = AZStd::string::format("LoadMotionSet -filename \"%s\"", filename.c_str());
commandGroup.AddCommandString(commandString);
// iterate over each actor instance and re-active the motion set
if (motionSet)
{
int32 commandIndex = 1;
const uint32 numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (uint32 j = 0; j < numActorInstances; ++j)
size_t commandIndex = 1;
const size_t numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (size_t j = 0; j < numActorInstances; ++j)
{
EMotionFX::ActorInstance* actorInstance = EMotionFX::GetActorManager().GetActorInstance(j);
if (!actorInstance)
@@ -1174,7 +1171,7 @@ namespace CommandSystem
EMotionFX::MotionSet* currentActiveMotionSet = animGraphInstance->GetMotionSet();
if (currentActiveMotionSet == motionSet)
{
commandString = AZStd::string::format("ActivateAnimGraph -actorInstanceID %d -animGraphID %d -motionSetID %%LASTRESULT%d%%",
commandString = AZStd::string::format("ActivateAnimGraph -actorInstanceID %d -animGraphID %d -motionSetID %%LASTRESULT%zu%%",
actorInstance->GetID(),
animGraphInstance->GetAnimGraph()->GetID(),
commandIndex);
@@ -33,14 +33,14 @@ namespace CommandSystem
: MCore::Command(s_toggleLockSelectionCmdName, orgCommand)
{ }
void SelectActorInstancesUsingCommands(const MCore::Array<EMotionFX::ActorInstance*>& selectedActorInstances)
void SelectActorInstancesUsingCommands(const AZStd::vector<EMotionFX::ActorInstance*>& selectedActorInstances)
{
SelectionList& selection = GetCommandManager()->GetCurrentSelection();
const uint32 numSelectedActorInstances = selectedActorInstances.GetLength();
const size_t numSelectedActorInstances = selectedActorInstances.size();
// check if the current selection is equal to the desired actor instances selection list
bool nothingChanged = true;
for (uint32 i = 0; i < numSelectedActorInstances; ++i)
for (size_t i = 0; i < numSelectedActorInstances; ++i)
{
EMotionFX::ActorInstance* actorInstance = selectedActorInstances[i];
if (selection.CheckIfHasActorInstance(actorInstance) == false)
@@ -49,10 +49,10 @@ namespace CommandSystem
break;
}
}
for (uint32 i = 0; i < selection.GetNumSelectedActorInstances(); ++i)
for (size_t i = 0; i < selection.GetNumSelectedActorInstances(); ++i)
{
EMotionFX::ActorInstance* actorInstance = selection.GetActorInstance(i);
if (selectedActorInstances.Find(actorInstance) == MCORE_INVALIDINDEX32)
if (AZStd::find(begin(selectedActorInstances), end(selectedActorInstances), actorInstance) == end(selectedActorInstances))
{
nothingChanged = false;
break;
@@ -70,7 +70,7 @@ namespace CommandSystem
// add the newly selected actor instances
AZStd::string commandString;
for (uint32 a = 0; a < numSelectedActorInstances; ++a)
for (size_t a = 0; a < numSelectedActorInstances; ++a)
{
EMotionFX::ActorInstance* actorInstance = selectedActorInstances[a];
commandString = AZStd::string::format("Select -actorInstanceID %i -actorID %i", actorInstance->GetID(), actorInstance->GetActor()->GetID());
@@ -166,10 +166,10 @@ namespace CommandSystem
// return false;
SelectionList& selection = GetCommandManager()->GetCurrentSelection();
const uint32 numActors = EMotionFX::GetActorManager().GetNumActors();
const uint32 numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
const uint32 numMotions = EMotionFX::GetMotionManager().GetNumMotions();
const uint32 numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
const size_t numActors = EMotionFX::GetActorManager().GetNumActors();
const size_t numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
const size_t numMotions = EMotionFX::GetMotionManager().GetNumMotions();
const size_t numAnimGraphs = EMotionFX::GetAnimGraphManager().GetNumAnimGraphs();
AZStd::string valueString;
@@ -180,7 +180,7 @@ namespace CommandSystem
if (AzFramework::StringFunc::Equal(valueString.c_str(), "SELECT_ALL", false /* no case */))
{
// iterate through all available actors and add them to the selection
for (uint32 i = 0; i < numActors; ++i)
for (size_t i = 0; i < numActors; ++i)
{
EMotionFX::Actor* actor = EMotionFX::GetActorManager().GetActor(i);
@@ -240,7 +240,7 @@ namespace CommandSystem
}
// iterate through all available actors and add them to the selection
for (uint32 i = 0; i < numActors; ++i)
for (size_t i = 0; i < numActors; ++i)
{
EMotionFX::Actor* actor = EMotionFX::GetActorManager().GetActor(i);
@@ -271,7 +271,7 @@ namespace CommandSystem
if (AzFramework::StringFunc::Equal(valueString.c_str(), "SELECT_ALL", false /* no case */))
{
// iterate through all available actor instances and add them to the selection
for (uint32 i = 0; i < numActorInstances; ++i)
for (size_t i = 0; i < numActorInstances; ++i)
{
EMotionFX::ActorInstance* actorInstance = EMotionFX::GetActorManager().GetActorInstance(i);
@@ -330,7 +330,7 @@ namespace CommandSystem
}
// iterate through all available motions and add them to the selection
for (uint32 i = 0; i < numMotions; ++i)
for (size_t i = 0; i < numMotions; ++i)
{
// get the current motion
EMotionFX::Motion* motion = EMotionFX::GetMotionManager().GetMotion(i);
@@ -362,7 +362,7 @@ namespace CommandSystem
if (AzFramework::StringFunc::Equal(valueString.c_str(), "SELECT_ALL", false /* no case */))
{
// iterate through all available motions and add them to the selection
for (uint32 i = 0; i < numMotions; ++i)
for (size_t i = 0; i < numMotions; ++i)
{
// get the current motion
EMotionFX::Motion* motion = EMotionFX::GetMotionManager().GetMotion(i);
@@ -385,7 +385,7 @@ namespace CommandSystem
else
{
// get the motion index from the string and check if it is valid
const uint32 motionIndex = parameters.GetValueAsInt("motionIndex", command);
const size_t motionIndex = parameters.GetValueAsInt("motionIndex", command);
if (motionIndex >= numMotions)
{
if (numMotions == 0)
@@ -394,7 +394,7 @@ namespace CommandSystem
}
else
{
outResult = AZStd::string::format("Motion index '%i' is not valid. Valid range is [0, %i].", motionIndex, numMotions - 1);
outResult = AZStd::string::format("Motion index '%zu' is not valid. Valid range is [0, %zu].", motionIndex, numMotions - 1);
}
return false;
@@ -427,7 +427,7 @@ namespace CommandSystem
if (AzFramework::StringFunc::Equal(valueString.c_str(), "SELECT_ALL", false /* no case */))
{
// iterate through all available motions and add them to the selection
for (uint32 i = 0; i < numAnimGraphs; ++i)
for (size_t i = 0; i < numAnimGraphs; ++i)
{
// get the current anim graph
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
@@ -450,7 +450,7 @@ namespace CommandSystem
else
{
// get the anim graph index from the string and check if it is valid
const uint32 animGraphIndex = parameters.GetValueAsInt("animGraphIndex", command);
const size_t animGraphIndex = parameters.GetValueAsInt("animGraphIndex", command);
if (animGraphIndex >= numAnimGraphs)
{
if (numAnimGraphs == 0)
@@ -459,7 +459,7 @@ namespace CommandSystem
}
else
{
outResult = AZStd::string::format("Anim graph index '%i' is not valid. Valid range is [0, %i].", animGraphIndex, numAnimGraphs - 1);
outResult = AZStd::string::format("Anim graph index '%zu' is not valid. Valid range is [0, %zu].", animGraphIndex, numAnimGraphs - 1);
}
return false;
@@ -492,7 +492,7 @@ namespace CommandSystem
if (AzFramework::StringFunc::Equal(valueString.c_str(), "SELECT_ALL", false /* no case */))
{
// iterate through all available motions and add them to the selection
for (uint32 i = 0; i < numAnimGraphs; ++i)
for (size_t i = 0; i < numAnimGraphs; ++i)
{
// get the current anim graph
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().GetAnimGraph(i);
@@ -44,7 +44,7 @@ public:
MCORE_DEFINECOMMAND_1_END
// helper functions
void COMMANDSYSTEM_API SelectActorInstancesUsingCommands(const MCore::Array<EMotionFX::ActorInstance*>& selectedActorInstances);
void COMMANDSYSTEM_API SelectActorInstancesUsingCommands(const AZStd::vector<EMotionFX::ActorInstance*>& selectedActorInstances);
bool COMMANDSYSTEM_API CheckIfHasMotionSelectionParameter(const MCore::CommandLine& parameters);
bool COMMANDSYSTEM_API CheckIfHasAnimGraphSelectionParameter(const MCore::CommandLine& parameters);
bool COMMANDSYSTEM_API CheckIfHasActorSelectionParameter(const MCore::CommandLine& parameters, bool ignoreInstanceParameters = false);
@@ -25,14 +25,14 @@ namespace CommandSystem
EMotionFX::ActorNotificationBus::Handler::BusDisconnect();
}
uint32 SelectionList::GetNumTotalItems() const
size_t SelectionList::GetNumTotalItems() const
{
return static_cast<uint32>(mSelectedNodes.size() +
return mSelectedNodes.size() +
mSelectedActors.size() +
mSelectedActorInstances.size() +
mSelectedMotions.size() +
mSelectedMotionInstances.size() +
mSelectedAnimGraphs.size());
mSelectedAnimGraphs.size();
}
bool SelectionList::GetIsEmpty() const
@@ -113,48 +113,46 @@ namespace CommandSystem
// add a complete selection list to this one
void SelectionList::Add(SelectionList& selection)
{
uint32 i;
// get the number of selected objects
const uint32 numSelectedNodes = selection.GetNumSelectedNodes();
const uint32 numSelectedActors = selection.GetNumSelectedActors();
const uint32 numSelectedActorInstances = selection.GetNumSelectedActorInstances();
const uint32 numSelectedMotions = selection.GetNumSelectedMotions();
const uint32 numSelectedMotionInstances = selection.GetNumSelectedMotionInstances();
const uint32 numSelectedAnimGraphs = selection.GetNumSelectedAnimGraphs();
const size_t numSelectedNodes = selection.GetNumSelectedNodes();
const size_t numSelectedActors = selection.GetNumSelectedActors();
const size_t numSelectedActorInstances = selection.GetNumSelectedActorInstances();
const size_t numSelectedMotions = selection.GetNumSelectedMotions();
const size_t numSelectedMotionInstances = selection.GetNumSelectedMotionInstances();
const size_t numSelectedAnimGraphs = selection.GetNumSelectedAnimGraphs();
// iterate through all nodes and select them
for (i = 0; i < numSelectedNodes; ++i)
for (size_t i = 0; i < numSelectedNodes; ++i)
{
AddNode(selection.GetNode(i));
}
// iterate through all actors and select them
for (i = 0; i < numSelectedActors; ++i)
for (size_t i = 0; i < numSelectedActors; ++i)
{
AddActor(selection.GetActor(i));
}
// iterate through all actor instances and select them
for (i = 0; i < numSelectedActorInstances; ++i)
for (size_t i = 0; i < numSelectedActorInstances; ++i)
{
AddActorInstance(selection.GetActorInstance(i));
}
// iterate through all motions and select them
for (i = 0; i < numSelectedMotions; ++i)
for (size_t i = 0; i < numSelectedMotions; ++i)
{
AddMotion(selection.GetMotion(i));
}
// iterate through all motion instances and select them
for (i = 0; i < numSelectedMotionInstances; ++i)
for (size_t i = 0; i < numSelectedMotionInstances; ++i)
{
AddMotionInstance(selection.GetMotionInstance(i));
}
// iterate through all anim graphs and select them
for (i = 0; i < numSelectedAnimGraphs; ++i)
for (size_t i = 0; i < numSelectedAnimGraphs; ++i)
{
AddAnimGraph(selection.GetAnimGraph(i));
}
@@ -164,53 +162,46 @@ namespace CommandSystem
// log the current selection
void SelectionList::Log()
{
uint32 i;
// get the number of selected objects
const uint32 numSelectedNodes = GetNumSelectedNodes();
const uint32 numSelectedActorInstances = GetNumSelectedActorInstances();
const uint32 numSelectedActors = GetNumSelectedActors();
const uint32 numSelectedMotions = GetNumSelectedMotions();
const uint32 numSelectedMotionInstances = GetNumSelectedMotionInstances();
const uint32 numSelectedAnimGraphs = GetNumSelectedAnimGraphs();
const size_t numSelectedNodes = GetNumSelectedNodes();
const size_t numSelectedActorInstances = GetNumSelectedActorInstances();
const size_t numSelectedActors = GetNumSelectedActors();
const size_t numSelectedMotions = GetNumSelectedMotions();
const size_t numSelectedAnimGraphs = GetNumSelectedAnimGraphs();
MCore::LogInfo("SelectionList:");
// iterate through all nodes and select them
MCore::LogInfo(" - Nodes (%i)", numSelectedNodes);
for (i = 0; i < numSelectedNodes; ++i)
for (size_t i = 0; i < numSelectedNodes; ++i)
{
MCore::LogInfo(" + Node #%.3d: name='%s'", i, GetNode(i)->GetName());
}
// iterate through all actors and select them
MCore::LogInfo(" - Actors (%i)", numSelectedActors);
for (i = 0; i < numSelectedActors; ++i)
for (size_t i = 0; i < numSelectedActors; ++i)
{
MCore::LogInfo(" + Actor #%.3d: name='%s'", i, GetActor(i)->GetName());
}
// iterate through all actor instances and select them
MCore::LogInfo(" - Actor instances (%i)", numSelectedActorInstances);
for (i = 0; i < numSelectedActorInstances; ++i)
for (size_t i = 0; i < numSelectedActorInstances; ++i)
{
MCore::LogInfo(" + Actor instance #%.3d: name='%s'", i, GetActorInstance(i)->GetActor()->GetName());
}
// iterate through all motions and select them
MCore::LogInfo(" - Motions (%i)", numSelectedMotions);
for (i = 0; i < numSelectedMotions; ++i)
for (size_t i = 0; i < numSelectedMotions; ++i)
{
MCore::LogInfo(" + Motion #%.3d: name='%s'", i, GetMotion(i)->GetName());
}
// iterate through all motion instances and select them
MCore::LogInfo(" - Motion instances (%i)", numSelectedMotionInstances);
//for (i=0; i<numSelectedMotionInstances; ++i)
// iterate through all motions and select them
MCore::LogInfo(" - AnimGraphs (%i)", numSelectedAnimGraphs);
for (i = 0; i < numSelectedAnimGraphs; ++i)
for (size_t i = 0; i < numSelectedAnimGraphs; ++i)
{
MCore::LogInfo(" + AnimGraph #%.3d: %s", i, GetAnimGraph(i)->GetFileName());
}
@@ -367,8 +358,8 @@ namespace CommandSystem
void SelectionList::OnActorDestroyed(EMotionFX::Actor* actor)
{
const EMotionFX::Skeleton* skeleton = actor->GetSkeleton();
const AZ::u32 numJoints = skeleton->GetNumNodes();
for (AZ::u32 i = 0; i < numJoints; ++i)
const size_t numJoints = skeleton->GetNumNodes();
for (size_t i = 0; i < numJoints; ++i)
{
EMotionFX::Node* joint = skeleton->GetNode(i);
RemoveNode(joint);
@@ -45,42 +45,42 @@ namespace CommandSystem
* Get the number of selected nodes.
* @return The number of selected nodes.
*/
MCORE_INLINE uint32 GetNumSelectedNodes() const { return static_cast<uint32>(mSelectedNodes.size()); }
MCORE_INLINE size_t GetNumSelectedNodes() const { return mSelectedNodes.size(); }
/**
* Get the number of selected actors
*/
MCORE_INLINE uint32 GetNumSelectedActors() const { return static_cast<uint32>(mSelectedActors.size()); }
MCORE_INLINE size_t GetNumSelectedActors() const { return mSelectedActors.size(); }
/**
* Get the number of selected actor instances.
* @return The number of selected actor instances.
*/
MCORE_INLINE uint32 GetNumSelectedActorInstances() const { return static_cast<uint32>(mSelectedActorInstances.size()); }
MCORE_INLINE size_t GetNumSelectedActorInstances() const { return mSelectedActorInstances.size(); }
/**
* Get the number of selected motion instances.
* @return The number of selected motion instances.
*/
MCORE_INLINE uint32 GetNumSelectedMotionInstances() const { return static_cast<uint32>(mSelectedMotionInstances.size()); }
MCORE_INLINE size_t GetNumSelectedMotionInstances() const { return mSelectedMotionInstances.size(); }
/**
* Get the number of selected motions.
* @return The number of selected motions.
*/
MCORE_INLINE uint32 GetNumSelectedMotions() const { return static_cast<uint32>(mSelectedMotions.size()); }
MCORE_INLINE size_t GetNumSelectedMotions() const { return mSelectedMotions.size(); }
/**
* Get the number of selected anim graphs.
* @return The number of selected anim graphs.
*/
MCORE_INLINE uint32 GetNumSelectedAnimGraphs() const { return static_cast<uint32>(mSelectedAnimGraphs.size()); }
MCORE_INLINE size_t GetNumSelectedAnimGraphs() const { return mSelectedAnimGraphs.size(); }
/**
* Get the total number of selected objects.
* @return The number of selected nodes, actors and motions.
*/
MCORE_INLINE uint32 GetNumTotalItems() const;
MCORE_INLINE size_t GetNumTotalItems() const;
/**
* Check whether or not the selection list contains any objects.
@@ -139,7 +139,7 @@ namespace CommandSystem
* @param index The index of the node to get from the selection list.
* @return A pointer to the given node from the selection list.
*/
MCORE_INLINE EMotionFX::Node* GetNode(uint32 index) const { return mSelectedNodes[index]; }
MCORE_INLINE EMotionFX::Node* GetNode(size_t index) const { return mSelectedNodes[index]; }
/**
* Get the first node from the selection list.
@@ -159,7 +159,7 @@ namespace CommandSystem
* @param index The index of the actor to get from the selection list.
* @return A pointer to the given actor from the selection list.
*/
MCORE_INLINE EMotionFX::Actor* GetActor(uint32 index) const { return mSelectedActors[index]; }
MCORE_INLINE EMotionFX::Actor* GetActor(size_t index) const { return mSelectedActors[index]; }
/**
* Get the first actor from the selection list.
@@ -179,7 +179,7 @@ namespace CommandSystem
* @param index The index of the actor instance to get from the selection list.
* @return A pointer to the given actor instance from the selection list.
*/
MCORE_INLINE EMotionFX::ActorInstance* GetActorInstance(uint32 index) const { return mSelectedActorInstances[index]; }
MCORE_INLINE EMotionFX::ActorInstance* GetActorInstance(size_t index) const { return mSelectedActorInstances[index]; }
/**
* Get the first actor instance from the selection list.
@@ -199,7 +199,7 @@ namespace CommandSystem
* @param index The index of the anim graph to get from the selection list.
* @return A pointer to the given anim graph from the selection list.
*/
MCORE_INLINE EMotionFX::AnimGraph* GetAnimGraph(uint32 index) const { return mSelectedAnimGraphs[index]; }
MCORE_INLINE EMotionFX::AnimGraph* GetAnimGraph(size_t index) const { return mSelectedAnimGraphs[index]; }
/**
* Get the first anim graph from the selection list.
@@ -231,7 +231,7 @@ namespace CommandSystem
* @param index The index of the motion to get from the selection list.
* @return A pointer to the given motion from the selection list.
*/
MCORE_INLINE EMotionFX::Motion* GetMotion(uint32 index) const { return mSelectedMotions[index]; }
MCORE_INLINE EMotionFX::Motion* GetMotion(size_t index) const { return mSelectedMotions[index]; }
/**
* Get the first motion from the selection list.
@@ -257,7 +257,7 @@ namespace CommandSystem
* @param index The index of the motion instance to get from the selection list.
* @return A pointer to the given motion instance from the selection list.
*/
MCORE_INLINE EMotionFX::MotionInstance* GetMotionInstance(uint32 index) const { return mSelectedMotionInstances[index]; }
MCORE_INLINE EMotionFX::MotionInstance* GetMotionInstance(size_t index) const { return mSelectedMotionInstances[index]; }
/**
* Get the first motion instance from the selection list.
@@ -276,37 +276,37 @@ namespace CommandSystem
* Remove the given node from the selection list.
* @param index The index of the node to be removed from the selection list.
*/
MCORE_INLINE void RemoveNode(uint32 index) { mSelectedNodes.erase(mSelectedNodes.begin() + index); }
MCORE_INLINE void RemoveNode(size_t index) { mSelectedNodes.erase(mSelectedNodes.begin() + index); }
/**
* Remove the given actor instance from the selection list.
* @param index The index of the actor instance to be removed from the selection list.
*/
MCORE_INLINE void RemoveActor(uint32 index) { mSelectedActors.erase(mSelectedActors.begin() + index); }
MCORE_INLINE void RemoveActor(size_t index) { mSelectedActors.erase(mSelectedActors.begin() + index); }
/**
* Remove the given actor instance from the selection list.
* @param index The index of the actor instance to be removed from the selection list.
*/
MCORE_INLINE void RemoveActorInstance(uint32 index) { mSelectedActorInstances.erase(mSelectedActorInstances.begin() + index); }
MCORE_INLINE void RemoveActorInstance(size_t index) { mSelectedActorInstances.erase(mSelectedActorInstances.begin() + index); }
/**
* Remove the given motion from the selection list.
* @param index The index of the motion to be removed from the selection list.
*/
MCORE_INLINE void RemoveMotion(uint32 index) { mSelectedMotions.erase(mSelectedMotions.begin() + index); }
MCORE_INLINE void RemoveMotion(size_t index) { mSelectedMotions.erase(mSelectedMotions.begin() + index); }
/**
* Remove the given motion instance from the selection list.
* @param index The index of the motion instance to be removed from the selection list.
*/
MCORE_INLINE void RemoveMotionInstance(uint32 index) { mSelectedMotionInstances.erase(mSelectedMotionInstances.begin() + index); }
MCORE_INLINE void RemoveMotionInstance(size_t index) { mSelectedMotionInstances.erase(mSelectedMotionInstances.begin() + index); }
/**
* Remove the given anim graph from the selection list.
* @param index The index of the anim graph to remove from the selection list.
*/
MCORE_INLINE void RemoveAnimGraph(uint32 index) { mSelectedAnimGraphs.erase(mSelectedAnimGraphs.begin() + index); }
MCORE_INLINE void RemoveAnimGraph(size_t index) { mSelectedAnimGraphs.erase(mSelectedAnimGraphs.begin() + index); }
/**
* Remove the given node from the selection list.
@@ -34,20 +34,20 @@ namespace EMotionFX
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CommandSimulatedObjectHelpers
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CommandSimulatedObjectHelpers::JointIndicesToString(const AZStd::vector<AZ::u32>& jointIndices, AZStd::string& outJointIndicesString)
void CommandSimulatedObjectHelpers::JointIndicesToString(const AZStd::vector<size_t>& jointIndices, AZStd::string& outJointIndicesString)
{
outJointIndicesString.clear();
for (AZ::u32 jointIndex : jointIndices)
for (size_t jointIndex : jointIndices)
{
if (!outJointIndicesString.empty())
{
outJointIndicesString += ';';
}
outJointIndicesString += AZStd::string::format("%d", jointIndex);
outJointIndicesString += AZStd::string::format("%zu", jointIndex);
}
}
void CommandSimulatedObjectHelpers::StringToJointIndices(const AZStd::string& jointIndicesString, AZStd::vector<AZ::u32>& outJointIndices)
void CommandSimulatedObjectHelpers::StringToJointIndices(const AZStd::string& jointIndicesString, AZStd::vector<size_t>& outJointIndices)
{
outJointIndices.clear();
AZStd::vector<AZStd::string> jointIndicesStrings;
@@ -86,7 +86,7 @@ namespace EMotionFX
return CommandSystem::GetCommandManager()->ExecuteCommandOrAddToGroup(command, commandGroup, executeInsideCommand);
}
bool CommandSimulatedObjectHelpers::AddSimulatedJoints(AZ::u32 actorId, const AZStd::vector<AZ::u32>& jointIndices, size_t objectIndex, bool addChildren,
bool CommandSimulatedObjectHelpers::AddSimulatedJoints(AZ::u32 actorId, const AZStd::vector<size_t>& jointIndices, size_t objectIndex, bool addChildren,
MCore::CommandGroup* commandGroup, bool executeInsideCommand)
{
AZStd::string jointIndicesStr;
@@ -102,7 +102,7 @@ namespace EMotionFX
return CommandSystem::GetCommandManager()->ExecuteCommandOrAddToGroup(command, commandGroup, executeInsideCommand);
}
bool CommandSimulatedObjectHelpers::RemoveSimulatedJoints(AZ::u32 actorId, const AZStd::vector<AZ::u32>& jointIndices, size_t objectIndex, bool removeChildren,
bool CommandSimulatedObjectHelpers::RemoveSimulatedJoints(AZ::u32 actorId, const AZStd::vector<size_t>& jointIndices, size_t objectIndex, bool removeChildren,
MCore::CommandGroup* commandGroup, bool executeInsideCommand)
{
AZStd::string jointIndicesStr;
@@ -737,7 +737,7 @@ namespace EMotionFX
}
else
{
for (AZ::u32 jointIndex: m_jointIndices)
for (size_t jointIndex: m_jointIndices)
{
object->AddSimulatedJointAndChildren(jointIndex);
}
@@ -878,7 +878,7 @@ namespace EMotionFX
// and having to deal with merging two object. Since we are rebuilding the simulated object model when removing joints anyway, it's more convenient to serialize the whole object.
m_oldContents = MCore::ReflectionSerializer::Serialize(object).GetValue();
for (AZ::u32 jointIndex : m_jointIndices)
for (size_t jointIndex : m_jointIndices)
{
if (!object->FindSimulatedJointBySkeletonJointIndex(jointIndex))
{
@@ -1235,8 +1235,8 @@ namespace EMotionFX
bool CommandAdjustSimulatedJoint::SetCommandParameters(const MCore::CommandLine& parameters)
{
ParameterMixinActorId::SetCommandParameters(parameters);
m_objectIndex = static_cast<size_t>(parameters.GetValueAsInt(s_objectIndexParameterName, this));
m_jointIndex = static_cast<AZ::u32>(parameters.GetValueAsInt(s_jointIndexParameterName, this));
m_objectIndex = parameters.GetValueAsInt(s_objectIndexParameterName, this);
m_jointIndex = parameters.GetValueAsInt(s_jointIndexParameterName, this);
if (parameters.CheckIfHasParameter(s_coneAngleLimitParameterName))
{
@@ -16,6 +16,7 @@
#include <EMotionFX/Source/PhysicsSetup.h>
#include <EMotionFX/CommandSystem/Source/ParameterMixins.h>
#include <EMotionFX/Source/SimulatedObjectSetup.h>
#include <EMotionFX/Source/EMotionFXConfig.h>
namespace AZ
@@ -34,11 +35,11 @@ namespace EMotionFX
public:
static bool AddSimulatedObject(AZ::u32 actorId, AZStd::optional<AZStd::string> name = AZStd::nullopt, MCore::CommandGroup* commandGroup = nullptr, bool executeInsideCommand = false);
static bool RemoveSimulatedObject(AZ::u32 actorId, size_t objectIndex, MCore::CommandGroup* commandGroup = nullptr, bool executeInsideCommand = false);
static bool AddSimulatedJoints(AZ::u32 actorId, const AZStd::vector<AZ::u32>& jointIndices, size_t objectIndex, bool addChildren, MCore::CommandGroup* commandGroup = nullptr, bool executeInsideCommand = false);
static bool RemoveSimulatedJoints(AZ::u32 actorId, const AZStd::vector<AZ::u32>& jointIndices, size_t objectIndex, bool removeChildren, MCore::CommandGroup* commandGroup = nullptr, bool executeInsideCommand = false);
static bool AddSimulatedJoints(AZ::u32 actorId, const AZStd::vector<size_t>& jointIndices, size_t objectIndex, bool addChildren, MCore::CommandGroup* commandGroup = nullptr, bool executeInsideCommand = false);
static bool RemoveSimulatedJoints(AZ::u32 actorId, const AZStd::vector<size_t>& jointIndices, size_t objectIndex, bool removeChildren, MCore::CommandGroup* commandGroup = nullptr, bool executeInsideCommand = false);
static void JointIndicesToString(const AZStd::vector<AZ::u32>& jointIndices, AZStd::string& outJointIndicesString);
static void StringToJointIndices(const AZStd::string& jointIndicesString, AZStd::vector<AZ::u32>& outJointIndices);
static void JointIndicesToString(const AZStd::vector<size_t>& jointIndices, AZStd::string& outJointIndicesString);
static void StringToJointIndices(const AZStd::string& jointIndicesString, AZStd::vector<size_t>& outJointIndices);
static void ReplaceTag(const Actor* actor, const PhysicsSetup::ColliderConfigType colliderType, const AZStd::string& oldTag, const AZStd::string& newTag, MCore::CommandGroup& outCommandGroup);
@@ -203,8 +204,8 @@ namespace EMotionFX
const char* GetDescription() const override { return "Add simulated joints to a simulated object"; }
MCore::Command* Create() override { return aznew CommandAddSimulatedJoints(this); }
const AZStd::vector<AZ::u32>& GetJointIndices() const { return m_jointIndices; }
void SetJointIndices(AZStd::vector<AZ::u32> newJointIndices) { m_jointIndices = AZStd::move(newJointIndices); }
const AZStd::vector<size_t>& GetJointIndices() const { return m_jointIndices; }
void SetJointIndices(AZStd::vector<size_t> newJointIndices) { m_jointIndices = AZStd::move(newJointIndices); }
size_t GetObjectIndex() { return m_objectIndex; }
void SetObjectIndex(size_t newObjectIndex ) { m_objectIndex = newObjectIndex; }
@@ -215,8 +216,8 @@ namespace EMotionFX
static const char* s_addChildrenParameterName;
static const char* s_contentsParameterName;
private:
size_t m_objectIndex = MCORE_INVALIDINDEX32;
AZStd::vector<AZ::u32> m_jointIndices;
size_t m_objectIndex = InvalidIndex;
AZStd::vector<size_t> m_jointIndices;
AZStd::optional<AZStd::string> m_contents;
bool m_addChildren = false;
bool m_oldDirtyFlag = false;
@@ -245,7 +246,7 @@ namespace EMotionFX
const char* GetDescription() const override { return "Remove simulated joints from a simulated object"; }
MCore::Command* Create() override { return aznew CommandRemoveSimulatedJoints(this); }
const AZStd::vector<AZ::u32>& GetJointIndices() const { return m_jointIndices; }
const AZStd::vector<size_t>& GetJointIndices() const { return m_jointIndices; }
size_t GetObjectIndex() { return m_objectIndex; }
static const char* s_commandName;
@@ -254,8 +255,8 @@ namespace EMotionFX
static const char* s_removeChildrenParameterName;
private:
size_t m_objectIndex = MCORE_INVALIDINDEX32;
AZStd::vector<AZ::u32> m_jointIndices;
size_t m_objectIndex = InvalidIndex;
AZStd::vector<size_t> m_jointIndices;
AZStd::optional<AZStd::string> m_oldContents;
bool m_removeChildren = false;
bool m_oldDirtyFlag = false;
@@ -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)
{
@@ -11,7 +11,6 @@
#include <AzCore/Math/Quaternion.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/optional.h>
#include <MCore/Source/Array.h>
#include <MCore/Source/MemoryFile.h>
#include <MCore/Source/Endian.h>
#include <MCore/Source/Color.h>
@@ -58,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);
@@ -100,21 +100,21 @@ namespace ExporterLib
// nodes
void SaveNodes(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType);
void SaveNodeGroup(MCore::Stream* file, EMotionFX::NodeGroup* nodeGroup, MCore::Endian::EEndianType targetEndianType);
void SaveNodeGroups(MCore::Stream* file, const MCore::Array<EMotionFX::NodeGroup*>& nodeGroups, MCore::Endian::EEndianType targetEndianType);
void SaveNodeGroups(MCore::Stream* file, const AZStd::vector<EMotionFX::NodeGroup*>& nodeGroups, MCore::Endian::EEndianType targetEndianType);
void SaveNodeGroups(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType);
void SaveNodeMotionSources(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Array<EMotionFX::Actor::NodeMirrorInfo>* mirrorInfo, MCore::Endian::EEndianType targetEndianType);
void SaveNodeMotionSources(MCore::Stream* file, EMotionFX::Actor* actor, AZStd::vector<EMotionFX::Actor::NodeMirrorInfo>* mirrorInfo, MCore::Endian::EEndianType targetEndianType);
void SaveAttachmentNodes(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType);
void SaveAttachmentNodes(MCore::Stream* file, EMotionFX::Actor* actor, const AZStd::vector<uint16>& attachmentNodes, MCore::Endian::EEndianType targetEndianType);
// morph targets
void SaveMorphTarget(MCore::Stream* file, EMotionFX::Actor* actor, EMotionFX::MorphTarget* inputMorphTarget, uint32 lodLevel, MCore::Endian::EEndianType targetEndianType);
void SaveMorphTargets(MCore::Stream* file, EMotionFX::Actor* actor, uint32 lodLevel, MCore::Endian::EEndianType targetEndianType);
void SaveMorphTarget(MCore::Stream* file, EMotionFX::Actor* actor, EMotionFX::MorphTarget* inputMorphTarget, size_t lodLevel, MCore::Endian::EEndianType targetEndianType);
void SaveMorphTargets(MCore::Stream* file, EMotionFX::Actor* actor, size_t lodLevel, MCore::Endian::EEndianType targetEndianType);
void SaveMorphTargets(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType);
// 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<AZ::Data::AssetId> meshAssetId = AZStd::nullopt);
bool SaveActor(AZStd::string& filename, const EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType, const AZStd::optional<AZ::Data::AssetId> meshAssetId = AZStd::nullopt);
@@ -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<uint8>(EMotionFX::GetEMotionFX().GetHighVersion());
infoChunk.mExporterLowVersion = static_cast<uint8>(EMotionFX::GetEMotionFX().GetLowVersion());
infoChunk.mUnitType = static_cast<uint8>(unitType);
@@ -199,10 +199,10 @@ namespace ExporterLib
// save the given materials
void SaveMaterials(MCore::Stream* file, MCore::Array<EMotionFX::Material*>& materials, uint32 lodLevel, MCore::Endian::EEndianType targetEndianType)
void SaveMaterials(MCore::Stream* file, AZStd::vector<EMotionFX::Material*>& materials, uint32 lodLevel, MCore::Endian::EEndianType targetEndianType)
{
// get the number of materials
const uint32 numMaterials = materials.GetLength();
const uint32 numMaterials = materials.size();
// chunk header
EMotionFX::FileFormat::FileChunk chunkHeader;
@@ -269,15 +269,15 @@ namespace ExporterLib
const uint32 numMaterials = actor->GetNumMaterials(lodLevel);
// create our materials array and reserve some elements
MCore::Array<EMotionFX::Material*> materials;
materials.Reserve(numMaterials);
AZStd::vector<EMotionFX::Material*> materials;
materials.reserve(numMaterials);
// iterate through the materials
for (uint32 j = 0; j < numMaterials; j++)
{
// get the base material
EMotionFX::Material* baseMaterial = actor->GetMaterial(lodLevel, j);
materials.Add(baseMaterial);
materials.emplace_back(baseMaterial);
}
// save the materials
@@ -20,7 +20,7 @@
namespace ExporterLib
{
// save the given morph target
void SaveMorphTarget(MCore::Stream* file, EMotionFX::Actor* actor, EMotionFX::MorphTarget* inputMorphTarget, uint32 lodLevel, MCore::Endian::EEndianType targetEndianType)
void SaveMorphTarget(MCore::Stream* file, EMotionFX::Actor* actor, EMotionFX::MorphTarget* inputMorphTarget, size_t lodLevel, MCore::Endian::EEndianType targetEndianType)
{
MCORE_ASSERT(file);
MCORE_ASSERT(actor);
@@ -28,12 +28,12 @@ namespace ExporterLib
MCORE_ASSERT(inputMorphTarget->GetType() == EMotionFX::MorphTargetStandard::TYPE_ID);
EMotionFX::MorphTargetStandard* morphTarget = (EMotionFX::MorphTargetStandard*)inputMorphTarget;
const uint32 numTransformations = morphTarget->GetNumTransformations();
const size_t numTransformations = morphTarget->GetNumTransformations();
// copy over the information to the chunk
EMotionFX::FileFormat::Actor_MorphTarget morphTargetChunk;
morphTargetChunk.mLOD = lodLevel;
morphTargetChunk.mNumTransformations = numTransformations;
morphTargetChunk.mLOD = aznumeric_caster(lodLevel);
morphTargetChunk.mNumTransformations = aznumeric_caster(numTransformations);
morphTargetChunk.mRangeMin = morphTarget->GetRangeMin();
morphTargetChunk.mRangeMax = morphTarget->GetRangeMax();
morphTargetChunk.mPhonemeSets = morphTarget->GetPhonemeSets();
@@ -60,7 +60,7 @@ namespace ExporterLib
SaveString(morphTarget->GetName(), file, targetEndianType);
// create and write the transformations
for (uint32 i = 0; i < numTransformations; i++)
for (size_t i = 0; i < numTransformations; i++)
{
EMotionFX::MorphTargetStandard::Transformation transform = morphTarget->GetTransformation(i);
EMotionFX::Node* node = actor->GetSkeleton()->GetNode(transform.mNodeIndex);
@@ -73,7 +73,7 @@ namespace ExporterLib
// create and fill the transformation
EMotionFX::FileFormat::Actor_MorphTargetTransform transformChunk;
transformChunk.mNodeIndex = transform.mNodeIndex;
transformChunk.mNodeIndex = aznumeric_caster(transform.mNodeIndex);
CopyVector(transformChunk.mPosition, AZ::PackedVector3f(transform.mPosition));
CopyVector(transformChunk.mScale, AZ::PackedVector3f(transform.mScale));
CopyQuaternion(transformChunk.mRotation, transform.mRotation);
@@ -99,12 +99,12 @@ namespace ExporterLib
// get the size of the chunk for the given morph target
uint32 GetMorphTargetChunkSize(EMotionFX::MorphTarget* inputMorphTarget)
size_t GetMorphTargetChunkSize(EMotionFX::MorphTarget* inputMorphTarget)
{
MCORE_ASSERT(inputMorphTarget->GetType() == EMotionFX::MorphTargetStandard::TYPE_ID);
EMotionFX::MorphTargetStandard* morphTarget = (EMotionFX::MorphTargetStandard*)inputMorphTarget;
uint32 totalSize = 0;
size_t totalSize = 0;
totalSize += sizeof(EMotionFX::FileFormat::Actor_MorphTarget);
totalSize += GetStringChunkSize(morphTarget->GetName());
totalSize += sizeof(EMotionFX::FileFormat::Actor_MorphTargetTransform) * morphTarget->GetNumTransformations();
@@ -114,14 +114,14 @@ namespace ExporterLib
// get the size of the chunk for the complete morph setup
uint32 GetMorphSetupChunkSize(EMotionFX::MorphSetup* morphSetup)
size_t GetMorphSetupChunkSize(EMotionFX::MorphSetup* morphSetup)
{
// get the number of morph targets
const uint32 numMorphTargets = morphSetup->GetNumMorphTargets();
const size_t numMorphTargets = morphSetup->GetNumMorphTargets();
// calculate the size of the chunk
uint32 totalSize = sizeof(EMotionFX::FileFormat::Actor_MorphTargets);
for (uint32 i = 0; i < numMorphTargets; ++i)
size_t totalSize = sizeof(EMotionFX::FileFormat::Actor_MorphTargets);
for (size_t i = 0; i < numMorphTargets; ++i)
{
totalSize += GetMorphTargetChunkSize(morphSetup->GetMorphTarget(i));
}
@@ -129,15 +129,14 @@ namespace ExporterLib
return totalSize;
}
uint32 GetNumSavedMorphTargets(EMotionFX::MorphSetup* morphSetup)
size_t GetNumSavedMorphTargets(EMotionFX::MorphSetup* morphSetup)
{
return morphSetup->GetNumMorphTargets();
}
// save all morph targets for a given LOD level
void SaveMorphTargets(MCore::Stream* file, EMotionFX::Actor* actor, uint32 lodLevel, MCore::Endian::EEndianType targetEndianType)
void SaveMorphTargets(MCore::Stream* file, EMotionFX::Actor* actor, size_t lodLevel, MCore::Endian::EEndianType targetEndianType)
{
uint32 i;
MCORE_ASSERT(file);
MCORE_ASSERT(actor);
@@ -148,7 +147,7 @@ namespace ExporterLib
}
// get the number of morph targets we need to save to the file and check if there are any at all
const uint32 numSavedMorphTargets = GetNumSavedMorphTargets(morphSetup);
const size_t numSavedMorphTargets = GetNumSavedMorphTargets(morphSetup);
if (numSavedMorphTargets <= 0)
{
MCore::LogInfo("No morph targets to be saved in morph setup. Skipping writing morph targets.");
@@ -156,10 +155,10 @@ namespace ExporterLib
}
// get the number of morph targets
const uint32 numMorphTargets = morphSetup->GetNumMorphTargets();
const size_t numMorphTargets = morphSetup->GetNumMorphTargets();
// check if all morph targets have a valid name and rename them in case they are empty
for (i = 0; i < numMorphTargets; ++i)
for (size_t i = 0; i < numMorphTargets; ++i)
{
EMotionFX::MorphTarget* morphTarget = morphSetup->GetMorphTarget(i);
@@ -168,7 +167,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());
}
@@ -177,7 +176,7 @@ namespace ExporterLib
// fill in the chunk header
EMotionFX::FileFormat::FileChunk chunkHeader;
chunkHeader.mChunkID = EMotionFX::FileFormat::ACTOR_CHUNK_STDPMORPHTARGETS;
chunkHeader.mSizeInBytes = GetMorphSetupChunkSize(morphSetup);
chunkHeader.mSizeInBytes = aznumeric_caster(GetMorphSetupChunkSize(morphSetup));
chunkHeader.mVersion = 2;
// endian convert the chunk and write it to the file
@@ -186,8 +185,8 @@ namespace ExporterLib
// fill in the chunk header
EMotionFX::FileFormat::Actor_MorphTargets morphTargetsChunk;
morphTargetsChunk.mNumMorphTargets = numSavedMorphTargets;
morphTargetsChunk.mLOD = lodLevel;
morphTargetsChunk.mNumMorphTargets = aznumeric_caster(numSavedMorphTargets);
morphTargetsChunk.mLOD = aznumeric_caster(lodLevel);
MCore::LogDetailedInfo("============================================================");
MCore::LogInfo("Morph Targets (%i, LOD=%d)", morphTargetsChunk.mNumMorphTargets, morphTargetsChunk.mLOD);
@@ -199,7 +198,7 @@ namespace ExporterLib
file->Write(&morphTargetsChunk, sizeof(EMotionFX::FileFormat::Actor_MorphTargets));
// save morph targets
for (i = 0; i < numMorphTargets; ++i)
for (size_t i = 0; i < numMorphTargets; ++i)
{
SaveMorphTarget(file, actor, morphSetup->GetMorphTarget(i), lodLevel, targetEndianType);
}
@@ -209,8 +208,8 @@ namespace ExporterLib
void SaveMorphTargets(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType)
{
// get the number of LOD levels and save the morph targets for each
const uint32 numLODLevels = actor->GetNumLODLevels();
for (uint32 i = 0; i < numLODLevels; ++i)
const size_t numLODLevels = actor->GetNumLODLevels();
for (size_t i = 0; i < numLODLevels; ++i)
{
SaveMorphTargets(file, actor, i, targetEndianType);
}
@@ -24,12 +24,10 @@ namespace ExporterLib
MCORE_ASSERT(actor);
MCORE_ASSERT(node);
uint32 l;
// get some information from the node
const uint32 nodeIndex = node->GetNodeIndex();
const uint32 parentIndex = node->GetParentIndex();
const uint32 numChilds = node->GetNumChildNodes();
const size_t nodeIndex = node->GetNodeIndex();
const size_t parentIndex = node->GetParentIndex();
const size_t numChilds = node->GetNumChildNodes();
const EMotionFX::Transform& transform = actor->GetBindPose()->GetLocalSpaceTransform(nodeIndex);
AZ::PackedVector3f position = AZ::PackedVector3f(transform.mPosition);
AZ::Quaternion rotation = transform.mRotation.GetNormalized();
@@ -48,12 +46,12 @@ namespace ExporterLib
CopyQuaternion(nodeChunk.mLocalQuat, rotation);
CopyVector(nodeChunk.mLocalScale, scale);
nodeChunk.mNumChilds = numChilds;
nodeChunk.mParentIndex = parentIndex;
nodeChunk.mNumChilds = aznumeric_caster(numChilds);
nodeChunk.mParentIndex = aznumeric_caster(parentIndex);
// calculate and copy over the skeletal LODs
uint32 skeletalLODs = 0;
for (l = 0; l < 32; ++l)
for (uint32 l = 0; l < 32; ++l)
{
if (node->GetSkeletalLODStatus(l))
{
@@ -84,7 +82,7 @@ namespace ExporterLib
// log the node chunk information
MCore::LogDetailedInfo("- Node: name='%s' index=%i", actor->GetSkeleton()->GetNode(nodeIndex)->GetName(), nodeIndex);
if (parentIndex == MCORE_INVALIDINDEX32)
if (parentIndex == InvalidIndex)
{
MCore::LogDetailedInfo(" + Parent: Has no parent(root).");
}
@@ -105,7 +103,7 @@ namespace ExporterLib
// log skeletal lods
AZStd::string lodString = " + Skeletal LODs: ";
for (l = 0; l < 32; ++l)
for (uint32 l = 0; l < 32; ++l)
{
int32 flag = node->GetSkeletalLODStatus(l);
lodString += AZStd::to_string(flag);
@@ -129,10 +127,8 @@ namespace ExporterLib
void SaveNodes(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType)
{
uint32 i;
// get the number of nodes
const uint32 numNodes = actor->GetNumNodes();
const size_t numNodes = actor->GetNumNodes();
MCore::LogDetailedInfo("============================================================");
MCore::LogInfo("Nodes (%i)", actor->GetNumNodes());
@@ -144,8 +140,8 @@ namespace ExporterLib
chunkHeader.mVersion = 2;
// get the nodes chunk size
chunkHeader.mSizeInBytes = sizeof(EMotionFX::FileFormat::Actor_Nodes2) + numNodes * sizeof(EMotionFX::FileFormat::Actor_Node2);
for (i = 0; i < numNodes; i++)
chunkHeader.mSizeInBytes = aznumeric_caster(sizeof(EMotionFX::FileFormat::Actor_Nodes2) + numNodes * sizeof(EMotionFX::FileFormat::Actor_Node2));
for (size_t i = 0; i < numNodes; i++)
{
chunkHeader.mSizeInBytes += GetStringChunkSize(actor->GetSkeleton()->GetNode(i)->GetName());
}
@@ -156,8 +152,8 @@ namespace ExporterLib
// nodes chunk
EMotionFX::FileFormat::Actor_Nodes2 nodesChunk;
nodesChunk.mNumNodes = numNodes;
nodesChunk.mNumRootNodes = actor->GetSkeleton()->GetNumRootNodes();
nodesChunk.mNumNodes = aznumeric_caster(numNodes);
nodesChunk.mNumRootNodes = aznumeric_caster(actor->GetSkeleton()->GetNumRootNodes());
// endian conversion and write it
ConvertUnsignedInt(&nodesChunk.mNumNodes, targetEndianType);
@@ -166,21 +162,20 @@ namespace ExporterLib
file->Write(&nodesChunk, sizeof(EMotionFX::FileFormat::Actor_Nodes2));
// write the nodes
for (uint32 n = 0; n < numNodes; n++)
for (size_t n = 0; n < numNodes; n++)
{
SaveNode(file, actor, actor->GetSkeleton()->GetNode(n), targetEndianType);
}
}
void SaveNodeGroup(MCore::Stream* file, EMotionFX::NodeGroup* nodeGroup, MCore::Endian::EEndianType targetEndianType)
void SaveNodeGroup(MCore::Stream* file, const EMotionFX::NodeGroup* nodeGroup, MCore::Endian::EEndianType targetEndianType)
{
uint32 i;
MCORE_ASSERT(file);
MCORE_ASSERT(nodeGroup);
// get the number of nodes in the node group
const uint32 numNodes = nodeGroup->GetNumNodes();
const size_t numNodes = nodeGroup->GetNumNodes();
// the node group chunk
EMotionFX::FileFormat::Actor_NodeGroup groupChunk;
@@ -194,7 +189,7 @@ namespace ExporterLib
MCore::LogDetailedInfo("- Group: name='%s'", nodeGroup->GetName());
MCore::LogDetailedInfo(" + DisabledOnDefault: %i", groupChunk.mDisabledOnDefault);
AZStd::string nodesString;
for (i = 0; i < numNodes; ++i)
for (size_t i = 0; i < numNodes; ++i)
{
nodesString += AZStd::to_string(nodeGroup->GetNode(static_cast<uint16>(i)));
if (i < numNodes - 1)
@@ -214,7 +209,7 @@ namespace ExporterLib
SaveString(nodeGroup->GetNameString(), file, targetEndianType);
// write the node numbers
for (i = 0; i < numNodes; ++i)
for (size_t i = 0; i < numNodes; ++i)
{
uint16 nodeNumber = nodeGroup->GetNode(static_cast<uint16>(i));
if (nodeNumber == MCORE_INVALIDINDEX16)
@@ -227,13 +222,12 @@ namespace ExporterLib
}
void SaveNodeGroups(MCore::Stream* file, const MCore::Array<EMotionFX::NodeGroup*>& nodeGroups, MCore::Endian::EEndianType targetEndianType)
void SaveNodeGroups(MCore::Stream* file, const AZStd::vector<EMotionFX::NodeGroup*>& nodeGroups, MCore::Endian::EEndianType targetEndianType)
{
uint32 i;
MCORE_ASSERT(file);
// get the number of node groups
const uint32 numGroups = nodeGroups.GetLength();
const size_t numGroups = nodeGroups.size();
if (numGroups == 0)
{
@@ -251,11 +245,11 @@ namespace ExporterLib
// calculate the chunk size
chunkHeader.mSizeInBytes = sizeof(uint16);
for (i = 0; i < numGroups; ++i)
for (const EMotionFX::NodeGroup* nodeGroup : nodeGroups)
{
chunkHeader.mSizeInBytes += sizeof(EMotionFX::FileFormat::Actor_NodeGroup);
chunkHeader.mSizeInBytes += GetStringChunkSize(nodeGroups[i]->GetNameString());
chunkHeader.mSizeInBytes += sizeof(uint16) * nodeGroups[i]->GetNumNodes();
chunkHeader.mSizeInBytes += GetStringChunkSize(nodeGroup->GetNameString());
chunkHeader.mSizeInBytes += sizeof(uint16) * nodeGroup->GetNumNodes();
}
// endian conversion
@@ -270,9 +264,9 @@ namespace ExporterLib
file->Write(&numGroupsChunk, sizeof(uint16));
// iterate through all groups
for (i = 0; i < numGroups; ++i)
for (const EMotionFX::NodeGroup* nodeGroup : nodeGroups)
{
SaveNodeGroup(file, nodeGroups[i], targetEndianType);
SaveNodeGroup(file, nodeGroup, targetEndianType);
}
}
@@ -286,13 +280,13 @@ namespace ExporterLib
const uint32 numGroups = actor->GetNumNodeGroups();
// create the node group array and reserve some elements
MCore::Array<EMotionFX::NodeGroup*> nodeGroups;
nodeGroups.Reserve(numGroups);
AZStd::vector<EMotionFX::NodeGroup*> nodeGroups;
nodeGroups.reserve(numGroups);
// iterate through the node groups and add them to the array
for (uint32 i = 0; i < numGroups; ++i)
{
nodeGroups.Add(actor->GetNodeGroup(i));
nodeGroups.emplace_back(actor->GetNodeGroup(i));
}
// save the node groups
@@ -300,7 +294,7 @@ namespace ExporterLib
}
void SaveNodeMotionSources(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Array<EMotionFX::Actor::NodeMirrorInfo>* nodeMirrorInfos, MCore::Endian::EEndianType targetEndianType)
void SaveNodeMotionSources(MCore::Stream* file, EMotionFX::Actor* actor, AZStd::vector<EMotionFX::Actor::NodeMirrorInfo>* nodeMirrorInfos, MCore::Endian::EEndianType targetEndianType)
{
MCORE_ASSERT(file);
@@ -311,12 +305,12 @@ namespace ExporterLib
MCORE_ASSERT(nodeMirrorInfos);
const uint32 numNodes = nodeMirrorInfos->GetLength();
const size_t numNodes = nodeMirrorInfos->size();
// chunk information
EMotionFX::FileFormat::FileChunk chunkHeader;
chunkHeader.mChunkID = EMotionFX::FileFormat::ACTOR_CHUNK_NODEMOTIONSOURCES;
chunkHeader.mSizeInBytes = sizeof(EMotionFX::FileFormat::Actor_NodeMotionSources2) + (numNodes * sizeof(uint16)) + (numNodes * sizeof(uint8) * 2);
chunkHeader.mSizeInBytes = aznumeric_caster(sizeof(EMotionFX::FileFormat::Actor_NodeMotionSources2) + (numNodes * sizeof(uint16)) + (numNodes * sizeof(uint8) * 2));
chunkHeader.mVersion = 1;
// endian conversion and write it
@@ -326,7 +320,7 @@ namespace ExporterLib
// the node motion sources chunk data
EMotionFX::FileFormat::Actor_NodeMotionSources2 nodeMotionSourcesChunk;
nodeMotionSourcesChunk.mNumNodes = numNodes;
nodeMotionSourcesChunk.mNumNodes = aznumeric_caster(numNodes);
// convert endian and save to the file
ConvertUnsignedInt(&nodeMotionSourcesChunk.mNumNodes, targetEndianType);
@@ -339,13 +333,10 @@ namespace ExporterLib
MCore::LogInfo("============================================================");
// write all node motion sources and convert endian
for (uint32 i = 0; i < numNodes; ++i)
for (const EMotionFX::Actor::NodeMirrorInfo& nodeMirrorInfo : *nodeMirrorInfos)
{
// get the motion node source
uint16 nodeMotionSource = nodeMirrorInfos->GetItem(i).mSourceNode;
//if (actor && nodeMotionSource != MCORE_INVALIDINDEX16)
//LogInfo(" + '%s' (NodeNr=%i) -> '%s' (NodeNr=%i)", actor->GetNode( i )->GetName(), i, actor->GetNode( nodeMotionSource )->GetName(), nodeMotionSource);
uint16 nodeMotionSource = nodeMirrorInfo.mSourceNode;
// convert endian and save to the file
ConvertUnsignedShort(&nodeMotionSource, targetEndianType);
@@ -353,16 +344,16 @@ namespace ExporterLib
}
// write all axes
for (uint32 i = 0; i < numNodes; ++i)
for (const EMotionFX::Actor::NodeMirrorInfo& nodeMirrorInfo : *nodeMirrorInfos)
{
uint8 axis = static_cast<uint8>(nodeMirrorInfos->GetItem(i).mAxis);
uint8 axis = static_cast<uint8>(nodeMirrorInfo.mAxis);
file->Write(&axis, sizeof(uint8));
}
// write all flags
for (uint32 i = 0; i < numNodes; ++i)
for (const EMotionFX::Actor::NodeMirrorInfo& nodeMirrorInfo : *nodeMirrorInfos)
{
uint8 flags = static_cast<uint8>(nodeMirrorInfos->GetItem(i).mFlags);
uint8 flags = static_cast<uint8>(nodeMirrorInfo.mFlags);
file->Write(&flags, sizeof(uint8));
}
}
@@ -371,14 +362,14 @@ namespace ExporterLib
void SaveAttachmentNodes(MCore::Stream* file, EMotionFX::Actor* actor, MCore::Endian::EEndianType targetEndianType)
{
// get the number of nodes
const uint32 numNodes = actor->GetNumNodes();
const size_t numNodes = actor->GetNumNodes();
// create our attachment nodes array and preallocate memory
AZStd::vector<uint16> attachmentNodes;
attachmentNodes.reserve(numNodes);
// iterate through the nodes and collect all attachments
for (uint32 i = 0; i < numNodes; ++i)
for (size_t i = 0; i < numNodes; ++i)
{
// get the current node, check if it is an attachment and add it to the attachment array in that case
EMotionFX::Node* node = actor->GetSkeleton()->GetNode(i);
@@ -403,12 +394,12 @@ namespace ExporterLib
}
// get the number of attachment nodes
const uint32 numAttachmentNodes = static_cast<uint32>(attachmentNodes.size());
const size_t numAttachmentNodes = attachmentNodes.size();
// chunk information
EMotionFX::FileFormat::FileChunk chunkHeader;
chunkHeader.mChunkID = EMotionFX::FileFormat::ACTOR_CHUNK_ATTACHMENTNODES;
chunkHeader.mSizeInBytes = sizeof(EMotionFX::FileFormat::Actor_AttachmentNodes) + numAttachmentNodes * sizeof(uint16);
chunkHeader.mSizeInBytes = aznumeric_caster(sizeof(EMotionFX::FileFormat::Actor_AttachmentNodes) + numAttachmentNodes * sizeof(uint16));
chunkHeader.mVersion = 1;
// endian conversion and write it
@@ -418,7 +409,7 @@ namespace ExporterLib
// the attachment nodes chunk data
EMotionFX::FileFormat::Actor_AttachmentNodes attachmentNodesChunk;
attachmentNodesChunk.mNumNodes = numAttachmentNodes;
attachmentNodesChunk.mNumNodes = aznumeric_caster(numAttachmentNodes);
// convert endian and save to the file
ConvertUnsignedInt(&attachmentNodesChunk.mNumNodes, targetEndianType);
@@ -430,18 +421,16 @@ namespace ExporterLib
MCore::LogInfo("============================================================");
// get all nodes that are affected by the skin
MCore::Array<uint32> bones;
AZStd::vector<size_t> bones;
if (actor)
{
actor->ExtractBoneList(0, &bones);
}
// write all attachment nodes and convert endian
for (uint32 i = 0; i < numAttachmentNodes; ++i)
for (uint16 nodeNr : attachmentNodes)
{
// get the attachment node index
uint16 nodeNr = attachmentNodes[i];
if (actor && nodeNr != MCORE_INVALIDINDEX16)
{
EMotionFX::Node* node = actor->GetSkeleton()->GetNode(nodeNr);
@@ -455,7 +444,7 @@ namespace ExporterLib
}
// is the attachment node a skinned one?
if (bones.Find(node->GetNodeIndex()) != MCORE_INVALIDINDEX32)
if (AZStd::find(begin(bones), end(bones), node->GetNodeIndex()) != end(bones))
{
MCore::LogWarning("Attachment node '%s' (NodeNr=%i) is used by a skin. Skinning will look incorrectly when using motion mirroring.", node->GetName(), nodeNr);
}
@@ -163,10 +163,10 @@ namespace EMotionFX
createMotionEventCommand->SetStartTime(commandLine.GetValueAsFloat("startTime", 0.0f));
createMotionEventCommand->SetEndTime(commandLine.GetValueAsFloat("endTime", 0.0f));
const AZ::u32 eventTypeIndex = commandLine.FindParameterIndex("eventType");
const AZ::u32 parametersIndex = commandLine.FindParameterIndex("parameters");
const AZ::u32 mirrorTypeIndex = commandLine.FindParameterIndex("mirrorType");
if (eventTypeIndex == MCORE_INVALIDINDEX32 || parametersIndex == MCORE_INVALIDINDEX32 || mirrorTypeIndex == MCORE_INVALIDINDEX32)
const size_t eventTypeIndex = commandLine.FindParameterIndex("eventType");
const size_t parametersIndex = commandLine.FindParameterIndex("parameters");
const size_t mirrorTypeIndex = commandLine.FindParameterIndex("mirrorType");
if (eventTypeIndex == InvalidIndex || parametersIndex == InvalidIndex || mirrorTypeIndex == InvalidIndex)
{
// Note: We have noticed some bad data issue in internal assets. The parameters could contain \r\n inside of the parameter string, which would result in the mirror type missing.
// Those are already been fixed in the command line object code, but we don't want to support the bad data in here by creating another loophole. Instead, we want the user to fix
@@ -51,8 +51,6 @@ namespace MCommon
mArrowHeadMesh = CreateArrowHead(1.0f, 0.5f);
mUnitCubeMesh = CreateCube(1.0f);
mFont = new VectorFont(this);
mTriangleVertices.SetMemoryCategory(MEMCATEGORY_MCOMMON);
}
@@ -106,14 +104,14 @@ namespace MCommon
void RenderUtil::RenderTriangles()
{
// check if we have to render anything and skip directly in case there are no triangles
if (mTriangleVertices.GetIsEmpty())
if (mTriangleVertices.empty())
{
return;
}
// render the triangles and clear the array
RenderTriangles(mTriangleVertices);
mTriangleVertices.Clear(false);
mTriangleVertices.clear();
}
@@ -316,7 +314,7 @@ namespace MCommon
// render the given types of AABBs of a actor instance
void RenderUtil::RenderAabbs(EMotionFX::ActorInstance* actorInstance, const AABBRenderSettings& renderSettings, bool directlyRender)
{
const uint32 lodLevel = actorInstance->GetLODLevel();
const size_t lodLevel = actorInstance->GetLODLevel();
// handle the node based AABB
if (renderSettings.mNodeBasedAABB)
@@ -367,19 +365,19 @@ namespace MCommon
// render a simple line based skeleton
void RenderUtil::RenderSimpleSkeleton(EMotionFX::ActorInstance* actorInstance, const AZStd::unordered_set<AZ::u32>* visibleJointIndices,
const AZStd::unordered_set<AZ::u32>* selectedJointIndices, const MCore::RGBAColor& color, const MCore::RGBAColor& selectedColor,
void RenderUtil::RenderSimpleSkeleton(EMotionFX::ActorInstance* actorInstance, const AZStd::unordered_set<size_t>* visibleJointIndices,
const AZStd::unordered_set<size_t>* selectedJointIndices, const MCore::RGBAColor& color, const MCore::RGBAColor& selectedColor,
float jointSphereRadius, bool directlyRender)
{
const EMotionFX::Actor* actor = actorInstance->GetActor();
const EMotionFX::Skeleton* skeleton = actor->GetSkeleton();
const EMotionFX::Pose* pose = actorInstance->GetTransformData()->GetCurrentPose();
const uint32 numNodes = actorInstance->GetNumEnabledNodes();
for (uint32 n = 0; n < numNodes; ++n)
const size_t numNodes = actorInstance->GetNumEnabledNodes();
for (size_t n = 0; n < numNodes; ++n)
{
const EMotionFX::Node* joint = skeleton->GetNode(actorInstance->GetEnabledNode(n));
const AZ::u32 jointIndex = joint->GetNodeIndex();
const size_t jointIndex = joint->GetNodeIndex();
if (!visibleJointIndices || visibleJointIndices->empty() ||
(visibleJointIndices->find(jointIndex) != visibleJointIndices->end()))
@@ -387,8 +385,8 @@ namespace MCommon
const AZ::Vector3 currentJointPos = pose->GetWorldSpaceTransform(jointIndex).mPosition;
const bool jointSelected = selectedJointIndices->find(jointIndex) != selectedJointIndices->end();
const AZ::u32 parentIndex = joint->GetParentIndex();
if (parentIndex != MCORE_INVALIDINDEX32)
const size_t parentIndex = joint->GetParentIndex();
if (parentIndex != InvalidIndex)
{
const bool parentSelected = selectedJointIndices->find(parentIndex) != selectedJointIndices->end();
const AZ::Vector3 parentJointPos = pose->GetWorldSpaceTransform(parentIndex).mPosition;
@@ -421,7 +419,7 @@ namespace MCommon
AZ::Vector3* normals = (AZ::Vector3*)mesh->FindVertexData(EMotionFX::Mesh::ATTRIB_NORMALS);
MCore::RGBAColor* vertexColors = (MCore::RGBAColor*)mesh->FindVertexData(EMotionFX::Mesh::ATTRIB_COLORS128);
const uint32 numSubMeshes = mesh->GetNumSubMeshes();
const size_t numSubMeshes = mesh->GetNumSubMeshes();
for (uint32 subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex)
{
EMotionFX::SubMesh* subMesh = mesh->GetSubMesh(subMeshIndex);
@@ -483,7 +481,7 @@ namespace MCommon
// render face normals
if (faceNormals)
{
const uint32 numSubMeshes = mesh->GetNumSubMeshes();
const size_t numSubMeshes = mesh->GetNumSubMeshes();
for (uint32 subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex)
{
EMotionFX::SubMesh* subMesh = mesh->GetSubMesh(subMeshIndex);
@@ -515,7 +513,7 @@ namespace MCommon
// render vertex normals
if (vertexNormals)
{
const uint32 numSubMeshes = mesh->GetNumSubMeshes();
const size_t numSubMeshes = mesh->GetNumSubMeshes();
for (uint32 subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex)
{
EMotionFX::SubMesh* subMesh = mesh->GetSubMesh(subMeshIndex);
@@ -636,11 +634,11 @@ namespace MCommon
EMotionFX::TransformData* transformData = actorInstance->GetTransformData();
const EMotionFX::Pose* pose = transformData->GetCurrentPose();
const uint32 nodeIndex = node->GetNodeIndex();
const uint32 parentIndex = node->GetParentIndex();
const size_t nodeIndex = node->GetNodeIndex();
const size_t parentIndex = node->GetParentIndex();
const AZ::Vector3 nodeWorldPos = pose->GetWorldSpaceTransform(nodeIndex).mPosition;
if (parentIndex != MCORE_INVALIDINDEX32)
if (parentIndex != InvalidIndex)
{
const AZ::Vector3 parentWorldPos = pose->GetWorldSpaceTransform(parentIndex).mPosition;
const AZ::Vector3 bone = parentWorldPos - nodeWorldPos;
@@ -655,7 +653,7 @@ namespace MCommon
// render the advanced skeleton
void RenderUtil::RenderSkeleton(EMotionFX::ActorInstance* actorInstance, const MCore::Array<uint32>& boneList, const AZStd::unordered_set<AZ::u32>* visibleJointIndices, const AZStd::unordered_set<AZ::u32>* selectedJointIndices, const MCore::RGBAColor& color, const MCore::RGBAColor& selectedColor)
void RenderUtil::RenderSkeleton(EMotionFX::ActorInstance* actorInstance, const AZStd::vector<size_t>& boneList, const AZStd::unordered_set<size_t>* visibleJointIndices, const AZStd::unordered_set<size_t>* selectedJointIndices, const MCore::RGBAColor& color, const MCore::RGBAColor& selectedColor)
{
// check if our render util supports rendering meshes, if not render the fallback skeleton using lines only
if (GetIsMeshRenderingSupported() == false)
@@ -672,15 +670,15 @@ namespace MCommon
// iterate through all enabled nodes
MCore::RGBAColor tempColor;
const uint32 numEnabled = actorInstance->GetNumEnabledNodes();
for (uint32 i = 0; i < numEnabled; ++i)
const size_t numEnabled = actorInstance->GetNumEnabledNodes();
for (size_t i = 0; i < numEnabled; ++i)
{
EMotionFX::Node* joint = skeleton->GetNode(actorInstance->GetEnabledNode(i));
const AZ::u32 jointIndex = joint->GetNodeIndex();
const AZ::u32 parentIndex = joint->GetParentIndex();
const size_t jointIndex = joint->GetNodeIndex();
const size_t parentIndex = joint->GetParentIndex();
// check if this node has a parent and is a bone, if not skip it
if (parentIndex == MCORE_INVALIDINDEX32 || boneList.Find(jointIndex) == MCORE_INVALIDINDEX32)
if (parentIndex == InvalidIndex || AZStd::find(begin(boneList), end(boneList), jointIndex) == end(boneList))
{
continue;
}
@@ -717,7 +715,7 @@ namespace MCommon
// render node orientations
void RenderUtil::RenderNodeOrientations(EMotionFX::ActorInstance* actorInstance, const MCore::Array<uint32>& boneList, const AZStd::unordered_set<AZ::u32>* visibleJointIndices, const AZStd::unordered_set<AZ::u32>* selectedJointIndices, float scale, bool scaleBonesOnLength)
void RenderUtil::RenderNodeOrientations(EMotionFX::ActorInstance* actorInstance, const AZStd::vector<size_t>& boneList, const AZStd::unordered_set<size_t>* visibleJointIndices, const AZStd::unordered_set<size_t>* selectedJointIndices, float scale, bool scaleBonesOnLength)
{
// get the actor and the transform data
const float unitScale = 1.0f / (float)MCore::Distance::ConvertValue(1.0f, MCore::Distance::UNITTYPE_METERS, EMotionFX::GetEMotionFX().GetUnitType());
@@ -728,18 +726,18 @@ namespace MCommon
const float constPreScale = scale * unitScale * 3.0f;
AxisRenderingSettings axisRenderingSettings;
const uint32 numEnabled = actorInstance->GetNumEnabledNodes();
for (uint32 i = 0; i < numEnabled; ++i)
const size_t numEnabled = actorInstance->GetNumEnabledNodes();
for (size_t i = 0; i < numEnabled; ++i)
{
EMotionFX::Node* joint = skeleton->GetNode(actorInstance->GetEnabledNode(i));
const AZ::u32 jointIndex = joint->GetNodeIndex();
const AZ::u32 parentIndex = joint->GetParentIndex();
const size_t jointIndex = joint->GetNodeIndex();
const size_t parentIndex = joint->GetParentIndex();
if (!visibleJointIndices || visibleJointIndices->empty() ||
(visibleJointIndices->find(jointIndex) != visibleJointIndices->end()))
{
// either scale the bones based on their length or use the normal size
if (scaleBonesOnLength && parentIndex != MCORE_INVALIDINDEX32 && boneList.Find(jointIndex) != MCORE_INVALIDINDEX32)
if (scaleBonesOnLength && parentIndex != InvalidIndex && AZStd::find(begin(boneList), end(boneList), jointIndex) != end(boneList))
{
static const float axisBoneScale = 50.0f;
axisRenderingSettings.mSize = GetBoneScale(actorInstance, joint) * constPreScale * axisBoneScale;
@@ -777,11 +775,11 @@ namespace MCommon
AxisRenderingSettings axisRenderingSettings;
// iterate through all enabled nodes
const uint32 numEnabled = actorInstance->GetNumEnabledNodes();
for (uint32 i = 0; i < numEnabled; ++i)
const size_t numEnabled = actorInstance->GetNumEnabledNodes();
for (size_t i = 0; i < numEnabled; ++i)
{
EMotionFX::Node* node = skeleton->GetNode(actorInstance->GetEnabledNode(i));
const uint32 nodeIndex = node->GetNodeIndex();
const size_t nodeIndex = node->GetNodeIndex();
// render node orientation
const EMotionFX::Transform worldTransform = pose->GetWorldSpaceTransform(nodeIndex);
@@ -791,8 +789,8 @@ namespace MCommon
// skip root nodes for the line based skeleton rendering, you could also use curNode->IsRootNode()
// but we use the parent index here, as we will reuse it
uint32 parentIndex = node->GetParentIndex();
if (parentIndex != MCORE_INVALIDINDEX32)
size_t parentIndex = node->GetParentIndex();
if (parentIndex != InvalidIndex)
{
const AZ::Vector3 endPos = pose->GetWorldSpaceTransform(parentIndex).mPosition;
RenderLine(worldTransform.mPosition, endPos, color);
@@ -1584,8 +1582,8 @@ namespace MCommon
AZ::Aabb finalAABB = AZ::Aabb::CreateNull();
// get the number of actor instances and iterate through them
const uint32 numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (uint32 i = 0; i < numActorInstances; ++i)
const size_t numActorInstances = EMotionFX::GetActorManager().GetNumActorInstances();
for (size_t i = 0; i < numActorInstances; ++i)
{
// get the actor instance and update its transformations and meshes
EMotionFX::ActorInstance* actorInstance = EMotionFX::GetActorManager().GetActorInstance(i);
@@ -1675,10 +1673,10 @@ namespace MCommon
void RenderUtil::RenderTrajectory(EMotionFX::ActorInstance* actorInstance, const MCore::RGBAColor& innerColor, const MCore::RGBAColor& borderColor, float scale)
{
EMotionFX::Actor* actor = actorInstance->GetActor();
const uint32 nodeIndex = actor->GetMotionExtractionNodeIndex();
const size_t nodeIndex = actor->GetMotionExtractionNodeIndex();
// in case the motion extraction node is not set, return directly
if (nodeIndex == MCORE_INVALIDINDEX32)
if (nodeIndex == InvalidIndex)
{
return;
}
@@ -1711,9 +1709,9 @@ namespace MCommon
}
// fast access to the trajectory trace particles
const MCore::Array<MCommon::RenderUtil::TrajectoryPathParticle>& traceParticles = trajectoryPath->mTraceParticles;
const int32 numTraceParticles = traceParticles.GetLength();
if (traceParticles.GetIsEmpty())
const AZStd::vector<MCommon::RenderUtil::TrajectoryPathParticle>& traceParticles = trajectoryPath->mTraceParticles;
const size_t numTraceParticles = traceParticles.size();
if (traceParticles.empty())
{
return;
}
@@ -1783,7 +1781,7 @@ namespace MCommon
MCore::RGBAColor color = innerColor;
// render the path from the arrow head towards the tail
for (int32 i = numTraceParticles - 1; i > 0; i--)
for (size_t i = numTraceParticles - 1; i > 0; i--)
{
// calculate the normalized distance to the head, this value also represents the alpha value as it fades away while getting closer to the end
float normalizedDistance = (float)i / numTraceParticles;
@@ -1858,7 +1856,7 @@ namespace MCommon
}
// remove all particles while keeping the data in memory
trajectoryPath->mTraceParticles.Clear(false);
trajectoryPath->mTraceParticles.clear();
}
@@ -1885,18 +1883,18 @@ namespace MCommon
// render node names for all enabled nodes
void RenderUtil::RenderNodeNames(EMotionFX::ActorInstance* actorInstance, Camera* camera, uint32 screenWidth, uint32 screenHeight, const MCore::RGBAColor& color, const MCore::RGBAColor& selectedColor, const AZStd::unordered_set<AZ::u32>& visibleJointIndices, const AZStd::unordered_set<AZ::u32>& selectedJointIndices)
void RenderUtil::RenderNodeNames(EMotionFX::ActorInstance* actorInstance, Camera* camera, uint32 screenWidth, uint32 screenHeight, const MCore::RGBAColor& color, const MCore::RGBAColor& selectedColor, const AZStd::unordered_set<size_t>& visibleJointIndices, const AZStd::unordered_set<size_t>& selectedJointIndices)
{
const EMotionFX::Actor* actor = actorInstance->GetActor();
const EMotionFX::Skeleton* skeleton = actor->GetSkeleton();
const EMotionFX::TransformData* transformData = actorInstance->GetTransformData();
const EMotionFX::Pose* pose = transformData->GetCurrentPose();
const AZ::u32 numEnabledNodes = actorInstance->GetNumEnabledNodes();
const size_t numEnabledNodes = actorInstance->GetNumEnabledNodes();
for (uint32 i = 0; i < numEnabledNodes; ++i)
for (size_t i = 0; i < numEnabledNodes; ++i)
{
const EMotionFX::Node* joint = skeleton->GetNode(actorInstance->GetEnabledNode(i));
const AZ::u32 jointIndex = joint->GetNodeIndex();
const size_t jointIndex = joint->GetNodeIndex();
const AZ::Vector3 worldPos = pose->GetWorldSpaceTransform(jointIndex).mPosition;
// check if the current enabled node is along the visible nodes and render it if that is the case
@@ -177,7 +177,7 @@ namespace MCommon
* @param[in] directlyRender Will call the RenderLines() function internally in case it is set to true. If false
* you have to make sure to call RenderLines() manually at the end of your custom render frame function.
*/
void RenderSimpleSkeleton(EMotionFX::ActorInstance* actorInstance, const AZStd::unordered_set<AZ::u32>* visibleJointIndices = nullptr, const AZStd::unordered_set<AZ::u32>* selectedJointIndices = nullptr,
void RenderSimpleSkeleton(EMotionFX::ActorInstance* actorInstance, const AZStd::unordered_set<size_t>* visibleJointIndices = nullptr, const AZStd::unordered_set<size_t>* selectedJointIndices = nullptr,
const MCore::RGBAColor& color = MCore::RGBAColor(1.0f, 1.0f, 0.0f, 1.0f), const MCore::RGBAColor& selectedColor = MCore::RGBAColor(1.0f, 0.647f, 0.0f),
float jointSphereRadius = 0.1f, bool directlyRender = false);
@@ -191,7 +191,7 @@ namespace MCommon
* @param[in] color The desired skeleton color.
* @param[in] selectedColor The color of the selected bones.
*/
void RenderSkeleton(EMotionFX::ActorInstance* actorInstance, const MCore::Array<uint32>& boneList, const AZStd::unordered_set<AZ::u32>* visibleJointIndices = nullptr, const AZStd::unordered_set<AZ::u32>* selectedJointIndices = nullptr, const MCore::RGBAColor& color = MCore::RGBAColor(1.0f, 0.0f, 0.0f, 1.0f), const MCore::RGBAColor& selectedColor = MCore::RGBAColor(1.0f, 0.647f, 0.0f));
void RenderSkeleton(EMotionFX::ActorInstance* actorInstance, const AZStd::vector<size_t>& boneList, const AZStd::unordered_set<size_t>* visibleJointIndices = nullptr, const AZStd::unordered_set<size_t>* selectedJointIndices = nullptr, const MCore::RGBAColor& color = MCore::RGBAColor(1.0f, 0.0f, 0.0f, 1.0f), const MCore::RGBAColor& selectedColor = MCore::RGBAColor(1.0f, 0.647f, 0.0f));
/**
* Render node orientations.
@@ -202,7 +202,7 @@ namespace MCommon
* @param[in] scale The scaling value in units. Axes of normal nodes will use the scaling value as unit length, skinned bones will use the scaling value as multiplier.
* @param[in] scaleBonesOnLength Automatically scales the bone orientations based on the bone length. This means finger node orientations will be rendered smaller than foot bones as the bone length is a lot smaller as well.
*/
void RenderNodeOrientations(EMotionFX::ActorInstance* actorInstance, const MCore::Array<uint32>& boneList, const AZStd::unordered_set<AZ::u32>* visibleJointIndices = nullptr, const AZStd::unordered_set<AZ::u32>* selectedJointIndices = nullptr, float scale = 1.0f, bool scaleBonesOnLength = true);
void RenderNodeOrientations(EMotionFX::ActorInstance* actorInstance, const AZStd::vector<size_t>& boneList, const AZStd::unordered_set<size_t>* visibleJointIndices = nullptr, const AZStd::unordered_set<size_t>* selectedJointIndices = nullptr, float scale = 1.0f, bool scaleBonesOnLength = true);
/**
* Render the bind pose of the given actor.
@@ -224,7 +224,7 @@ namespace MCommon
* @param[in] visibleJointIndices List of visible joint indices. nullptr in case all joints should be rendered.
* @param[in] selectedJointIndices List of selected joint indices. nullptr in case selection should not be considered.
*/
void RenderNodeNames(EMotionFX::ActorInstance* actorInstance, MCommon::Camera* camera, uint32 screenWidth, uint32 screenHeight, const MCore::RGBAColor& color, const MCore::RGBAColor& selectedColor, const AZStd::unordered_set<AZ::u32>& visibleJointIndices, const AZStd::unordered_set<AZ::u32>& selectedJointIndices);
void RenderNodeNames(EMotionFX::ActorInstance* actorInstance, MCommon::Camera* camera, uint32 screenWidth, uint32 screenHeight, const MCore::RGBAColor& color, const MCore::RGBAColor& selectedColor, const AZStd::unordered_set<size_t>& visibleJointIndices, const AZStd::unordered_set<size_t>& selectedJointIndices);
/**
* Render a sphere.
@@ -570,17 +570,17 @@ namespace MCommon
MCORE_INLINE void AddTriangle(const AZ::Vector3& posA, const AZ::Vector3& posB, const AZ::Vector3& posC, const AZ::Vector3& normalA, const AZ::Vector3& normalB, const AZ::Vector3& normalC, uint32 color)
{
mTriangleVertices.Add(TriangleVertex(posA, normalA, color));
mTriangleVertices.Add(TriangleVertex(posB, normalB, color));
mTriangleVertices.Add(TriangleVertex(posC, normalC, color));
mTriangleVertices.emplace_back(TriangleVertex(posA, normalA, color));
mTriangleVertices.emplace_back(TriangleVertex(posB, normalB, color));
mTriangleVertices.emplace_back(TriangleVertex(posC, normalC, color));
if (mTriangleVertices.GetLength() + 2 >= mNumMaxTriangleVertices)
if (mTriangleVertices.size() + 2 >= mNumMaxTriangleVertices)
{
RenderTriangles();
}
}
virtual void RenderTriangles(const MCore::Array<TriangleVertex>& triangleVertices) { MCORE_UNUSED(triangleVertices); }
virtual void RenderTriangles(const AZStd::vector<TriangleVertex>& triangleVertices) { MCORE_UNUSED(triangleVertices); }
void RenderTriangles();
//---------------------------------------------------------------------------------------------
@@ -609,13 +609,13 @@ namespace MCommon
struct TrajectoryTracePath
{
MCore::Array<TrajectoryPathParticle> mTraceParticles;
AZStd::vector<TrajectoryPathParticle> mTraceParticles;
EMotionFX::ActorInstance* mActorInstance;
float mTimePassed;
TrajectoryTracePath()
{
mTraceParticles.Reserve(250);
mTraceParticles.reserve(250);
mTimePassed = 0.0f;
mActorInstance = NULL;
}
@@ -812,7 +812,7 @@ namespace MCommon
static uint32 mNumMaxMeshIndices; /**< The maximum capacity of the util mesh index buffer */
// helper variables for rendering triangles
MCore::Array<TriangleVertex> mTriangleVertices;
AZStd::vector<TriangleVertex> mTriangleVertices;
static uint32 mNumMaxTriangleVertices; /**< The maximum capacity of the triangle vertex buffer */
};
} // namespace MCommon
@@ -10,7 +10,7 @@
#include <MCore/Source/Config.h>
#include <MCore/Source/LogManager.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include "GBuffer.h"
#include "RenderTexture.h"
#include "GLSLShader.h"
@@ -27,15 +27,6 @@ namespace RenderGL
mActor = nullptr;
mEnableGPUSkinning = true;
mMaterials.SetMemoryCategory(MEMCATEGORY_RENDERING);
mHomoMaterials.SetMemoryCategory(MEMCATEGORY_RENDERING);
for (uint32 i = 0; i < 3; i++)
{
mIndexBuffers[i].SetMemoryCategory(MEMCATEGORY_RENDERING);
}
mSkyColor = MCore::RGBAColor(0.55f, 0.55f, 0.55f);
mGroundColor = MCore::RGBAColor(0.117f, 0.015f, 0.07f);
}
@@ -65,42 +56,36 @@ namespace RenderGL
// get rid of the allocated memory
void GLActor::Cleanup()
{
uint32 i;
// get rid of all index and vertex buffers
for (uint32 a = 0; a < 3; ++a)
for (AZStd::vector<VertexBuffer*>& vertexBuffers : mVertexBuffers)
{
// get rid of the given vertex buffers
const uint32 numVertexBuffers = mVertexBuffers[a].GetLength();
for (i = 0; i < numVertexBuffers; ++i)
for (VertexBuffer* vertexBuffer : vertexBuffers)
{
delete mVertexBuffers[a][i];
delete vertexBuffer;
}
// get rid of the given index buffers
const uint32 numIndexBuffers = mIndexBuffers[a].GetLength();
for (i = 0; i < numIndexBuffers; ++i)
}
for (AZStd::vector<IndexBuffer*>& indexBuffers : mIndexBuffers)
{
for (IndexBuffer* indexBuffer : indexBuffers)
{
delete mIndexBuffers[a][i];
delete indexBuffer;
}
}
// delete all materials
const uint32 numLOD = mMaterials.GetLength();
for (uint32 l = 0; l < numLOD; l++)
for (AZStd::vector<MaterialPrimitives*>& materialsPerLod : mMaterials)
{
const uint32 numMaterials = mMaterials[l].GetLength();
for (uint32 n = 0; n < numMaterials; n++)
for (MaterialPrimitives* materialPrimitives : materialsPerLod)
{
delete mMaterials[l][n]->mMaterial;
delete mMaterials[l][n];
delete materialPrimitives->mMaterial;
delete materialPrimitives;
}
}
}
// customize the classify mesh type function
EMotionFX::Mesh::EMeshType GLActor::ClassifyMeshType(EMotionFX::Node* node, EMotionFX::Mesh* mesh, uint32 lodLevel)
EMotionFX::Mesh::EMeshType GLActor::ClassifyMeshType(EMotionFX::Node* node, EMotionFX::Mesh* mesh, size_t lodLevel)
{
MCORE_ASSERT(node && mesh);
return mesh->ClassifyMeshType(lodLevel, mActor, node->GetNodeIndex(), !mEnableGPUSkinning, 4, 200);
@@ -122,34 +107,35 @@ 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);
mMaterials.resize(numGeometryLODLevels);
// resize the vertex and index buffers
for (uint32 a = 0; a < 3; ++a)
for (AZStd::vector<VertexBuffer*>& vertexBuffers : mVertexBuffers)
{
mVertexBuffers[a].Resize(numGeometryLODLevels);
mIndexBuffers[a].Resize(numGeometryLODLevels);
mPrimitives[a].Resize(numGeometryLODLevels);
// reset the vertex and index buffers
for (uint32 n = 0; n < numGeometryLODLevels; ++n)
{
mVertexBuffers[a][n] = nullptr;
mIndexBuffers [a][n] = nullptr;
}
vertexBuffers.resize(numGeometryLODLevels);
AZStd::fill(begin(vertexBuffers), end(vertexBuffers), nullptr);
}
for (AZStd::vector<IndexBuffer*>& indexBuffers : mIndexBuffers)
{
indexBuffers.resize(numGeometryLODLevels);
AZStd::fill(begin(indexBuffers), end(indexBuffers), nullptr);
}
for (MCore::Array2D<Primitive>& primitives : mPrimitives)
{
primitives.Resize(numGeometryLODLevels);
}
mHomoMaterials.Resize(numGeometryLODLevels);
mHomoMaterials.resize(numGeometryLODLevels);
mDynamicNodes.Resize (numGeometryLODLevels);
EMotionFX::Skeleton* skeleton = actor->GetSkeleton();
// iterate through the lod levels
for (uint32 lodLevel = 0; lodLevel < numGeometryLODLevels; ++lodLevel)
for (size_t lodLevel = 0; lodLevel < numGeometryLODLevels; ++lodLevel)
{
InitMaterials(lodLevel);
@@ -158,7 +144,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);
@@ -180,8 +166,8 @@ namespace RenderGL
EMotionFX::Mesh::EMeshType meshType = ClassifyMeshType(node, mesh, lodLevel);
// get the number of submeshes and iterate through them
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)
{
// get the current submesh
EMotionFX::SubMesh* subMesh = mesh->GetSubMesh(s);
@@ -206,7 +192,7 @@ namespace RenderGL
// add to material list
MaterialPrimitives* materialPrims = mMaterials[lodLevel][newPrimitive.mMaterialIndex];
materialPrims->mPrimitives[meshType].Add(newPrimitive);
materialPrims->mPrimitives[meshType].emplace_back(newPrimitive);
totalNumIndices[meshType] += newPrimitive.mNumTriangles * 3;
totalNumVerts[meshType] += subMesh->GetNumVertices();
@@ -221,7 +207,7 @@ namespace RenderGL
}
// create the dynamic vertex buffers
const uint32 numDynamicBytes = sizeof(StandardVertex) * totalNumVerts[EMotionFX::Mesh::MESHTYPE_CPU_DEFORMED];
const size_t numDynamicBytes = sizeof(StandardVertex) * totalNumVerts[EMotionFX::Mesh::MESHTYPE_CPU_DEFORMED];
if (numDynamicBytes > 0)
{
mVertexBuffers[EMotionFX::Mesh::MESHTYPE_CPU_DEFORMED][lodLevel] = new VertexBuffer();
@@ -239,7 +225,7 @@ namespace RenderGL
}
// create the static vertex buffers
const uint32 numStaticBytes = sizeof(StandardVertex) * totalNumVerts[EMotionFX::Mesh::MESHTYPE_STATIC];
const size_t numStaticBytes = sizeof(StandardVertex) * totalNumVerts[EMotionFX::Mesh::MESHTYPE_STATIC];
if (numStaticBytes > 0)
{
mVertexBuffers[EMotionFX::Mesh::MESHTYPE_STATIC][lodLevel] = new VertexBuffer();
@@ -257,7 +243,7 @@ namespace RenderGL
}
// create the skinned vertex buffers
const uint32 numSkinnedBytes = sizeof(SkinnedVertex) * totalNumVerts[EMotionFX::Mesh::MESHTYPE_GPU_DEFORMED];
const size_t numSkinnedBytes = sizeof(SkinnedVertex) * totalNumVerts[EMotionFX::Mesh::MESHTYPE_GPU_DEFORMED];
if (numSkinnedBytes > 0)
{
mVertexBuffers[EMotionFX::Mesh::MESHTYPE_GPU_DEFORMED][lodLevel] = new VertexBuffer();
@@ -284,10 +270,10 @@ namespace RenderGL
if (gpuSkinning)
{
// iterate through all geometry LOD levels
for (uint32 lodLevel = 0; lodLevel < numGeometryLODLevels; ++lodLevel)
for (size_t 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);
@@ -321,8 +307,8 @@ namespace RenderGL
EMotionFX::MeshDeformerStack* stack = actor->GetMeshDeformerStack(lodLevel, n);
if (stack)
{
const uint32 numDeformers = stack->GetNumDeformers();
for (uint32 d=0; d<numDeformers; ++d)
const size_t numDeformers = stack->GetNumDeformers();
for (size_t d=0; d<numDeformers; ++d)
{
EMotionFX::MeshDeformer* deformer = stack->GetDeformer(d);
deformer->SetIsEnabled(false);
@@ -365,15 +351,15 @@ namespace RenderGL
// initialize materials
void GLActor::InitMaterials(uint32 lodLevel)
void GLActor::InitMaterials(size_t lodLevel)
{
// get the number of materials and iterate through them
const uint32 numMaterials = mActor->GetNumMaterials(lodLevel);
for (uint32 m = 0; m < numMaterials; ++m)
const size_t numMaterials = mActor->GetNumMaterials(lodLevel);
for (size_t m = 0; m < numMaterials; ++m)
{
EMotionFX::Material* emfxMaterial = mActor->GetMaterial(lodLevel, m);
Material* material = InitMaterial(emfxMaterial);
mMaterials[lodLevel].Add( new MaterialPrimitives(material) );
mMaterials[lodLevel].emplace_back( new MaterialPrimitives(material) );
}
}
@@ -411,8 +397,8 @@ namespace RenderGL
// render meshes of the given type
void GLActor::RenderMeshes(EMotionFX::ActorInstance* actorInstance, EMotionFX::Mesh::EMeshType meshType, uint32 renderFlags)
{
const uint32 lodLevel = actorInstance->GetLODLevel();
const uint32 numMaterials = mMaterials[lodLevel].GetLength();
const size_t lodLevel = actorInstance->GetLODLevel();
const size_t numMaterials = mMaterials[lodLevel].size();
if (numMaterials == 0)
{
@@ -434,11 +420,9 @@ namespace RenderGL
mIndexBuffers[meshType][lodLevel]->Activate();
// render all the primitives in each material
for (uint32 n = 0; n < numMaterials; n++)
for (const MaterialPrimitives* materialPrims : mMaterials[lodLevel])
{
const MaterialPrimitives* materialPrims = mMaterials[lodLevel][n];
const uint32 numPrimitives = materialPrims->mPrimitives[meshType].GetLength();
if (numPrimitives == 0)
if (materialPrims->mPrimitives[meshType].empty())
{
continue;
}
@@ -459,9 +443,9 @@ namespace RenderGL
material->Activate(activationFlags);
// render all primitives
for (uint32 i = 0; i < numPrimitives; ++i)
for (const Primitive& primitive : materialPrims->mPrimitives[meshType])
{
material->Render(actorInstance, &materialPrims->mPrimitives[meshType][i]);
material->Render(actorInstance, &primitive);
}
material->Deactivate();
@@ -473,7 +457,7 @@ namespace RenderGL
void GLActor::UpdateDynamicVertices(EMotionFX::ActorInstance* actorInstance)
{
// get the number of dynamic nodes
const uint32 lodLevel = actorInstance->GetLODLevel();
const size_t lodLevel = actorInstance->GetLODLevel();
const size_t numNodes = mDynamicNodes.GetNumElements(lodLevel);
if (numNodes == 0)
{
@@ -500,7 +484,7 @@ namespace RenderGL
{
// get the node and its mesh
const size_t nodeIndex = mDynamicNodes.GetElement(lodLevel, n);
EMotionFX::Mesh* mesh = mActor->GetMesh(lodLevel, aznumeric_cast<uint32>(nodeIndex));
EMotionFX::Mesh* mesh = mActor->GetMesh(lodLevel, nodeIndex);
// is the mesh valid?
if (mesh == nullptr)
@@ -545,7 +529,7 @@ namespace RenderGL
// fill the index buffers with data
void GLActor::FillIndexBuffers(uint32 lodLevel)
void GLActor::FillIndexBuffers(size_t lodLevel)
{
// initialize the index buffers
uint32* staticIndices = nullptr;
@@ -586,8 +570,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);
@@ -606,7 +590,6 @@ namespace RenderGL
}
// get the mesh type and the indices
//const uint32 numIndices = mesh->GetNumIndices();
uint32* indices = mesh->GetIndices();
uint8* vertCounts = mesh->GetPolygonVertexCounts();
EMotionFX::Mesh::EMeshType meshType = ClassifyMeshType(node, mesh, lodLevel);
@@ -630,9 +613,6 @@ namespace RenderGL
polyStartIndex += numPolyVerts;
}
//for (uint32 i=0; i<numIndices; ++i)
//dynamicIndices[totalNumDynamicIndices++] = indices[i] + dynamicOffset;
dynamicOffset += mesh->GetNumVertices();
break;
}
@@ -653,10 +633,6 @@ namespace RenderGL
polyStartIndex += numPolyVerts;
}
// fill in static index buffers
//for (uint32 i=0; i<numIndices; ++i)
//staticIndices[totalNumStaticIndices++] = indices[i] + staticOffset;
staticOffset += mesh->GetNumVertices();
break;
}
@@ -677,10 +653,6 @@ namespace RenderGL
polyStartIndex += numPolyVerts;
}
// fill in gpu skinned index buffers
//for (uint32 i=0; i<numIndices; ++i)
//skinnedIndices[totalNumSkinnedIndices++] = indices[i] + gpuSkinnedOffset;
gpuSkinnedOffset += mesh->GetNumVertices();
break;
}
@@ -704,7 +676,7 @@ namespace RenderGL
// fill the static vertex buffer
void GLActor::FillStaticVertexBuffers(uint32 lodLevel)
void GLActor::FillStaticVertexBuffers(size_t lodLevel)
{
if (mVertexBuffers[EMotionFX::Mesh::MESHTYPE_STATIC][lodLevel] == nullptr)
{
@@ -712,7 +684,7 @@ namespace RenderGL
}
// get the number of nodes
const uint32 numNodes = mActor->GetNumNodes();
const size_t numNodes = mActor->GetNumNodes();
if (numNodes == 0)
{
return;
@@ -731,7 +703,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);
@@ -794,7 +766,7 @@ namespace RenderGL
// fill the GPU skinned vertex buffer
void GLActor::FillGPUSkinnedVertexBuffers(uint32 lodLevel)
void GLActor::FillGPUSkinnedVertexBuffers(size_t lodLevel)
{
if (mVertexBuffers[EMotionFX::Mesh::MESHTYPE_GPU_DEFORMED][lodLevel] == nullptr)
{
@@ -802,7 +774,7 @@ namespace RenderGL
}
// get the number of dynamic nodes
const uint32 numNodes = mActor->GetNumNodes();
const size_t numNodes = mActor->GetNumNodes();
if (numNodes == 0)
{
return;
@@ -821,7 +793,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);
@@ -858,8 +830,8 @@ namespace RenderGL
assert(skinningInfo);
// get the number of submeshes and iterate through them
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)
{
// get the current submesh and the start vertex
EMotionFX::SubMesh* subMesh = mesh->GetSubMesh(s);
@@ -886,9 +858,9 @@ namespace RenderGL
// get the influence and its weight and set the indices
EMotionFX::SkinInfluence* influence = skinningInfo->GetInfluence(orgVertex, i);
skinnedVertices[globalVert].mWeights[i] = influence->GetWeight();
const uint32 boneIndex = subMesh->FindBoneIndex(influence->GetNodeNr());
const size_t boneIndex = subMesh->FindBoneIndex(influence->GetNodeNr());
skinnedVertices[globalVert].mBoneIndices[i] = static_cast<float>(boneIndex);
MCORE_ASSERT(boneIndex != MCORE_INVALIDINDEX32);
MCORE_ASSERT(boneIndex != InvalidIndex);
}
// reset remaining weights and offsets
@@ -37,16 +37,11 @@ namespace RenderGL
mCurrentLineVB = 0;
for (uint32 i = 0; i < MAX_LINE_VERTEXBUFFERS; ++i)
{
mLineVertexBuffers[i] = nullptr;
}
// initialize the vertex buffers and the shader used for line rendering
for (uint32 i = 0; i < MAX_LINE_VERTEXBUFFERS; ++i)
for (VertexBuffer*& lineVertexBuffer : mLineVertexBuffers)
{
mLineVertexBuffers[i] = new VertexBuffer();
if (mLineVertexBuffers[i]->Init(sizeof(LineVertex), mNumMaxLineVertices, USAGE_DYNAMIC) == false)
lineVertexBuffer = new VertexBuffer();
if (lineVertexBuffer->Init(sizeof(LineVertex), mNumMaxLineVertices, USAGE_DYNAMIC) == false)
{
MCore::LogError("[OpenGL] Failed to create render utility line vertex buffer.");
CleanUp();
@@ -110,7 +105,6 @@ namespace RenderGL
mTextures = new TextureEntry[mMaxNumTextures];
// text rendering
mTextEntries.SetMemoryCategory(MEMCATEGORY_RENDERING);
}
@@ -140,10 +134,10 @@ namespace RenderGL
// destroy the allocated memory
void GLRenderUtil::CleanUp()
{
for (uint32 i = 0; i < MAX_LINE_VERTEXBUFFERS; ++i)
for (VertexBuffer*& lineVertexBuffer : mLineVertexBuffers)
{
delete mLineVertexBuffers[i];
mLineVertexBuffers[i] = nullptr;
delete lineVertexBuffer;
lineVertexBuffer = nullptr;
}
delete mMeshVertexBuffer;
@@ -164,12 +158,11 @@ namespace RenderGL
delete[] mTextures;
// get rid of texture entries
const uint32 numTextEntries = mTextEntries.GetLength();
for (uint32 i = 0; i < numTextEntries; ++i)
for (TextEntry* textEntry : mTextEntries)
{
delete mTextEntries[i];
delete textEntry;
}
mTextEntries.Clear();
mTextEntries.clear();
}
@@ -245,9 +238,6 @@ namespace RenderGL
glPopAttrib();
//const float renderTime = time.GetTime();
//LOG("numTextures=%i, renderTime=%.3fms", mNumTextures, renderTime*1000);
mNumTextures = 0;
}
@@ -481,10 +471,10 @@ namespace RenderGL
}
void GLRenderUtil::RenderTriangles(const MCore::Array<TriangleVertex>& triangleVertices)
void GLRenderUtil::RenderTriangles(const AZStd::vector<TriangleVertex>& triangleVertices)
{
// check if there are any triangles to render, if not return directly
if (triangleVertices.GetIsEmpty())
if (triangleVertices.empty())
{
return;
}
@@ -492,7 +482,7 @@ namespace RenderGL
glDisable(GL_CULL_FACE);
// get the number of vertices to render
const uint32 numVertices = triangleVertices.GetLength();
const uint32 numVertices = aznumeric_caster(triangleVertices.size());
MCORE_ASSERT(numVertices <= mNumMaxTriangleVertices);
// lock the vertex buffer
@@ -552,7 +542,7 @@ namespace RenderGL
textEntry->mFontSize = fontSize;
textEntry->mCentered = centered;
mTextEntries.Add(textEntry);
mTextEntries.emplace_back(textEntry);
}
@@ -560,7 +550,7 @@ namespace RenderGL
{
static AZ::Debug::Timer timer;
const float timeDelta = static_cast<float>(timer.StampAndGetDeltaTimeInSeconds());
for (uint32 i = 0; i < mTextEntries.GetLength(); )
for (uint32 i = 0; i < mTextEntries.size(); )
{
TextEntry* textEntry = mTextEntries[i];
RenderText(static_cast<float>(textEntry->mX), static_cast<float>(textEntry->mY), textEntry->mText.c_str(), textEntry->mColor, textEntry->mFontSize, textEntry->mCentered);
@@ -569,7 +559,7 @@ namespace RenderGL
if (textEntry->mLifeTime < 0.0f)
{
delete textEntry;
mTextEntries.Remove(i);
mTextEntries.erase(AZStd::next(begin(mTextEntries), i));
}
else
{
@@ -54,7 +54,7 @@ namespace RenderGL
// triangle rendering
void RenderTriangle(const AZ::Vector3& v1, const AZ::Vector3& v2, const AZ::Vector3& v3, const MCore::RGBAColor& color) override;
void RenderTriangles(const MCore::Array<TriangleVertex>& triangleVertices) override;
void RenderTriangles(const AZStd::vector<TriangleVertex>& triangleVertices) override;
// text rendering (do not use until really needed, needs to do runtime allocations)
void RenderTextPeriod(uint32 x, uint32 y, const char* text, float lifeTime, const MCore::RGBAColor& color = MCore::RGBAColor(1.0f, 1.0f, 1.0f), float fontSize = 11.0f, bool centered = false);
@@ -74,7 +74,7 @@ namespace RenderGL
#define MAX_LINE_VERTEXBUFFERS 2
GraphicsManager* mGraphicsManager;
VertexBuffer* mLineVertexBuffers[MAX_LINE_VERTEXBUFFERS];
VertexBuffer* mLineVertexBuffers[MAX_LINE_VERTEXBUFFERS]{};
uint16 mCurrentLineVB;
GLSLShader* mLineShader;
GLSLShader* mMeshShader;
@@ -108,7 +108,7 @@ namespace RenderGL
bool mCentered;
};
MCore::Array<TextEntry*> mTextEntries;
AZStd::vector<TextEntry*> mTextEntries;
TextureEntry* mTextures;
uint32 mNumTextures;
uint32 mMaxNumTextures;
@@ -6,6 +6,7 @@
*
*/
#include <AzCore/std/numeric.h>
#include <MCore/Source/Config.h>
#include <MCore/Source/LogManager.h>
#include "GLSLShader.h"
@@ -36,16 +37,11 @@ namespace RenderGL
mPixelShader = 0;
mTextureUnit = 0;
mUniforms.SetMemoryCategory(MEMCATEGORY_RENDERING);
mAttributes.SetMemoryCategory(MEMCATEGORY_RENDERING);
mActivatedAttribs.SetMemoryCategory(MEMCATEGORY_RENDERING);
mActivatedTextures.SetMemoryCategory(MEMCATEGORY_RENDERING);
// pre-alloc data for uniforms and attributes
mUniforms.Reserve(10);
mAttributes.Reserve(10);
mActivatedAttribs.Reserve(10);
mActivatedTextures.Reserve(10);
mUniforms.reserve(10);
mAttributes.reserve(10);
mActivatedAttribs.reserve(10);
mActivatedTextures.reserve(10);
}
@@ -70,24 +66,20 @@ namespace RenderGL
// Deactivate
void GLSLShader::Deactivate()
{
const uint32 numAttribs = mActivatedAttribs.GetLength();
for (uint32 i = 0; i < numAttribs; ++i)
for (const size_t index : mActivatedAttribs)
{
const uint32 index = mActivatedAttribs[i];
glDisableVertexAttribArray(mAttributes[index].mLocation);
}
const uint32 numTextures = mActivatedTextures.GetLength();
for (uint32 i = 0; i < numTextures; ++i)
for (const size_t index : mActivatedTextures)
{
const uint32 index = mActivatedTextures[i];
assert(mUniforms[index].mType == GL_SAMPLER_2D);
glActiveTexture(GL_TEXTURE0 + mUniforms[index].mTextureUnit);
glBindTexture(GL_TEXTURE_2D, 0);
}
mActivatedAttribs.Clear(false);
mActivatedTextures.Clear(false);
mActivatedAttribs.clear();
mActivatedTextures.clear();
}
bool GLSLShader::Validate()
@@ -129,10 +121,9 @@ namespace RenderGL
text = "#version 120\n";
// build define string
const uint32 numDefines = mDefines.GetLength();
for (uint32 n = 0; n < numDefines; ++n)
for (const AZStd::string& define : mDefines)
{
text += AZStd::string::format("#define %s\n", mDefines[n].c_str());
text += AZStd::string::format("#define %s\n", define.c_str());
}
// read file into a big string
@@ -180,20 +171,16 @@ namespace RenderGL
AZStd::invoke(func, static_cast<QOpenGLExtraFunctions*>(this), object, logLen, &logWritten, text.data());
// if there are any defines, print that out too
if (mDefines.GetLength() > 0)
if (!mDefines.empty())
{
AZStd::string dStr;
const uint32 numDefines = mDefines.GetLength();
for (uint32 n = 0; n < numDefines; ++n)
for (const AZStd::string& define : mDefines)
{
if (n < numDefines - 1)
if (!dStr.empty())
{
dStr += mDefines[n] + " ";
}
else
{
dStr += mDefines[n];
dStr.append(" ");
}
dStr.append(define);
}
MCore::LogDetailedInfo("[GLSL] Compiling shader '%s', with defines %s", mFileName.c_str(), dStr.c_str());
@@ -209,7 +196,7 @@ namespace RenderGL
// Init
bool GLSLShader::Init(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName, MCore::Array<AZStd::string>& defines)
bool GLSLShader::Init(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName, AZStd::vector<AZStd::string>& defines)
{
initializeOpenGLFunctions();
/*const char* args[] = { "unroll all",
@@ -265,8 +252,8 @@ namespace RenderGL
// FindAttribute
GLSLShader::ShaderParameter* GLSLShader::FindAttribute(const char* name)
{
const uint32 index = FindAttributeIndex(name);
if (index == MCORE_INVALIDINDEX32)
const size_t index = FindAttributeIndex(name);
if (index == InvalidIndex)
{
return nullptr;
}
@@ -276,44 +263,40 @@ namespace RenderGL
// FindAttributeIndex
uint32 GLSLShader::FindAttributeIndex(const char* name)
size_t GLSLShader::FindAttributeIndex(const char* name)
{
const uint32 numAttribs = mAttributes.GetLength();
for (uint32 i = 0; i < numAttribs; ++i)
const auto foundAttribute = AZStd::find_if(begin(mAttributes), end(mAttributes), [name](const auto& attribute)
{
if (AzFramework::StringFunc::Equal(mAttributes[i].mName.c_str(), name, false /* no case */))
{
return AzFramework::StringFunc::Equal(attribute.mName.c_str(), name, false /* no case */) &&
// if we don't have a valid parameter location, an attribute by this name doesn't exist
// we just cached the fact that it doesn't exist, instead of failing glGetAttribLocation every time
if (mAttributes[i].mLocation >= 0)
{
return i;
}
return MCORE_INVALIDINDEX32;
}
attribute.mLocation >= 0;
});
if (foundAttribute != end(mAttributes))
{
return AZStd::distance(begin(mAttributes), foundAttribute);
}
// the parameter wasn't cached, try to retrieve it
const GLint loc = glGetAttribLocation(mProgram, name);
mAttributes.Add(ShaderParameter(name, loc, true));
mAttributes.emplace_back(name, loc, true);
if (loc < 0)
{
return MCORE_INVALIDINDEX32;
return InvalidIndex;
}
return mAttributes.GetLength() - 1;
return mAttributes.size() - 1;
}
// FindAttributeLocation
uint32 GLSLShader::FindAttributeLocation(const char* name)
size_t GLSLShader::FindAttributeLocation(const char* name)
{
ShaderParameter* p = FindAttribute(name);
if (p == nullptr)
{
return MCORE_INVALIDINDEX32;
return InvalidIndex;
}
return p->mLocation;
@@ -323,8 +306,8 @@ namespace RenderGL
// FindUniform
GLSLShader::ShaderParameter* GLSLShader::FindUniform(const char* name)
{
const uint32 index = FindUniformIndex(name);
if (index == MCORE_INVALIDINDEX32)
const size_t index = FindUniformIndex(name);
if (index == InvalidIndex)
{
return nullptr;
}
@@ -334,40 +317,36 @@ namespace RenderGL
// FindUniformIndex
uint32 GLSLShader::FindUniformIndex(const char* name)
size_t GLSLShader::FindUniformIndex(const char* name)
{
const uint32 numUniforms = mUniforms.GetLength();
for (uint32 i = 0; i < numUniforms; ++i)
const auto foundUniform = AZStd::find_if(begin(mUniforms), end(mUniforms), [name](const auto& uniform)
{
if (AzFramework::StringFunc::Equal(mUniforms[i].mName.c_str(), name, false /* no case */))
{
if (mUniforms[i].mLocation >= 0)
{
return i;
}
return MCORE_INVALIDINDEX32;
}
return AzFramework::StringFunc::Equal(uniform.mName.c_str(), name, false /* no case */) &&
uniform.mLocation >= 0;
});
if (foundUniform != end(mUniforms))
{
return AZStd::distance(begin(mUniforms), foundUniform);
}
// the parameter wasn't cached, try to retrieve it
const GLint loc = glGetUniformLocation(mProgram, name);
mUniforms.Add(ShaderParameter(name, loc, false));
mUniforms.emplace_back(name, loc, false);
if (loc < 0)
{
return MCORE_INVALIDINDEX32;
return InvalidIndex;
}
return mUniforms.GetLength() - 1;
return mUniforms.size() - 1;
}
// SetAttribute
void GLSLShader::SetAttribute(const char* name, uint32 dim, uint32 type, uint32 stride, size_t offset)
{
const uint32 index = FindAttributeIndex(name);
if (index == MCORE_INVALIDINDEX32)
const size_t index = FindAttributeIndex(name);
if (index == InvalidIndex)
{
return;
}
@@ -377,7 +356,7 @@ namespace RenderGL
glEnableVertexAttribArray(param->mLocation);
glVertexAttribPointer(param->mLocation, dim, type, GL_FALSE, stride, (GLvoid*)offset);
mActivatedAttribs.Add(index);
mActivatedAttribs.emplace_back(index);
}
@@ -508,8 +487,8 @@ namespace RenderGL
// SetUniform
void GLSLShader::SetUniform(const char* name, Texture* texture)
{
const uint32 index = FindUniformIndex(name);
if (index == MCORE_INVALIDINDEX32)
const size_t index = FindUniformIndex(name);
if (index == InvalidIndex)
{
return;
}
@@ -532,15 +511,15 @@ namespace RenderGL
glBindTexture(GL_TEXTURE_2D, texture->GetID());
glUniform1i(mUniforms[index].mLocation, mUniforms[index].mTextureUnit);
mActivatedTextures.Add(index);
mActivatedTextures.emplace_back(index);
}
// link a texture to a given uniform
void GLSLShader::SetUniformTextureID(const char* name, uint32 textureID)
{
const uint32 index = FindUniformIndex(name);
if (index == MCORE_INVALIDINDEX32)
const size_t index = FindUniformIndex(name);
if (index == InvalidIndex)
{
return;
}
@@ -563,25 +542,17 @@ namespace RenderGL
glBindTexture(GL_TEXTURE_2D, textureID);
glUniform1i(mUniforms[index].mLocation, mUniforms[index].mTextureUnit);
mActivatedTextures.Add(index);
mActivatedTextures.emplace_back(index);
}
// check if the given attribute string is defined in the shader
bool GLSLShader::CheckIfIsDefined(const char* attributeName)
bool GLSLShader::CheckIfIsDefined(const char* attributeName) const
{
// get the number of defines and iterate through them
const uint32 numDefines = mDefines.GetLength();
for (uint32 i = 0; i < numDefines; ++i)
return AZStd::any_of(begin(mDefines), end(mDefines), [attributeName](const AZStd::string& define)
{
// compare the given attribute with the current define and return if they are equal
if (AzFramework::StringFunc::Equal(mDefines[i].c_str(), attributeName, false /* no case */))
{
return true;
}
}
// we haven't found the attribute, return failure
return false;
return AzFramework::StringFunc::Equal(define.c_str(), attributeName, false /* no case */);
});
}
}
@@ -14,7 +14,7 @@
#include "Shader.h"
// include OpenGL
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/PlatformIncl.h>
#include <QOpenGLExtraFunctions>
@@ -36,13 +36,13 @@ namespace RenderGL
void Deactivate() override;
bool Validate() override;
uint32 FindAttributeLocation(const char* name);
size_t FindAttributeLocation(const char* name);
uint32 GetType() const override;
MCORE_INLINE unsigned int GetProgram() const { return mProgram; }
bool CheckIfIsDefined(const char* attributeName);
bool CheckIfIsDefined(const char* attributeName) const;
bool Init(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName, MCore::Array<AZStd::string>& defines);
bool Init(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName, AZStd::vector<AZStd::string>& defines);
void SetAttribute(const char* name, uint32 dim, uint32 type, uint32 stride, size_t offset) override;
void SetUniform(const char* name, float value) override;
@@ -73,8 +73,8 @@ namespace RenderGL
bool mIsAttribute;
};
uint32 FindAttributeIndex(const char* name);
uint32 FindUniformIndex(const char* name);
size_t FindAttributeIndex(const char* name);
size_t FindUniformIndex(const char* name);
ShaderParameter* FindAttribute(const char* name);
ShaderParameter* FindUniform(const char* name);
@@ -84,11 +84,11 @@ namespace RenderGL
AZ::IO::Path mFileName;
MCore::Array<uint32> mActivatedAttribs;
MCore::Array<uint32> mActivatedTextures;
MCore::Array<ShaderParameter> mUniforms;
MCore::Array<ShaderParameter> mAttributes;
MCore::Array<AZStd::string> mDefines;
AZStd::vector<size_t> mActivatedAttribs;
AZStd::vector<size_t> mActivatedTextures;
AZStd::vector<ShaderParameter> mUniforms;
AZStd::vector<ShaderParameter> mAttributes;
AZStd::vector<AZStd::string> mDefines;
unsigned int mVertexShader;
unsigned int mPixelShader;
@@ -403,23 +403,22 @@ namespace RenderGL
// LoadShader
GLSLShader* GraphicsManager::LoadShader(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName)
{
MCore::Array<AZStd::string> defines;
AZStd::vector<AZStd::string> defines;
return LoadShader(vertexFileName, pixelFileName, defines);
}
// LoadShader
GLSLShader* GraphicsManager::LoadShader(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName, MCore::Array<AZStd::string>& defines)
GLSLShader* GraphicsManager::LoadShader(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName, AZStd::vector<AZStd::string>& defines)
{
const AZ::IO::Path vertexPath {vertexFileName.empty() ? AZ::IO::Path{} : mShaderPath / vertexFileName};
const AZ::IO::Path pixelPath {pixelFileName.empty() ? AZ::IO::Path{} : mShaderPath / pixelFileName};
// construct the lookup string for the shader cache
AZStd::string cacheLookupStr = vertexPath.Native() + pixelPath.Native();
const uint32 numDefines = defines.GetLength();
for (uint32 n = 0; n < numDefines; n++)
for (const AZStd::string& define : defines)
{
cacheLookupStr += AZStd::string::format("#%s", defines[n].c_str());
cacheLookupStr += AZStd::string::format("#%s", define.c_str());
}
// check if the shader is already in the cache
@@ -62,7 +62,7 @@ namespace RenderGL
bool GetIsPostProcessingEnabled() const { return mPostProcessing; }
PostProcessShader* LoadPostProcessShader(AZ::IO::PathView filename);
GLSLShader* LoadShader(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName);
GLSLShader* LoadShader(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName, MCore::Array<AZStd::string>& defines);
GLSLShader* LoadShader(AZ::IO::PathView vertexFileName, AZ::IO::PathView pixelFileName, AZStd::vector<AZStd::string>& defines);
MCORE_INLINE void SetGBuffer(GBuffer* gBuffer) { mGBuffer = gBuffer; }
MCORE_INLINE GBuffer* GetGBuffer() { return mGBuffer; }
@@ -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. */
MCore::Array<uint32> mBoneNodeIndices;/**< Mapping from local bones 0-50 to nodes. */
AZStd::vector<size_t> mBoneNodeIndices;/**< Mapping from local bones 0-50 to nodes. */
};
@@ -81,7 +81,7 @@ namespace RenderGL
// Init
bool PostProcessShader::Init(AZ::IO::PathView filename)
{
MCore::Array<AZStd::string> defines;
AZStd::vector<AZStd::string> defines;
return GLSLShader::Init(nullptr, filename, defines);
}
@@ -15,8 +15,7 @@ namespace RenderGL
// constructor
ShaderCache::ShaderCache()
{
mEntries.SetMemoryCategory(MEMCATEGORY_RENDERING);
mEntries.Reserve(128);
mEntries.reserve(128);
}
@@ -31,56 +30,41 @@ namespace RenderGL
void ShaderCache::Release()
{
// delete all shaders
const uint32 numEntries = mEntries.GetLength();
for (uint32 i = 0; i < numEntries; ++i)
for (Entry& entry : mEntries)
{
mEntries[i].mName.clear();
delete mEntries[i].mShader;
entry.mName.clear();
delete entry.mShader;
}
// clear all entries
mEntries.Clear();
mEntries.clear();
}
// add the shader to the cache (assume there are no duplicate names)
void ShaderCache::AddShader(AZStd::string_view filename, Shader* shader)
{
mEntries.AddEmpty();
mEntries.GetLast().mName = filename;
mEntries.GetLast().mShader = shader;
mEntries.emplace_back(Entry{filename, shader});
}
// try to locate a shader based on its name
Shader* ShaderCache::FindShader(AZStd::string_view filename) const
{
const uint32 numEntries = mEntries.GetLength();
for (uint32 i = 0; i < numEntries; ++i)
const auto foundShader = AZStd::find_if(begin(mEntries), end(mEntries), [filename](const Entry& entry)
{
if (AzFramework::StringFunc::Equal(mEntries[i].mName, filename, false /* no case */)) // non-case-sensitive name compare
{
return mEntries[i].mShader;
}
}
// not found
return nullptr;
return AzFramework::StringFunc::Equal(entry.mName, filename, false /* no case */);
});
return foundShader != end(mEntries) ? foundShader->mShader : nullptr;
}
// check if we have a given shader in the cache
bool ShaderCache::CheckIfHasShader(Shader* shader) const
{
const uint32 numEntries = mEntries.GetLength();
for (uint32 i = 0; i < numEntries; ++i)
return AZStd::any_of(begin(mEntries), end(mEntries), [shader](const Entry& entry)
{
if (mEntries[i].mShader == shader)
{
return true;
}
}
return false;
return entry.mShader == shader;
});
}
} // namespace RenderGL
@@ -28,8 +28,6 @@ namespace RenderGL
mSpecularMap = GetGraphicsManager()->GetTextureCache()->GetWhiteTexture();
mNormalMap = GetGraphicsManager()->GetTextureCache()->GetDefaultNormalTexture();
mShaders.SetMemoryCategory(MEMCATEGORY_RENDERING);
SetAttribute(LIGHTING, true);
SetAttribute(SKINNING, false);
SetAttribute(SHADOWS, false);
@@ -185,8 +183,8 @@ namespace RenderGL
EMotionFX::StandardMaterial* stdMaterial = static_cast<EMotionFX::StandardMaterial*>(material);
// get the number of material layers and iterate through them
const uint32 numLayers = stdMaterial->GetNumLayers();
for (uint32 i = 0; i < numLayers; ++i)
const size_t numLayers = stdMaterial->GetNumLayers();
for (size_t i = 0; i < numLayers; ++i)
{
EMotionFX::StandardMaterialLayer* layer = stdMaterial->GetLayer(i);
switch (layer->GetType())
@@ -234,11 +232,9 @@ namespace RenderGL
//
void StandardMaterial::SetAttribute(EAttribute attribute, bool enabled)
{
const uint32 index = (uint32)attribute;
if (mAttributes[index] != enabled)
if (mAttributes[attribute] != enabled)
{
mAttributes[index] = enabled;
mAttributes[attribute] = enabled;
mAttributesUpdated = true;
}
}
@@ -266,15 +262,15 @@ namespace RenderGL
const AZ::Matrix3x4* skinningMatrices = transformData->GetSkinningMatrices();
// multiple each transform by its inverse bind pose
const uint32 numBones = primitive->mBoneNodeIndices.GetLength();
for (uint32 i = 0; i < numBones; ++i)
const size_t numBones = primitive->mBoneNodeIndices.size();
for (size_t i = 0; i < numBones; ++i)
{
const uint32 nodeNr = primitive->mBoneNodeIndices[i];
const size_t nodeNr = primitive->mBoneNodeIndices[i];
const AZ::Matrix3x4& skinTransform = skinningMatrices[nodeNr];
mBoneMatrices[i] = AZ::Matrix4x4::CreateFromMatrix3x4(skinTransform);
}
mActiveShader->SetUniform("matBones", mBoneMatrices, numBones);
mActiveShader->SetUniform("matBones", mBoneMatrices, aznumeric_caster(numBones));
}
const MCommon::Camera* camera = GetGraphicsManager()->GetCamera();
@@ -307,10 +303,9 @@ namespace RenderGL
mActiveShader = nullptr;
// get the number of shaders and iterate through them
const uint32 numShaders = mShaders.GetLength();
for (uint32 i = 0; i < numShaders; ++i)
for (GLSLShader* shader : mShaders)
{
if (mShaders[i] == nullptr)
if (shader == nullptr)
{
continue;
}
@@ -321,7 +316,7 @@ namespace RenderGL
{
if (mAttributes[n])
{
if (mShaders[i]->CheckIfIsDefined(AttributeToString((EAttribute)n)) == false)
if (shader->CheckIfIsDefined(AttributeToString((EAttribute)n)) == false)
{
match = false;
break;
@@ -329,7 +324,7 @@ namespace RenderGL
}
else
{
if (mShaders[i]->CheckIfIsDefined(AttributeToString((EAttribute)n)))
if (shader->CheckIfIsDefined(AttributeToString((EAttribute)n)))
{
match = false;
break;
@@ -340,7 +335,7 @@ namespace RenderGL
// in case we have found a matching shader update the active shader
if (match)
{
mActiveShader = mShaders[i];
mActiveShader = shader;
break;
}
}
@@ -351,18 +346,18 @@ namespace RenderGL
// if this function gets called at runtime something is wrong, go bug hunting!
// construct an array of string attributes
MCore::Array<AZStd::string> defines;
AZStd::vector<AZStd::string> defines;
for (uint32 n = 0; n < NUM_ATTRIBUTES; ++n)
{
if (mAttributes[n])
{
defines.Add(AttributeToString((EAttribute)n));
defines.emplace_back(AttributeToString((EAttribute)n));
}
}
// compile shader and add it to the list of shaders
mActiveShader = GetGraphicsManager()->LoadShader("StandardMaterial_VS.glsl", "StandardMaterial_PS.glsl", defines);
mShaders.Add(mActiveShader);
mShaders.emplace_back(mActiveShader);
}
mAttributesUpdated = false;
@@ -45,7 +45,7 @@ namespace RenderGL
bool mAttributesUpdated;
GLSLShader* mActiveShader;
MCore::Array<GLSLShader*> mShaders;
AZStd::vector<GLSLShader*> mShaders;
AZ::Matrix4x4 mBoneMatrices[200];
EMotionFX::Material* mMaterial;
@@ -47,8 +47,7 @@ namespace RenderGL
mWhiteTexture = nullptr;
mDefaultNormalTexture = nullptr;
mEntries.SetMemoryCategory(MEMCATEGORY_RENDERING);
mEntries.Reserve(128);
mEntries.reserve(128);
}
@@ -74,14 +73,13 @@ namespace RenderGL
void TextureCache::Release()
{
// delete all textures
const uint32 numEntries = mEntries.GetLength();
for (uint32 i = 0; i < numEntries; ++i)
for (Entry& entry : mEntries)
{
delete mEntries[i].mTexture;
delete entry.mTexture;
}
// clear all entries
mEntries.Clear();
mEntries.clear();
// delete the white texture
delete mWhiteTexture;
@@ -95,9 +93,7 @@ namespace RenderGL
// add the texture to the cache (assume there are no duplicate names)
void TextureCache::AddTexture(const char* filename, Texture* texture)
{
mEntries.AddEmpty();
mEntries.GetLast().mName = filename;
mEntries.GetLast().mTexture = texture;
mEntries.emplace_back(Entry{filename, texture});
}
@@ -105,17 +101,11 @@ namespace RenderGL
Texture* TextureCache::FindTexture(const char* filename) const
{
// get the number of entries and iterate through them
const uint32 numEntries = mEntries.GetLength();
for (uint32 i = 0; i < numEntries; ++i)
const auto foundEntry = AZStd::find_if(begin(mEntries), end(mEntries), [filename](const Entry& entry)
{
if (AzFramework::StringFunc::Equal(mEntries[i].mName.c_str(), filename, false /* no case */)) // non-case-sensitive name compare
{
return mEntries[i].mTexture;
}
}
// not found
return nullptr;
return AzFramework::StringFunc::Equal(entry.mName.c_str(), filename, false /* no case */);
});
return foundEntry != end(mEntries) ? foundEntry->mTexture : nullptr;
}
@@ -123,31 +113,25 @@ namespace RenderGL
bool TextureCache::CheckIfHasTexture(Texture* texture) const
{
// get the number of entries and iterate through them
const uint32 numEntries = mEntries.GetLength();
for (uint32 i = 0; i < numEntries; ++i)
return AZStd::any_of(begin(mEntries), end(mEntries), [texture](const Entry& entry)
{
if (mEntries[i].mTexture == texture)
{
return true;
}
}
return false;
return entry.mTexture == texture;
});
}
// remove an item from the cache
void TextureCache::RemoveTexture(Texture* texture)
{
const uint32 numEntries = mEntries.GetLength();
for (uint32 i = 0; i < numEntries; ++i)
const auto foundEntry = AZStd::find_if(begin(mEntries), end(mEntries), [texture](const Entry& entry)
{
if (mEntries[i].mTexture == texture)
{
delete mEntries[i].mTexture;
mEntries.Remove(i);
return;
}
return entry.mTexture == texture;
});
if (foundEntry != end(mEntries))
{
delete foundEntry->mTexture;
mEntries.erase(foundEntry);
}
}
@@ -157,12 +141,12 @@ namespace RenderGL
GLuint textureID;
glGenTextures(1, &textureID);
uint32 width = 2;
uint32 height = 2;
constexpr GLsizei width = 2;
constexpr GLsizei height = 2;
uint32 imageBuffer[4];
for (uint32 i = 0; i < 4; ++i)
{
imageBuffer[i] = MCore::RGBA(255, 255, 255, 255); // actually abgr
using AZStd::begin, AZStd::end;
AZStd::fill(begin(imageBuffer), end(imageBuffer), MCore::RGBA(255, 255, 255, 255)); // actually abgr
}
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -183,12 +167,12 @@ namespace RenderGL
GLuint textureID;
glGenTextures(1, &textureID);
uint32 width = 2;
uint32 height = 2;
constexpr GLsizei width = 2;
constexpr GLsizei height = 2;
uint32 imageBuffer[4];
for (uint32 i = 0; i < 4; ++i)
{
imageBuffer[i] = MCore::RGBA(255, 128, 128, 255); // opengl wants abgr
using AZStd::begin, AZStd::end;
AZStd::fill(begin(imageBuffer), end(imageBuffer), MCore::RGBA(255, 128, 128, 255)); // opengl wants abgr
}
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -10,7 +10,7 @@
#define __RENDERGL_TEXTURECACHE_H
#include <AzCore/std/string/string.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include "RenderGLConfig.h"
#include <AzCore/PlatformIncl.h>
@@ -72,7 +72,7 @@ namespace RenderGL
Texture* mTexture;
};
MCore::Array<Entry> mEntries;
AZStd::vector<Entry> mEntries;
Texture* mWhiteTexture;
Texture* mDefaultNormalTexture;
};
@@ -61,10 +61,10 @@ namespace RenderGL
struct RENDERGL_API MaterialPrimitives
{
Material* mMaterial;
MCore::Array<Primitive> mPrimitives[3];
AZStd::vector<Primitive> mPrimitives[3];
MaterialPrimitives() { mMaterial = nullptr; mPrimitives[0].Reserve(64); mPrimitives[1].Reserve(64); mPrimitives[2].Reserve(64); }
MaterialPrimitives(Material* mat) { mMaterial = mat; mPrimitives[0].Reserve(64); mPrimitives[1].Reserve(64); mPrimitives[2].Reserve(64); }
MaterialPrimitives() { mMaterial = nullptr; mPrimitives[0].reserve(64); mPrimitives[1].reserve(64); mPrimitives[2].reserve(64); }
MaterialPrimitives(Material* mat) { mMaterial = mat; mPrimitives[0].reserve(64); mPrimitives[1].reserve(64); mPrimitives[2].reserve(64); }
};
AZStd::string mTexturePath;
@@ -75,22 +75,22 @@ namespace RenderGL
void RenderMeshes(EMotionFX::ActorInstance* actorInstance, EMotionFX::Mesh::EMeshType meshType, uint32 renderFlags);
void RenderShadowMap(EMotionFX::Mesh::EMeshType meshType);
void InitMaterials(uint32 lodLevel);
void InitMaterials(size_t lodLevel);
Material* InitMaterial(EMotionFX::Material* emfxMaterial);
void FillIndexBuffers(uint32 lodLevel);
void FillStaticVertexBuffers(uint32 lodLevel);
void FillGPUSkinnedVertexBuffers(uint32 lodLevel);
void FillIndexBuffers(size_t lodLevel);
void FillStaticVertexBuffers(size_t lodLevel);
void FillGPUSkinnedVertexBuffers(size_t lodLevel);
void UpdateDynamicVertices(EMotionFX::ActorInstance* actorInstance);
EMotionFX::Mesh::EMeshType ClassifyMeshType(EMotionFX::Node* node, EMotionFX::Mesh* mesh, uint32 lodLevel);
EMotionFX::Mesh::EMeshType ClassifyMeshType(EMotionFX::Node* node, EMotionFX::Mesh* mesh, size_t lodLevel);
MCore::Array< MCore::Array<MaterialPrimitives*> > mMaterials;
MCore::Array2D<uint32> mDynamicNodes;
AZStd::vector< AZStd::vector<MaterialPrimitives*> > mMaterials;
MCore::Array2D<size_t> mDynamicNodes;
MCore::Array2D<Primitive> mPrimitives[3];
MCore::Array<bool> mHomoMaterials;
MCore::Array<VertexBuffer*> mVertexBuffers[3];
MCore::Array<IndexBuffer*> mIndexBuffers[3];
AZStd::vector<bool> mHomoMaterials;
AZStd::vector<VertexBuffer*> mVertexBuffers[3];
AZStd::vector<IndexBuffer*> mIndexBuffers[3];
MCore::RGBAColor mGroundColor;
MCore::RGBAColor mSkyColor;
@@ -11,7 +11,7 @@
#include "Shader.h"
#include <AzCore/std/string/string.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
namespace RenderGL
@@ -42,7 +42,7 @@ namespace RenderGL
};
//
MCore::Array<Entry> mEntries; // the shader cache entries
AZStd::vector<Entry> mEntries; // the shader cache entries
};
} // namespace RenderGL
File diff suppressed because it is too large Load Diff
+86 -63
View File
@@ -22,7 +22,7 @@
// include MCore related files
#include <MCore/Source/Vector.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include <MCore/Source/SmallArray.h>
#include <MCore/Source/Distance.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, MCore::Array<uint32>& outPath) const;
void GenerateUpdatePathToRoot(size_t endNodeIndex, AZStd::vector<size_t>& 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,14 +227,14 @@ 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.
* @param lodLevel The LOD level to check for.
* @result Returns true when skinned meshes are present in the specified LOD level, otherwise false is returned.
*/
bool CheckIfHasSkinnedMeshes(AZ::u32 lodLevel) const;
bool CheckIfHasSkinnedMeshes(size_t lodLevel) const;
/**
* Extract a list with nodes that represent bones.
@@ -245,7 +245,7 @@ namespace EMotionFX
* @param outBoneList The array of indices to nodes that will be filled with the nodes that are bones. When the outBoneList array
* already contains items, the array will first be cleared, so all existing contents will be lost.
*/
void ExtractBoneList(uint32 lodLevel, MCore::Array<uint32>* outBoneList) const;
void ExtractBoneList(size_t lodLevel, AZStd::vector<size_t>* outBoneList) const;
//------------------------------------------------
void SetPhysicsSetup(const AZStd::shared_ptr<PhysicsSetup>& physicsSetup);
@@ -261,7 +261,7 @@ namespace EMotionFX
* @param lodLevel The geometry LOD level to work on.
* @param numMaterials The amount of materials to pre-allocate space for.
*/
void ReserveMaterials(uint32 lodLevel, uint32 numMaterials);
void ReserveMaterials(size_t lodLevel, size_t numMaterials);
/**
* Get a given material.
@@ -269,7 +269,7 @@ namespace EMotionFX
* @param nr The material number to get.
* @result A pointer to the material.
*/
Material* GetMaterial(uint32 lodLevel, uint32 nr) const;
Material* GetMaterial(size_t lodLevel, size_t nr) const;
/**
* Find the material number/index of the material with the specified name.
@@ -279,7 +279,7 @@ namespace EMotionFX
* @result Returns the material number/index, which you can use to GetMaterial. When no material with the given name
* can be found, a value of MCORE_INVALIDINDEX32 is returned.
*/
uint32 FindMaterialIndexByName(uint32 lodLevel, const char* name) const;
size_t FindMaterialIndexByName(size_t lodLevel, const char* name) const;
/**
* Set a given material.
@@ -287,14 +287,14 @@ namespace EMotionFX
* @param nr The material number to set.
* @param mat The material to set at this index.
*/
void SetMaterial(uint32 lodLevel, uint32 nr, Material* mat);
void SetMaterial(size_t lodLevel, size_t nr, Material* mat);
/**
* Add a material to the back of the material list.
* @param lodLevel The LOD level add the material to.
* @param mat The material to add to the back of the list.
*/
void AddMaterial(uint32 lodLevel, Material* mat);
void AddMaterial(size_t lodLevel, Material* mat);
/**
* Remove the given material from the material list and reassign all material numbers of the sub meshes
@@ -306,14 +306,14 @@ namespace EMotionFX
* @param lodLevel The LOD level add the material to.
* @param index The material index of the material to remove.
*/
void RemoveMaterial(uint32 lodLevel, uint32 index);
void RemoveMaterial(size_t lodLevel, size_t index);
/**
* Get the number of materials.
* @param lodLevel The LOD level to get the number of material from.
* @result The number of materials this actor has/uses.
*/
uint32 GetNumMaterials(uint32 lodLevel) const;
size_t GetNumMaterials(size_t lodLevel) const;
/**
* Removes all materials from this actor.
@@ -329,7 +329,7 @@ namespace EMotionFX
* @param index The material number to check.
* @result Returns true when there are meshes using the material, otherwise false is returned.
*/
bool CheckIfIsMaterialUsed(uint32 lodLevel, uint32 index) const;
bool CheckIfIsMaterialUsed(size_t lodLevel, size_t index) const;
//------------------------------------------------
@@ -348,26 +348,26 @@ namespace EMotionFX
* @param[in] copySkeletalLODFlags Copy over the skeletal LOD flags in case of true, skip them in case of false.
* @param[in] delLODActorFromMem When set to true, the method will automatically delete the given copyActor from memory.
*/
void CopyLODLevel(Actor* copyActor, uint32 copyLODLevel, uint32 replaceLODLevel, bool copySkeletalLODFlags);
void CopyLODLevel(Actor* copyActor, size_t copyLODLevel, size_t replaceLODLevel, bool copySkeletalLODFlags);
/**
* Insert LOD level at the given position.
* This function will not copy any meshes, deformer, morph targets or materials but just insert an empty LOD level.
* @param[in] insertAt The position to insert the new LOD level.
*/
void InsertLODLevel(uint32 insertAt);
void InsertLODLevel(size_t insertAt);
/**
* Set the number of LOD levels.
* This will be called by the importer. Do not use manually.
*/
void SetNumLODLevels(uint32 numLODs, bool adjustMorphSetup = true);
void SetNumLODLevels(size_t numLODs, bool adjustMorphSetup = true);
/**
* Get the number of LOD levels inside this actor.
* @result The number of LOD levels. This value is at least 1, since the full detail LOD is always there.
*/
uint32 GetNumLODLevels() const;
size_t GetNumLODLevels() const;
//--------------------------------------------------------------------------
@@ -385,7 +385,7 @@ namespace EMotionFX
* @param outNumVertices The integer to write the number of vertices in.
* @param outNumIndices The integer to write the number of indices in.
*/
void CalcMeshTotals(uint32 lodLevel, uint32* outNumPolygons, uint32* outNumVertices, uint32* outNumIndices) const;
void CalcMeshTotals(size_t lodLevel, uint32* outNumPolygons, uint32* outNumVertices, uint32* outNumIndices) const;
/**
* Calculates the total number of vertices and indices of all STATIC node meshes for the given LOD.
@@ -394,7 +394,7 @@ namespace EMotionFX
* @param outNumVertices The integer to write the number of vertices in.
* @param outNumIndices The integer to write the number of indices in.
*/
void CalcStaticMeshTotals(uint32 lodLevel, uint32* outNumVertices, uint32* outNumIndices);
void CalcStaticMeshTotals(size_t lodLevel, uint32* outNumVertices, uint32* outNumIndices);
/**
* Calculates the total number of vertices and indices of all DEFORMABLE node meshes for the given LOD.
@@ -404,7 +404,7 @@ namespace EMotionFX
* @param outNumVertices The integer to write the number of vertices in.
* @param outNumIndices The integer to write the number of indices in.
*/
void CalcDeformableMeshTotals(uint32 lodLevel, uint32* outNumVertices, uint32* outNumIndices);
void CalcDeformableMeshTotals(size_t lodLevel, uint32* outNumVertices, uint32* outNumIndices);
/**
* Calculates the maximum number of bone influences.
@@ -412,7 +412,7 @@ namespace EMotionFX
* @param lodLevel The LOD level, where 0 is the highest detail LOD level. This value must be in range of [0..GetNumLODLevels()-1].
* @result The maximum number of influences. This will be 0 for non-softskinned objects.
*/
uint32 CalcMaxNumInfluences(uint32 lodLevel) const;
size_t CalcMaxNumInfluences(size_t lodLevel) const;
/**
* Calculates the maximum number of bone influences.
@@ -424,7 +424,7 @@ namespace EMotionFX
* @param lodLevel The detail level to calculate the results for. A value of 0 is the highest detail.
* @result The maximum number of vertex/bone influences. This will be 0 for rigid, non-skinned objects.
*/
uint32 CalcMaxNumInfluences(uint32 lodLevel, AZStd::vector<uint32>& outVertexCounts) const;
size_t CalcMaxNumInfluences(size_t lodLevel, AZStd::vector<size_t>& outVertexCounts) const;
/**
* Verify if the skinning will look correctly in the given geometry LOD for a given skeletal LOD level.
@@ -438,7 +438,7 @@ namespace EMotionFX
* disabled nodes from the given skeletal LOD level.
* @param geometryLODLevel The geometry LOD level to test the skeletal LOD against with.
*/
void VerifySkinning(MCore::Array<uint8>& conflictNodeFlags, uint32 skeletalLODLevel, uint32 geometryLODLevel);
void VerifySkinning(AZStd::vector<uint8>& conflictNodeFlags, size_t skeletalLODLevel, size_t geometryLODLevel);
/**
* Checks if the given material is used by a given mesh.
@@ -446,7 +446,7 @@ namespace EMotionFX
* @param materialIndex The index of the material to check.
* @return True if one of the submeshes of the given mesh uses the given material, false if not.
*/
bool CheckIfIsMaterialUsed(Mesh* mesh, uint32 materialIndex) const;
bool CheckIfIsMaterialUsed(Mesh* mesh, size_t materialIndex) const;
//------------------
@@ -522,15 +522,15 @@ namespace EMotionFX
* Get the number of dependencies.
* @result The number of dependencies that this actor has on other actors.
*/
MCORE_INLINE uint32 GetNumDependencies() const { return mDependencies.GetLength(); }
MCORE_INLINE size_t GetNumDependencies() const { return mDependencies.size(); }
/**
* Get a given dependency.
* @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.
@@ -546,7 +546,7 @@ namespace EMotionFX
* @result A smart pointer object to the morph setup. Use the MCore::Pointer<MorphSetup>::GetPointer() to get the actual pointer.
* That GetPointer() method will return nullptr when there is no morph setup for the given LOD level.
*/
MCORE_INLINE MorphSetup* GetMorphSetup(uint32 geomLODLevel) const { return mMorphSetups[geomLODLevel]; }
MCORE_INLINE MorphSetup* GetMorphSetup(size_t geomLODLevel) const { return mMorphSetups[geomLODLevel]; }
/**
* Remove all morph setups. Morph setups contain all morph targtets.
@@ -561,7 +561,7 @@ namespace EMotionFX
* @param lodLevel The LOD level, which must be in range of [0..GetNumLODLevels()-1].
* @param setup The morph setup for this LOD.
*/
void SetMorphSetup(uint32 lodLevel, MorphSetup* setup);
void SetMorphSetup(size_t lodLevel, MorphSetup* setup);
/**
* Get the number of node groups inside this actor object.
@@ -649,16 +649,16 @@ 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.GetLength() != 0); }
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(size_t skeletalLOD, size_t startNodeIndex) const;
/**
* Make the geometry LOD levels compatible with the skinning LOD levels.
@@ -749,9 +749,9 @@ namespace EMotionFX
void PostCreateInit(bool makeGeomLodsCompatibleWithSkeletalLODs = true, bool convertUnitType = true);
void AutoDetectMirrorAxes();
const MCore::Array<NodeMirrorInfo>& GetNodeMirrorInfos() const;
MCore::Array<NodeMirrorInfo>& GetNodeMirrorInfos();
void SetNodeMirrorInfos(const MCore::Array<NodeMirrorInfo>& mirrorInfos);
const AZStd::vector<NodeMirrorInfo>& GetNodeMirrorInfos() const;
AZStd::vector<NodeMirrorInfo>& GetNodeMirrorInfos();
void SetNodeMirrorInfos(const AZStd::vector<NodeMirrorInfo>& mirrorInfos);
bool GetHasMirrorAxesDetected() const;
MCORE_INLINE const AZStd::vector<Transform>& GetInverseBindPoseTransforms() const { return mInvBindPoseTransforms; }
@@ -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(size_t 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<AZ::Vector3>& 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(size_t lodLevel, size_t nodeIndex, Mesh* mesh);
void SetMeshDeformerStack(size_t lodLevel, size_t nodeIndex, MeshDeformerStack* stack);
bool CheckIfHasMorphDeformer(uint32 lodLevel, uint32 nodeIndex) const;
bool CheckIfHasSkinningDeformer(uint32 lodLevel, uint32 nodeIndex) const;
bool CheckIfHasMorphDeformer(size_t lodLevel, size_t nodeIndex) const;
bool CheckIfHasSkinningDeformer(size_t lodLevel, size_t nodeIndex) const;
void RemoveNodeMeshForLOD(uint32 lodLevel, uint32 nodeIndex, bool destroyMesh = true);
void RemoveNodeMeshForLOD(size_t 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<AZStd::string>& alwaysIncludeJoints);
@@ -846,7 +846,7 @@ namespace EMotionFX
void Finalize(LoadRequirement loadReq = LoadRequirement::AllowAsyncLoad);
private:
void InsertJointAndParents(AZ::u32 jointIndex, AZStd::unordered_set<AZ::u32>& includedJointIndices);
void InsertJointAndParents(size_t jointIndex, AZStd::unordered_set<size_t>& includedJointIndices);
AZStd::unordered_map<AZ::u16, AZ::u16> ConstructSkinToSkeletonIndexMap(const AZ::Data::Asset<AZ::RPI::SkinMetaAsset>& skinMetaAsset);
void ConstructMeshes();
@@ -861,15 +861,38 @@ namespace EMotionFX
MeshDeformerStack* mStack;
NodeLODInfo();
NodeLODInfo(const NodeLODInfo&) = delete;
NodeLODInfo(NodeLODInfo&& rhs)
{
if (&rhs == this)
{
return;
}
mMesh = rhs.mMesh;
mStack = rhs.mStack;
rhs.mMesh = nullptr;
rhs.mStack = nullptr;
}
NodeLODInfo& operator=(const NodeLODInfo&) = delete;
NodeLODInfo& operator=(NodeLODInfo&& rhs)
{
if (&rhs == this)
{
return *this;
}
mMesh = rhs.mMesh;
mStack = rhs.mStack;
rhs.mMesh = nullptr;
rhs.mStack = nullptr;
return *this;
}
~NodeLODInfo();
};
// a lod level
struct EMFX_API LODLevel
{
MCore::Array<NodeLODInfo> mNodeInfos;
LODLevel();
AZStd::vector<NodeLODInfo> mNodeInfos;
};
struct MeshLODData
@@ -896,12 +919,12 @@ namespace EMotionFX
Node* FindMeshJoint(const AZ::Data::Asset<AZ::RPI::ModelLodAsset>& lodModelAsset) const;
Skeleton* mSkeleton; /**< The skeleton, containing the nodes and bind pose. */
MCore::Array<Dependency> mDependencies; /**< The dependencies on other actors (shared meshes and transforms). */
AZStd::vector<Dependency> mDependencies; /**< The dependencies on other actors (shared meshes and transforms). */
AZStd::string mName; /**< The name of the actor. */
AZStd::string mFileName; /**< The filename of the actor. */
MCore::Array<NodeMirrorInfo> mNodeMirrorInfos; /**< The array of node mirror info. */
MCore::Array< MCore::Array< Material* > > mMaterials; /**< A collection of materials (for each lod). */
MCore::Array< MorphSetup* > mMorphSetups; /**< A morph setup for each geometry LOD. */
AZStd::vector<NodeMirrorInfo> mNodeMirrorInfos; /**< The array of node mirror info. */
AZStd::vector< AZStd::vector< Material* > > mMaterials; /**< A collection of materials (for each lod). */
AZStd::vector< MorphSetup* > mMorphSetups; /**< A morph setup for each geometry LOD. */
MCore::SmallArray<NodeGroup*> mNodeGroups; /**< The set of node groups. */
AZStd::shared_ptr<PhysicsSetup> m_physicsSetup; /**< Hit detection, ragdoll and cloth colliders, joint limits and rigid bodies. */
AZStd::shared_ptr<SimulatedObjectSetup> m_simulatedObjectSetup; /**< Setup for simulated objects */
@@ -909,8 +932,8 @@ namespace EMotionFX
MCore::Distance::EUnitType mFileUnitType; /**< The unit type used on export. */
AZStd::vector<Transform> 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. */
@@ -45,11 +45,7 @@ namespace EMotionFX
{
MCORE_ASSERT(actor);
// set the memory categories
mAttachments.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORINSTANCES);
mDependencies.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORINSTANCES);
mEnabledNodes.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORINSTANCES);
mEnabledNodes.Reserve(actor->GetNumNodes());
mEnabledNodes.reserve(actor->GetNumNodes());
// set the actor and create the motion system
mBoolFlags = 0;
@@ -61,7 +57,7 @@ namespace EMotionFX
mAttachedTo = nullptr;
mSelfAttachment = nullptr;
mCustomData = nullptr;
mID = MCore::GetIDGenerator().GenerateID();
mID = aznumeric_caster(MCore::GetIDGenerator().GenerateID());
mVisualizeScale = 1.0f;
mMotionSamplingRate = 0.0f;
mMotionSamplingTimer = 0.0f;
@@ -98,8 +94,8 @@ namespace EMotionFX
}
// disable nodes that are disabled in LOD 0
Skeleton* skeleton = mActor->GetSkeleton();
const uint32 numNodes = skeleton->GetNumNodes();
for (uint32 n = 0; n < numNodes; ++n)
const size_t numNodes = skeleton->GetNumNodes();
for (size_t n = 0; n < numNodes; ++n)
{
if (skeleton->GetNode(n)->GetSkeletalLODStatus(0) == false)
{
@@ -174,8 +170,8 @@ namespace EMotionFX
// delete all attachments
// actor instances that are attached will be detached, and not deleted from memory
const uint32 numAttachments = mAttachments.GetLength();
for (uint32 i = 0; i < numAttachments; ++i)
const size_t numAttachments = mAttachments.size();
for (size_t i = 0; i < numAttachments; ++i)
{
ActorInstance* attachmentActorInstance = mAttachments[i]->GetAttachmentActorInstance();
if (attachmentActorInstance)
@@ -187,7 +183,7 @@ namespace EMotionFX
}
mAttachments[i]->Destroy();
}
mAttachments.Clear();
mAttachments.clear();
if (mMorphSetup)
{
@@ -379,10 +375,10 @@ namespace EMotionFX
AZ::Matrix3x4* skinningMatrices = mTransformData->GetSkinningMatrices();
const Pose* pose = mTransformData->GetCurrentPose();
const uint32 numNodes = GetNumEnabledNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = GetNumEnabledNodes();
for (size_t i = 0; i < numNodes; ++i)
{
const uint32 nodeNumber = GetEnabledNode(i);
const size_t nodeNumber = GetEnabledNode(i);
Transform skinningTransform = mActor->GetInverseBindPoseTransform(nodeNumber);
skinningTransform.Multiply(pose->GetModelSpaceTransform(nodeNumber));
skinningMatrices[nodeNumber] = AZ::Matrix3x4::CreateFromTransform(skinningTransform.ToAZTransform());
@@ -396,10 +392,8 @@ namespace EMotionFX
// Update the mesh deformers.
const Skeleton* skeleton = mActor->GetSkeleton();
const uint32 numNodes = mEnabledNodes.GetLength();
for (uint32 i = 0; i < numNodes; ++i)
for (uint16 nodeNr : mEnabledNodes)
{
const uint16 nodeNr = mEnabledNodes[i];
Node* node = skeleton->GetNode(nodeNr);
MeshDeformerStack* stack = mActor->GetMeshDeformerStack(mLODLevel, nodeNr);
if (stack)
@@ -416,10 +410,8 @@ namespace EMotionFX
// Update the mesh morph deformers.
const Skeleton* skeleton = mActor->GetSkeleton();
const uint32 numNodes = mEnabledNodes.GetLength();
for (uint32 i = 0; i < numNodes; ++i)
for (uint16 nodeNr : mEnabledNodes)
{
const uint16 nodeNr = mEnabledNodes[i];
Node* node = skeleton->GetNode(nodeNr);
MeshDeformerStack* stack = mActor->GetMeshDeformerStack(mLODLevel, nodeNr);
if (stack)
@@ -448,7 +440,7 @@ namespace EMotionFX
GetActorManager().GetScheduler()->RecursiveRemoveActorInstance(root);
// add the attachment
mAttachments.Add(attachment);
mAttachments.emplace_back(attachment);
ActorInstance* attachmentActorInstance = attachment->GetAttachmentActorInstance();
if (attachmentActorInstance)
{
@@ -465,27 +457,23 @@ namespace EMotionFX
}
// try to find the attachment number for a given actor instance
uint32 ActorInstance::FindAttachmentNr(ActorInstance* actorInstance)
size_t ActorInstance::FindAttachmentNr(ActorInstance* actorInstance)
{
// for all attachments
const uint32 numAttachments = mAttachments.GetLength();
for (uint32 i = 0; i < numAttachments; ++i)
const auto foundAttachment = AZStd::find_if(mAttachments.begin(), mAttachments.end(), [actorInstance](const Attachment* attachment)
{
if (mAttachments[i]->GetAttachmentActorInstance() == actorInstance)
{
return i;
}
}
return attachment->GetAttachmentActorInstance() == actorInstance;
});
return MCORE_INVALIDINDEX32;
return foundAttachment != mAttachments.end() ? AZStd::distance(mAttachments.begin(), foundAttachment) : InvalidIndex;
}
// remove an attachment by actor instance pointer
bool ActorInstance::RemoveAttachment(ActorInstance* actorInstance, bool delFromMem)
{
// try to find the attachment
const uint32 attachmentNr = FindAttachmentNr(actorInstance);
if (attachmentNr == MCORE_INVALIDINDEX32)
const size_t attachmentNr = FindAttachmentNr(actorInstance);
if (attachmentNr == InvalidIndex)
{
return false;
}
@@ -496,9 +484,9 @@ namespace EMotionFX
}
// remove an attachment
void ActorInstance::RemoveAttachment(uint32 nr, bool delFromMem)
void ActorInstance::RemoveAttachment(size_t nr, bool delFromMem)
{
MCORE_ASSERT(nr < mAttachments.GetLength());
MCORE_ASSERT(nr < mAttachments.size());
// first remove the current attachment tree from the scheduler
ActorInstance* root = FindAttachmentRoot();
@@ -528,7 +516,7 @@ namespace EMotionFX
}
// remove it from the attachment list
mAttachments.Remove(nr);
mAttachments.erase(AZStd::next(begin(mAttachments), nr));
// and re-add the root to the scheduler
GetActorManager().GetScheduler()->RecursiveInsertActorInstance(root, 0);
@@ -544,9 +532,9 @@ namespace EMotionFX
void ActorInstance::RemoveAllAttachments(bool delFromMem)
{
// keep removing the last attachment until there are none left
while (mAttachments.GetLength())
while (mAttachments.size())
{
RemoveAttachment(mAttachments.GetLength() - 1, delFromMem);
RemoveAttachment(mAttachments.size() - 1, delFromMem);
}
}
@@ -554,30 +542,28 @@ namespace EMotionFX
void ActorInstance::UpdateDependencies()
{
// get rid of existing dependencies
mDependencies.Clear();
mDependencies.clear();
// add the main dependency
Actor::Dependency mainDependency;
mainDependency.mActor = mActor;
mainDependency.mAnimGraph = (mAnimGraphInstance) ? mAnimGraphInstance->GetAnimGraph() : nullptr;
mDependencies.Add(mainDependency);
mDependencies.emplace_back(mainDependency);
// add all dependencies stored inside the actor
const uint32 numDependencies = mActor->GetNumDependencies();
for (uint32 i = 0; i < numDependencies; ++i)
const size_t numDependencies = mActor->GetNumDependencies();
for (size_t i = 0; i < numDependencies; ++i)
{
mDependencies.Add(*mActor->GetDependency(i));
mDependencies.emplace_back(*mActor->GetDependency(i));
}
}
// set the attachment matrices
void ActorInstance::UpdateAttachments()
{
// update all attachments
const uint32 numAttachments = mAttachments.GetLength();
for (uint32 i = 0; i < numAttachments; ++i)
for (Attachment* attachment : mAttachments)
{
mAttachments[i]->Update();
attachment->Update();
}
}
@@ -608,7 +594,7 @@ namespace EMotionFX
}
// update the bounding volume
void ActorInstance::UpdateBounds(uint32 geomLODLevel, EBoundsType boundsType, uint32 itemFrequency)
void ActorInstance::UpdateBounds(size_t geomLODLevel, EBoundsType boundsType, uint32 itemFrequency)
{
// depending on the bounding volume update type
switch (boundsType)
@@ -654,11 +640,10 @@ namespace EMotionFX
const Skeleton* skeleton = mActor->GetSkeleton();
// for all nodes, encapsulate the world space positions
uint16 nodeNr;
const uint32 numNodes = GetNumEnabledNodes();
for (uint32 i = 0; i < numNodes; i += nodeFrequency)
const size_t numNodes = GetNumEnabledNodes();
for (size_t i = 0; i < numNodes; i += nodeFrequency)
{
nodeNr = GetEnabledNode(i);
const uint16 nodeNr = GetEnabledNode(i);
if (skeleton->GetNode(nodeNr)->GetIncludeInBoundsCalc())
{
outResult->AddPoint(pose->GetWorldSpaceTransform(nodeNr).mPosition);
@@ -667,7 +652,7 @@ namespace EMotionFX
}
// calculate the AABB that contains all world space vertices of all meshes
void ActorInstance::CalcMeshBasedAabb(uint32 geomLODLevel, AZ::Aabb* outResult, uint32 vertexFrequency)
void ActorInstance::CalcMeshBasedAabb(size_t geomLODLevel, AZ::Aabb* outResult, uint32 vertexFrequency)
{
*outResult = AZ::Aabb::CreateNull();
@@ -675,8 +660,8 @@ namespace EMotionFX
const Skeleton* skeleton = mActor->GetSkeleton();
// for all nodes, encapsulate the world space positions
const uint32 numNodes = GetNumEnabledNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = GetNumEnabledNodes();
for (size_t i = 0; i < numNodes; ++i)
{
const uint16 nodeNr = GetEnabledNode(i);
Node* node = skeleton->GetNode(nodeNr);
@@ -732,8 +717,8 @@ namespace EMotionFX
// apply all morph targets
//bool allZero = true;
const uint32 numTargets = morphSetup->GetNumMorphTargets();
for (uint32 i = 0; i < numTargets; ++i)
const size_t numTargets = morphSetup->GetNumMorphTargets();
for (size_t i = 0; i < numTargets; ++i)
{
// get the morph target
MorphTarget* morphTarget = morphSetup->GetMorphTarget(i);
@@ -753,32 +738,19 @@ namespace EMotionFX
morphTarget->Apply(this, weight);
}
}
/*
// enable or disable all morph deformers if the weights are all zero
const uint32 numNodes = mActor->GetNumNodes();
for (uint32 n=0; n<numNodes; ++n)
{
Node* node = mActor->GetNode(n);
MeshDeformerStack* stack = node->GetMeshDeformerStack( mGeometryLODLevel ).GetPointer();
if (stack == nullptr)
continue;
stack->EnableAllDeformersByType( MorphMeshDeformer::TYPE_ID, !allZero );
}*/
}
//---------------------
// check intersection with a ray, but don't get the intersection point or closest intersecting node
Node* ActorInstance::IntersectsCollisionMesh(uint32 lodLevel, const MCore::Ray& ray) const
Node* ActorInstance::IntersectsCollisionMesh(size_t lodLevel, const MCore::Ray& ray) const
{
const Skeleton* skeleton = mActor->GetSkeleton();
const Pose* pose = mTransformData->GetCurrentPose();
// for all nodes
const uint32 numNodes = GetNumEnabledNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = GetNumEnabledNodes();
for (size_t i = 0; i < numNodes; ++i)
{
const uint16 nodeNr = GetEnabledNode(i);
@@ -806,7 +778,7 @@ namespace EMotionFX
return nullptr;
}
Node* ActorInstance::IntersectsCollisionMesh(uint32 lodLevel, const MCore::Ray& ray, AZ::Vector3* outIntersect, AZ::Vector3* outNormal, AZ::Vector2* outUV, float* outBaryU, float* outBaryV, uint32* outIndices) const
Node* ActorInstance::IntersectsCollisionMesh(size_t lodLevel, const MCore::Ray& ray, AZ::Vector3* outIntersect, AZ::Vector3* outNormal, AZ::Vector2* outUV, float* outBaryU, float* outBaryV, uint32* outIndices) const
{
Node* closestNode = nullptr;
AZ::Vector3 point;
@@ -821,11 +793,10 @@ namespace EMotionFX
const Pose* pose = mTransformData->GetCurrentPose();
// check all nodes
uint16 nodeNr;
const uint32 numNodes = GetNumEnabledNodes();
for (uint32 i = 0; i < numNodes; i++)
const size_t numNodes = GetNumEnabledNodes();
for (size_t i = 0; i < numNodes; i++)
{
nodeNr = GetEnabledNode(i);
const uint16 nodeNr = GetEnabledNode(i);
Node* curNode = skeleton->GetNode(nodeNr);
Mesh* mesh = mActor->GetMesh(lodLevel, nodeNr);
if (mesh == nullptr)
@@ -921,17 +892,16 @@ namespace EMotionFX
}
// check intersection with a ray, but don't get the intersection point or closest intersecting node
Node* ActorInstance::IntersectsMesh(uint32 lodLevel, const MCore::Ray& ray) const
Node* ActorInstance::IntersectsMesh(size_t lodLevel, const MCore::Ray& ray) const
{
const Pose* pose = mTransformData->GetCurrentPose();
const Skeleton* skeleton = mActor->GetSkeleton();
// for all nodes
uint16 nodeNr;
const uint32 numNodes = GetNumEnabledNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = GetNumEnabledNodes();
for (size_t i = 0; i < numNodes; ++i)
{
nodeNr = GetEnabledNode(i);
const uint16 nodeNr = GetEnabledNode(i);
Node* node = skeleton->GetNode(nodeNr);
// check if there is a mesh for this node
@@ -972,7 +942,7 @@ namespace EMotionFX
}
// intersection test that returns the closest intersection
Node* ActorInstance::IntersectsMesh(uint32 lodLevel, const MCore::Ray& ray, AZ::Vector3* outIntersect, AZ::Vector3* outNormal, AZ::Vector2* outUV, float* outBaryU, float* outBaryV, uint32* outIndices) const
Node* ActorInstance::IntersectsMesh(size_t lodLevel, const MCore::Ray& ray, AZ::Vector3* outIntersect, AZ::Vector3* outNormal, AZ::Vector2* outUV, float* outBaryU, float* outBaryV, uint32* outIndices) const
{
Node* closestNode = nullptr;
AZ::Vector3 point;
@@ -987,11 +957,10 @@ namespace EMotionFX
const Skeleton* skeleton = mActor->GetSkeleton();
// check all nodes
uint16 nodeNr;
const uint32 numNodes = GetNumEnabledNodes();
for (uint32 i = 0; i < numNodes; i++)
const size_t numNodes = GetNumEnabledNodes();
for (size_t i = 0; i < numNodes; i++)
{
nodeNr = GetEnabledNode(i);
const uint16 nodeNr = GetEnabledNode(i);
Node* curNode = skeleton->GetNode(nodeNr);
Mesh* mesh = mActor->GetMesh(lodLevel, nodeNr);
if (mesh == nullptr)
@@ -1089,7 +1058,7 @@ namespace EMotionFX
void ActorInstance::EnableNode(uint16 nodeIndex)
{
// if this node already is at an enabled state, do nothing
if (mEnabledNodes.Contains(nodeIndex))
if (AZStd::find(begin(mEnabledNodes), end(mEnabledNodes), nodeIndex) != end(mEnabledNodes))
{
return;
}
@@ -1098,23 +1067,23 @@ namespace EMotionFX
// find the location where to insert (as the flattened hierarchy needs to be preserved in the array)
bool found = false;
uint32 curNode = nodeIndex;
size_t curNode = nodeIndex;
do
{
// get the parent of the current node
uint32 parentIndex = skeleton->GetNode(curNode)->GetParentIndex();
if (parentIndex != MCORE_INVALIDINDEX32)
size_t parentIndex = skeleton->GetNode(curNode)->GetParentIndex();
if (parentIndex != InvalidIndex)
{
const uint32 parentArrayIndex = mEnabledNodes.Find(static_cast<uint16>(parentIndex));
if (parentArrayIndex != MCORE_INVALIDINDEX32)
const auto parentArrayIter = AZStd::find(begin(mEnabledNodes), end(mEnabledNodes), static_cast<uint16>(parentIndex));
if (parentArrayIter != end(mEnabledNodes))
{
if (parentArrayIndex + 1 >= mEnabledNodes.GetLength())
if (parentArrayIter + 1 == end(mEnabledNodes))
{
mEnabledNodes.Add(nodeIndex);
mEnabledNodes.emplace_back(nodeIndex);
}
else
{
mEnabledNodes.Insert(parentArrayIndex + 1, nodeIndex);
mEnabledNodes.emplace(parentArrayIter + 1, nodeIndex);
}
found = true;
}
@@ -1125,7 +1094,7 @@ namespace EMotionFX
}
else // if we're dealing with a root node, insert it in the front of the array
{
mEnabledNodes.Insert(0, nodeIndex);
mEnabledNodes.emplace(AZStd::next(begin(mEnabledNodes), 0), nodeIndex);
found = true;
}
} while (found == false);
@@ -1135,31 +1104,31 @@ namespace EMotionFX
void ActorInstance::DisableNode(uint16 nodeIndex)
{
// try to remove the node from the array
mEnabledNodes.RemoveByValue(nodeIndex);
const auto it = AZStd::find(begin(mEnabledNodes), end(mEnabledNodes), nodeIndex);
if (it != end(mEnabledNodes))
{
mEnabledNodes.erase(it);
}
}
// enable all nodes
void ActorInstance::EnableAllNodes()
{
const uint32 numNodes = mActor->GetNumNodes();
mEnabledNodes.Resize(numNodes);
for (uint32 i = 0; i < numNodes; ++i)
{
mEnabledNodes[i] = static_cast<uint16>(i);
}
mEnabledNodes.resize(mActor->GetNumNodes());
std::iota(mEnabledNodes.begin(), mEnabledNodes.end(), 0);
}
// disable all nodes
void ActorInstance::DisableAllNodes()
{
mEnabledNodes.Clear();
mEnabledNodes.clear();
}
// change the skeletal LOD level
void ActorInstance::SetSkeletalLODLevelNodeFlags(uint32 level)
void ActorInstance::SetSkeletalLODLevelNodeFlags(size_t level)
{
// make sure the lod level is in range of 0..31
const uint32 newLevel = MCore::Clamp<uint32>(level, 0, 31);
// make sure the lod level is in range of 0..63
const size_t newLevel = MCore::Clamp<size_t>(level, 0, 63);
// if the lod level is the same as it currently is, do nothing
if (newLevel == mLODLevel)
@@ -1170,8 +1139,8 @@ namespace EMotionFX
Skeleton* skeleton = mActor->GetSkeleton();
// change the state of all nodes that need state changes
const uint32 numNodes = GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
Node* node = skeleton->GetNode(i);
@@ -1194,7 +1163,7 @@ namespace EMotionFX
}
}
void ActorInstance::SetLODLevel(uint32 level)
void ActorInstance::SetLODLevel(size_t level)
{
m_requestedLODLevel = level;
}
@@ -1208,14 +1177,7 @@ namespace EMotionFX
SetSkeletalLODLevelNodeFlags(m_requestedLODLevel);
// Make sure the LOD level is valid and update it.
mLODLevel = MCore::Clamp<uint32>(m_requestedLODLevel, 0, mActor->GetNumLODLevels() - 1);
/*// update the transform data
MorphSetup* morphSetup = mActor->GetMorphSetup(mLODLevel);
if (morphSetup)
mTransformData->SetNumMorphWeights( morphSetup->GetNumMorphTargets() );
else
mTransformData->SetNumMorphWeights( 0 );*/
mLODLevel = MCore::Clamp<size_t>(m_requestedLODLevel, 0, mActor->GetNumLODLevels() - 1);
}
}
@@ -1224,8 +1186,8 @@ namespace EMotionFX
{
// change the state of all nodes that need state changes
Skeleton* skeleton = mActor->GetSkeleton();
const uint32 numNodes = skeleton->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = skeleton->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
Node* node = skeleton->GetNode(i);
@@ -1242,15 +1204,15 @@ namespace EMotionFX
}
// calculate the number of disabled nodes for a given skeletal lod level
uint32 ActorInstance::CalcNumDisabledNodes(uint32 skeletalLODLevel) const
size_t ActorInstance::CalcNumDisabledNodes(size_t skeletalLODLevel) const
{
uint32 numDisabledNodes = 0;
Skeleton* skeleton = mActor->GetSkeleton();
const Skeleton* skeleton = mActor->GetSkeleton();
// get the number of nodes and iterate through them
const uint32 numNodes = GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
// get the current node
Node* node = skeleton->GetNode(i);
@@ -1266,14 +1228,14 @@ namespace EMotionFX
}
// calculate the number of skeletal LOD levels
uint32 ActorInstance::CalcNumSkeletalLODLevels() const
size_t ActorInstance::CalcNumSkeletalLODLevels() const
{
uint32 numSkeletalLODLevels = 0;
size_t numSkeletalLODLevels = 0;
// iterate over all skeletal LOD levels
uint32 currentNumDisabledNodes = 0;
uint32 previousNumDisabledNodes = MCORE_INVALIDINDEX32;
for (uint32 i = 0; i < 32; ++i)
size_t currentNumDisabledNodes = 0;
size_t previousNumDisabledNodes = InvalidIndex;
for (size_t i = 0; i < sizeof(size_t) * 8; ++i)
{
// get the number of disabled nodes in the current skeletal LOD level
currentNumDisabledNodes = CalcNumDisabledNodes(i);
@@ -1356,7 +1318,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 +1327,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 +1358,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;
}
@@ -1481,7 +1443,7 @@ namespace EMotionFX
return mMotionSystem;
}
uint32 ActorInstance::GetLODLevel() const
size_t ActorInstance::GetLODLevel() const
{
return mLODLevel;
}
@@ -1587,12 +1549,12 @@ namespace EMotionFX
m_aabb = aabb;
}
uint32 ActorInstance::GetNumAttachments() const
size_t ActorInstance::GetNumAttachments() const
{
return mAttachments.GetLength();
return mAttachments.size();
}
Attachment* ActorInstance::GetAttachment(uint32 nr) const
Attachment* ActorInstance::GetAttachment(size_t nr) const
{
return mAttachments[nr];
}
@@ -1612,12 +1574,12 @@ namespace EMotionFX
return mSelfAttachment;
}
uint32 ActorInstance::GetNumDependencies() const
size_t ActorInstance::GetNumDependencies() const
{
return mDependencies.GetLength();
return mDependencies.size();
}
Actor::Dependency* ActorInstance::GetDependency(uint32 nr)
Actor::Dependency* ActorInstance::GetDependency(size_t nr)
{
return &mDependencies[nr];
}
@@ -1779,10 +1741,9 @@ namespace EMotionFX
SetIsVisible(isVisible);
// recurse to all child attachments
const uint32 numAttachments = mAttachments.GetLength();
for (uint32 i = 0; i < numAttachments; ++i)
for (Attachment* attachment : mAttachments)
{
mAttachments[i]->GetAttachmentActorInstance()->RecursiveSetIsVisible(isVisible);
attachment->GetAttachmentActorInstance()->RecursiveSetIsVisible(isVisible);
}
}
@@ -1846,8 +1807,8 @@ namespace EMotionFX
}
// Iterate down the chain of attachments.
const AZ::u32 numAttachments = GetNumAttachments();
for (AZ::u32 i = 0; i < numAttachments; ++i)
const size_t numAttachments = GetNumAttachments();
for (size_t i = 0; i < numAttachments; ++i)
{
if (GetAttachment(i)->GetAttachmentActorInstance()->RecursiveHasAttachment(attachmentInstance))
{
@@ -181,7 +181,7 @@ namespace EMotionFX
* @param[in] skeletalLODLevel The skeletal LOD level to calculate the number of disabled nodes for.
* @return The number of disabled nodes for the given skeletal LOD level.
*/
uint32 CalcNumDisabledNodes(uint32 skeletalLODLevel) const;
size_t CalcNumDisabledNodes(size_t skeletalLODLevel) const;
/**
* Calculate the number of used skeletal LOD levels. Each actor instance alsways has 32 skeletal LOD levels while in most cases
@@ -189,7 +189,7 @@ namespace EMotionFX
* relative to the previous LOD level.
* @return The number of actually used skeletal LOD levels.
*/
uint32 CalcNumSkeletalLODLevels() const;
size_t CalcNumSkeletalLODLevels() const;
/**
* Get the current used geometry and skeletal detail level.
@@ -199,13 +199,13 @@ namespace EMotionFX
* are needed.
* @result The current LOD level.
*/
uint32 GetLODLevel() const;
size_t GetLODLevel() const;
/**
* Set the current geometry and skeletal detail level, where 0 is the highest detail.
* @param level The LOD level. Values higher than [GetNumGeometryLODLevels()-1] will be clamped to the maximum LOD.
*/
void SetLODLevel(uint32 level);
void SetLODLevel(size_t level);
//--------------------------------
@@ -423,7 +423,7 @@ namespace EMotionFX
* 4th vertex will be included in the bounds calculation, so only processing 25% of the total number of vertices. The same goes for
* node based bounds, but then it will process every 4th node. Of course higher values produce less accurate results, but are faster to process.
*/
void UpdateBounds(uint32 geomLODLevel, EBoundsType boundsType = BOUNDS_NODE_BASED, uint32 itemFrequency = 1);
void UpdateBounds(size_t geomLODLevel, EBoundsType boundsType = BOUNDS_NODE_BASED, uint32 itemFrequency = 1);
/**
* Update the base static axis aligned bounding box shape.
@@ -465,7 +465,7 @@ namespace EMotionFX
* @param vertexFrequency This includes every "vertexFrequency"-th vertex. So for example a value of 2 would skip every second vertex and
* so will process half of the vertices. A value of 4 would process only each 4th vertex, etc.
*/
void CalcMeshBasedAabb(uint32 geomLODLevel, AZ::Aabb* outResult, uint32 vertexFrequency = 1);
void CalcMeshBasedAabb(size_t geomLODLevel, AZ::Aabb* outResult, uint32 vertexFrequency = 1);
/**
* Get the axis aligned bounding box.
@@ -568,7 +568,7 @@ namespace EMotionFX
* When you set this to false, it will not be deleted from memory, but only removed from the array of attachments
* that is stored locally inside this actor instance.
*/
void RemoveAttachment(uint32 nr, bool delFromMem = true);
void RemoveAttachment(size_t nr, bool delFromMem = true);
/**
* Remove all attachments from this actor instance.
@@ -593,20 +593,20 @@ namespace EMotionFX
* @result Returns the attachment number, in range of [0..GetNumAttachments()-1], or MCORE_INVALIDINDEX32 when no attachment
* using the specified actor instance can be found.
*/
uint32 FindAttachmentNr(ActorInstance* actorInstance);
size_t FindAttachmentNr(ActorInstance* actorInstance);
/**
* Get the number of attachments that have been added to this actor instance.
* @result The number of attachments added to this actor instance.
*/
uint32 GetNumAttachments() const;
size_t GetNumAttachments() const;
/**
* Get a specific attachment.
* @param nr The attachment number, which must be in range of [0..GetNumAttachments()-1].
* @result A pointer to the attachment.
*/
Attachment* GetAttachment(uint32 nr) const;
Attachment* GetAttachment(size_t nr) const;
/**
* Check whether this actor instance also is an attachment or not.
@@ -664,14 +664,14 @@ namespace EMotionFX
* Get the number of dependencies that this actor instance has on other actors.
* @result The number of dependencies.
*/
uint32 GetNumDependencies() const;
size_t GetNumDependencies() const;
/**
* Get a given dependency.
* @param nr The dependency number to get, which must be in range of [0..GetNumDependencies()].
* @result A pointer to the dependency.
*/
Actor::Dependency* GetDependency(uint32 nr);
Actor::Dependency* GetDependency(size_t nr);
/**
* Get the morph setup instance.
@@ -692,7 +692,7 @@ namespace EMotionFX
* @param ray The ray to check.
* @return A pointer to the node we detected the first intersection with (doesn't have to be the closest), or nullptr when no intersection found.
*/
Node* IntersectsCollisionMesh(uint32 lodLevel, const MCore::Ray& ray) const;
Node* IntersectsCollisionMesh(size_t lodLevel, const MCore::Ray& ray) const;
/**
* Check for an intersection between the collision mesh of this actor and a given ray, and calculate the closest intersection point.
@@ -711,7 +711,7 @@ namespace EMotionFX
* A value of nullptr is allowed, which will skip storing the resulting triangle indices.
* @return A pointer to the node we detected the closest intersection with, or nullptr when no intersection found.
*/
Node* IntersectsCollisionMesh(uint32 lodLevel, const MCore::Ray& ray, AZ::Vector3* outIntersect, AZ::Vector3* outNormal = nullptr, AZ::Vector2* outUV = nullptr, float* outBaryU = nullptr, float* outBaryV = nullptr, uint32* outIndices = nullptr) const;
Node* IntersectsCollisionMesh(size_t lodLevel, const MCore::Ray& ray, AZ::Vector3* outIntersect, AZ::Vector3* outNormal = nullptr, AZ::Vector2* outUV = nullptr, float* outBaryU = nullptr, float* outBaryV = nullptr, uint32* outIndices = nullptr) const;
/**
* Check for an intersection between the real mesh (if present) of this actor and a given ray.
@@ -721,7 +721,7 @@ namespace EMotionFX
* @param ray The ray to test with.
* @return Returns a pointer to itself when an intersection occurred, or nullptr when no intersection found.
*/
Node* IntersectsMesh(uint32 lodLevel, const MCore::Ray& ray) const;
Node* IntersectsMesh(size_t lodLevel, const MCore::Ray& ray) const;
/**
* Checks for an intersection between the real mesh (if present) of this actor and a given ray.
@@ -741,7 +741,7 @@ namespace EMotionFX
* A value of nullptr is allowed, which will skip storing the resulting triangle indices.
* @return A pointer to the node we detected the closest intersection with, or nullptr when no intersection found.
*/
Node* IntersectsMesh(uint32 lodLevel, const MCore::Ray& ray, AZ::Vector3* outIntersect, AZ::Vector3* outNormal = nullptr, AZ::Vector2* outUV = nullptr, float* outBaryU = nullptr, float* outBaryV = nullptr, uint32* outStartIndex = nullptr) const;
Node* IntersectsMesh(size_t lodLevel, const MCore::Ray& ray, AZ::Vector3* outIntersect, AZ::Vector3* outNormal = nullptr, AZ::Vector2* outUV = nullptr, float* outBaryU = nullptr, float* outBaryV = nullptr, uint32* outStartIndex = nullptr) const;
void SetRagdoll(Physics::Ragdoll* ragdoll);
RagdollInstance* GetRagdollInstance() const;
@@ -788,20 +788,20 @@ namespace EMotionFX
* Get direct access to the array of enabled nodes.
* @result A read only reference to the array of enabled nodes. The values inside of this array are the node numbers of the enabled nodes.
*/
MCORE_INLINE const MCore::Array<uint16>& GetEnabledNodes() const { return mEnabledNodes; }
MCORE_INLINE const AZStd::vector<uint16>& GetEnabledNodes() const { return mEnabledNodes; }
/**
* Get the number of enabled nodes inside this actor instance.
* @result The number of nodes that have been enabled and are being updated.
*/
MCORE_INLINE uint32 GetNumEnabledNodes() const { return mEnabledNodes.GetLength(); }
MCORE_INLINE size_t GetNumEnabledNodes() const { return mEnabledNodes.size(); }
/**
* Get the node number of a given enabled node.
* @param index An index in the array of enabled nodes. This must be in range of [0..GetNumEnabledNodes()-1].
* @result The node number, which relates to Actor::GetNode( returnValue ).
*/
MCORE_INLINE uint16 GetEnabledNode(uint32 index) const { return mEnabledNodes[index]; }
MCORE_INLINE uint16 GetEnabledNode(size_t index) const { return mEnabledNodes[index]; }
/**
* Enable all nodes inside the actor instance.
@@ -856,7 +856,7 @@ namespace EMotionFX
float GetMotionSamplingTimer() const;
float GetMotionSamplingRate() const;
MCORE_INLINE uint32 GetNumNodes() const { return mActor->GetSkeleton()->GetNumNodes(); }
MCORE_INLINE size_t GetNumNodes() const { return mActor->GetSkeleton()->GetNumNodes(); }
void UpdateVisualizeScale(); // not automatically called on creation for performance reasons (this method relatively is slow as it updates all meshes)
float GetVisualizeScale() const;
@@ -873,10 +873,10 @@ namespace EMotionFX
Transform mParentWorldTransform = Transform::CreateIdentity();
Transform mTrajectoryDelta = Transform::CreateIdentityWithZeroScale();
MCore::Array<Attachment*> mAttachments; /**< The attachments linked to this actor instance. */
MCore::Array<Actor::Dependency> mDependencies; /**< The actor dependencies, which specify which Actor objects this instance is dependent on. */
AZStd::vector<Attachment*> mAttachments; /**< The attachments linked to this actor instance. */
AZStd::vector<Actor::Dependency> mDependencies; /**< The actor dependencies, which specify which Actor objects this instance is dependent on. */
MorphSetupInstance* mMorphSetup; /**< The morph setup instance. */
MCore::Array<uint16> mEnabledNodes; /**< The list of nodes that are enabled. */
AZStd::vector<uint16> mEnabledNodes; /**< The list of nodes that are enabled. */
Actor* mActor; /**< A pointer to the parent actor where this is an instance from. */
ActorInstance* mAttachedTo; /**< Specifies the actor where this actor is attached to, or nullptr when it is no attachment. */
@@ -892,8 +892,8 @@ namespace EMotionFX
float mMotionSamplingRate; /**< The motion sampling rate in seconds, where 0.1 would mean to update 10 times per second. A value of 0 or lower means to update every frame. */
float mMotionSamplingTimer; /**< The time passed since the last time we sampled motions/anim graphs. */
float mVisualizeScale; /**< Some visualization scale factor when rendering for example normals, to be at a nice size, relative to the character. */
uint32 mLODLevel; /**< The current LOD level, where 0 is the highest detail. */
uint32 m_requestedLODLevel; /**< Requested LOD level. The actual LOD level will be updated as soon as all transforms for the requested LOD level are ready. */
size_t mLODLevel; /**< The current LOD level, where 0 is the highest detail. */
size_t m_requestedLODLevel; /**< Requested LOD level. The actual LOD level will be updated as soon as all transforms for the requested LOD level are ready. */
uint32 mBoundsUpdateItemFreq; /**< The bounds update item counter step size. A value of 1 means every vertex/node, a value of 2 means every second vertex/node, etc. */
uint32 mID; /**< The unique identification number for the actor instance. */
uint32 mThreadIndex; /**< The thread index. This specifies the thread number this actor instance is being processed in. */
@@ -1002,7 +1002,7 @@ namespace EMotionFX
* are needed.
* @param level The skeletal detail LOD level. Values higher than 31 will be automatically clamped to 31.
*/
void SetSkeletalLODLevelNodeFlags(uint32 level);
void SetSkeletalLODLevelNodeFlags(size_t level);
/*
* Update the LOD level in case a change was requested.
@@ -27,17 +27,13 @@ namespace EMotionFX
{
mScheduler = nullptr;
// set memory categories
mActorInstances.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORMANAGER);
mRootActorInstances.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORMANAGER);
// setup the default scheduler
SetScheduler(MultiThreadScheduler::Create());
// reserve memory
m_actors.reserve(512);
mActorInstances.Reserve(1024);
mRootActorInstances.Reserve(1024);
mActorInstances.reserve(1024);
mRootActorInstances.reserve(1024);
}
@@ -79,8 +75,8 @@ namespace EMotionFX
void ActorManager::UnregisterAllActorInstances()
{
LockActorInstances();
mActorInstances.Clear();
mRootActorInstances.Clear();
mActorInstances.clear();
mRootActorInstances.clear();
if (mScheduler)
{
mScheduler->Clear();
@@ -104,8 +100,8 @@ namespace EMotionFX
mScheduler = scheduler;
// adjust all visibility flags to false for all actor instances
const uint32 numActorInstances = mActorInstances.GetLength();
for (uint32 i = 0; i < numActorInstances; ++i)
const size_t numActorInstances = mActorInstances.size();
for (size_t i = 0; i < numActorInstances; ++i)
{
mActorInstances[i]->SetIsVisible(false);
}
@@ -120,7 +116,7 @@ namespace EMotionFX
LockActors();
// check if we already registered
if (FindActorIndex(actor.get()) != MCORE_INVALIDINDEX32)
if (FindActorIndex(actor.get()) != InvalidIndex)
{
MCore::LogWarning("EMotionFX::ActorManager::RegisterActor() - The actor at location 0x%x has already been registered as actor, most likely already by the LoadActor of the importer.", actor.get());
UnlockActors();
@@ -139,7 +135,7 @@ namespace EMotionFX
{
LockActorInstances();
mActorInstances.Add(actorInstance);
mActorInstances.emplace_back(actorInstance);
UpdateActorInstanceStatus(actorInstance, false);
UnlockActorInstances();
@@ -172,38 +168,38 @@ namespace EMotionFX
// find the leader actor record for a given actor
uint32 ActorManager::FindActorIndex(Actor* actor) const
size_t ActorManager::FindActorIndex(Actor* actor) const
{
const auto found = AZStd::find_if(m_actors.begin(), m_actors.end(), [actor](const AZStd::shared_ptr<Actor>& a)
{
return a.get() == actor;
});
return (found != m_actors.end()) ? static_cast<uint32>(AZStd::distance(m_actors.begin(), found)) : MCORE_INVALIDINDEX32;
return (found != m_actors.end()) ? AZStd::distance(m_actors.begin(), found) : InvalidIndex;
}
// find the actor for a given actor name
uint32 ActorManager::FindActorIndexByName(const char* actorName) const
size_t ActorManager::FindActorIndexByName(const char* actorName) const
{
const auto found = AZStd::find_if(m_actors.begin(), m_actors.end(), [actorName](const AZStd::shared_ptr<Actor>& a)
{
return a->GetNameString() == actorName;
});
return (found != m_actors.end()) ? static_cast<uint32>(AZStd::distance(m_actors.begin(), found)) : MCORE_INVALIDINDEX32;
return (found != m_actors.end()) ? AZStd::distance(m_actors.begin(), found) : InvalidIndex;
}
// find the actor for a given actor filename
uint32 ActorManager::FindActorIndexByFileName(const char* filename) const
size_t ActorManager::FindActorIndexByFileName(const char* filename) const
{
const auto found = AZStd::find_if(m_actors.begin(), m_actors.end(), [filename](const AZStd::shared_ptr<Actor>& a)
{
return a->GetFileNameString() == filename;
});
return (found != m_actors.end()) ? static_cast<uint32>(AZStd::distance(m_actors.begin(), found)) : MCORE_INVALIDINDEX32;
return (found != m_actors.end()) ? AZStd::distance(m_actors.begin(), found) : InvalidIndex;
}
@@ -213,55 +209,28 @@ namespace EMotionFX
LockActorInstances();
// get the number of actor instances and iterate through them
const uint32 numActorInstances = mActorInstances.GetLength();
for (uint32 i = 0; i < numActorInstances; ++i)
{
if (mActorInstances[i] == actorInstance)
{
UnlockActorInstances();
return true;
}
}
// in case we haven't found it return failure
const bool foundActor = AZStd::find(begin(mActorInstances), end(mActorInstances), actorInstance) != end(mActorInstances);
UnlockActorInstances();
return false;
return foundActor;
}
// find the given actor instance inside the actor manager and return its index
uint32 ActorManager::FindActorInstanceIndex(ActorInstance* actorInstance) const
size_t ActorManager::FindActorInstanceIndex(ActorInstance* actorInstance) const
{
// get the number of actor instances and iterate through them
const uint32 numActorInstances = mActorInstances.GetLength();
for (uint32 i = 0; i < numActorInstances; ++i)
{
if (mActorInstances[i] == actorInstance)
{
return i;
}
}
// in case we haven't found it return failure
return MCORE_INVALIDINDEX32;
const auto foundActorInstance = AZStd::find(begin(mActorInstances), end(mActorInstances), actorInstance);
return foundActorInstance != end(mActorInstances) ? AZStd::distance(begin(mActorInstances), foundActorInstance) : InvalidIndex;
}
// find the actor instance by the identification number
ActorInstance* ActorManager::FindActorInstanceByID(uint32 id) const
{
// get the number of actor instances and iterate through them
const uint32 numActorInstances = mActorInstances.GetLength();
for (uint32 i = 0; i < numActorInstances; ++i)
const auto foundActorInstance = AZStd::find_if(begin(mActorInstances), end(mActorInstances), [id](const ActorInstance* actorInstance)
{
if (mActorInstances[i]->GetID() == id)
{
return mActorInstances[i];
}
}
// in case we haven't found it return failure
return nullptr;
return actorInstance->GetID() == id;
});
return foundActorInstance != end(mActorInstances) ? *foundActorInstance : nullptr;
}
@@ -288,7 +257,7 @@ namespace EMotionFX
// unregister a given actor instance
void ActorManager::UnregisterActorInstance(uint32 nr)
void ActorManager::UnregisterActorInstance(size_t nr)
{
UnregisterActorInstance(mActorInstances[nr]);
}
@@ -349,15 +318,18 @@ namespace EMotionFX
if (actorInstance->GetAttachedTo() == nullptr)
{
// make sure it's in the root list
if (mRootActorInstances.Contains(actorInstance) == false)
if (AZStd::find(begin(mRootActorInstances), end(mRootActorInstances), actorInstance) == end(mRootActorInstances))
{
mRootActorInstances.Add(actorInstance);
mRootActorInstances.emplace_back(actorInstance);
}
}
else // no root actor instance
{
// remove it from the root list
mRootActorInstances.RemoveByValue(actorInstance);
if (const auto it = AZStd::find(begin(mRootActorInstances), end(mRootActorInstances), actorInstance); it != end(mRootActorInstances))
{
mRootActorInstances.erase(it);
}
mScheduler->RecursiveRemoveActorInstance(actorInstance);
}
@@ -374,10 +346,16 @@ namespace EMotionFX
LockActorInstances();
// remove the actor instance from the list
mActorInstances.RemoveByValue(instance);
if (const auto it = AZStd::find(begin(mActorInstances), end(mActorInstances), instance); it != end(mActorInstances))
{
mActorInstances.erase(it);
}
// remove it from the list of roots, if it is in there
mRootActorInstances.RemoveByValue(instance);
if (const auto it = AZStd::find(begin(mRootActorInstances), end(mRootActorInstances), instance); it != end(mRootActorInstances))
{
mRootActorInstances.erase(it);
}
// remove it from the schedule
mScheduler->RemoveActorInstance(instance);
@@ -410,13 +388,13 @@ namespace EMotionFX
}
Actor* ActorManager::GetActor(uint32 nr) const
Actor* ActorManager::GetActor(size_t nr) const
{
return m_actors[nr].get();
}
const MCore::Array<ActorInstance*>& ActorManager::GetActorInstanceArray() const
const AZStd::vector<ActorInstance*>& ActorManager::GetActorInstanceArray() const
{
return mActorInstances;
}
@@ -14,7 +14,7 @@
#include "BaseObject.h"
#include "MemoryCategories.h"
#include <MCore/Source/MultiThreadManager.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/smart_ptr/weak_ptr.h>
@@ -67,7 +67,7 @@ namespace EMotionFX
* This does not include the clones that have been optionally created.
* @result The number of registered actors.
*/
MCORE_INLINE uint32 GetNumActors() const { return static_cast<uint32>(m_actors.size()); }
MCORE_INLINE size_t GetNumActors() const { return m_actors.size(); }
/**
* Get a given actor.
@@ -77,7 +77,7 @@ namespace EMotionFX
* @param nr The actor number, which must be in range of [0..GetNumActors()-1].
* @result A reference to the actor object that contains the array of Actor objects.
*/
Actor* GetActor(uint32 nr) const;
Actor* GetActor(size_t nr) const;
/**
* Find the given actor by name.
@@ -99,7 +99,7 @@ namespace EMotionFX
* @param actor The actor object you once passed to RegisterActor.
* @result Returns the actor number, which is in range of [0..GetNumActors()-1], or returns MCORE_INVALIDINDEX32 when not found.
*/
uint32 FindActorIndex(Actor* actor) const;
size_t FindActorIndex(Actor* actor) const;
/**
* Find the actor number for a given actor name.
@@ -107,7 +107,7 @@ namespace EMotionFX
* @param actorName The name of the actor.
* @result Returns the actor number, which is in range of [0..GetNumActors()-1], or returns MCORE_INVALIDINDEX32 when not found.
*/
uint32 FindActorIndexByName(const char* actorName) const;
size_t FindActorIndexByName(const char* actorName) const;
/**
* Find the actor number for a given actor filename.
@@ -115,7 +115,7 @@ namespace EMotionFX
* @param filename The filename of the actor.
* @result Returns the actor number, which is in range of [0..GetNumActors()-1], or returns MCORE_INVALIDINDEX32 when not found.
*/
uint32 FindActorIndexByFileName(const char* filename) const;
size_t FindActorIndexByFileName(const char* filename) const;
// register the actor instance
void RegisterActorInstance(ActorInstance* actorInstance);
@@ -124,27 +124,27 @@ namespace EMotionFX
* Get the number of actor instances that currently are registered.
* @result The number of registered actor instances.
*/
MCORE_INLINE uint32 GetNumActorInstances() const { return mActorInstances.GetLength(); }
MCORE_INLINE size_t GetNumActorInstances() const { return mActorInstances.size(); }
/**
* Get a given registered actor instance.
* @param nr The actor instance number, which must be in range of [0..GetNumActorInstances()-1].
* @result A pointer to the actor instance.
*/
MCORE_INLINE ActorInstance* GetActorInstance(uint32 nr) const { return mActorInstances[nr]; }
MCORE_INLINE ActorInstance* GetActorInstance(size_t nr) const { return mActorInstances[nr]; }
/**
* Get the array of actor instances.
* @result The const reference to the actor instance array.
*/
const MCore::Array<ActorInstance*>& GetActorInstanceArray() const;
const AZStd::vector<ActorInstance*>& GetActorInstanceArray() const;
/**
* Find the given actor instance inside the actor manager and return its index.
* @param actorInstance A pointer to the actor instance to be searched.
* @result The actor instance index for the actor manager, MCORE_INVALIDINDEX32 in case the actor instance hasn't been found.
*/
uint32 FindActorInstanceIndex(ActorInstance* actorInstance) const;
size_t FindActorInstanceIndex(ActorInstance* actorInstance) const;
/**
* Find an actor instance inside the actor manager by its id.
@@ -192,7 +192,7 @@ namespace EMotionFX
* When you delete an actor instance, it automatically will unregister itself from the manager.
* @param nr The actor instance number, which has to be in range of [0..GetNumActorInstances()-1].
*/
void UnregisterActorInstance(uint32 nr);
void UnregisterActorInstance(size_t nr);
/**
* Get the number of root actor instances.
@@ -201,7 +201,7 @@ namespace EMotionFX
* horse is the root attachment instance.
* @result Returns the number of root actor instances.
*/
MCORE_INLINE uint32 GetNumRootActorInstances() const { return mRootActorInstances.GetLength(); }
MCORE_INLINE size_t GetNumRootActorInstances() const { return mRootActorInstances.size(); }
/**
* Get a given root actor instance.
@@ -211,7 +211,7 @@ namespace EMotionFX
* @param nr The root actor instance number, which must be in range of [0..GetNumRootActorInstances()-1].
* @result A pointer to the actor instance that is a root.
*/
MCORE_INLINE ActorInstance* GetRootActorInstance(uint32 nr) const { return mRootActorInstances[nr]; }
MCORE_INLINE ActorInstance* GetRootActorInstance(size_t nr) const { return mRootActorInstances[nr]; }
/**
* Get the currently used actor update scheduler.
@@ -255,9 +255,9 @@ namespace EMotionFX
void UnlockActors();
private:
MCore::Array<ActorInstance*> mActorInstances; /**< The registered actor instances. */
AZStd::vector<ActorInstance*> mActorInstances; /**< The registered actor instances. */
AZStd::vector<AZStd::shared_ptr<Actor>> m_actors; /**< The registered actors. */
MCore::Array<ActorInstance*> mRootActorInstances; /**< Root actor instances (roots of all attachment chains). */
AZStd::vector<ActorInstance*> mRootActorInstances; /**< Root actor instances (roots of all attachment chains). */
ActorUpdateScheduler* mScheduler; /**< The update scheduler to use. */
MCore::MutexRecursive mActorLock; /**< The multithread lock for touching the actors array. */
MCore::MutexRecursive mActorInstanceLock; /**< The multithread lock for touching the actor instances array. */
@@ -63,14 +63,14 @@ namespace EMotionFX
* @param actorInstance The actor instance to insert.
* @param startStep An offset in the schedule where to start trying to insert the actor instances.
*/
virtual void RecursiveInsertActorInstance(ActorInstance* actorInstance, uint32 startStep = 0) = 0;
virtual void RecursiveInsertActorInstance(ActorInstance* actorInstance, size_t startStep = 0) = 0;
/**
* Recursively remove an actor instance and its attachments from the schedule.
* @param actorInstance The actor instance to remove.
* @param startStep An offset in the schedule where to start trying to remove from.
*/
virtual void RecursiveRemoveActorInstance(ActorInstance* actorInstance, uint32 startStep = 0) = 0;
virtual void RecursiveRemoveActorInstance(ActorInstance* actorInstance, size_t startStep = 0) = 0;
/**
* Remove a single actor instance from the schedule. This will not remove its attachments.
@@ -78,16 +78,16 @@ namespace EMotionFX
* @param startStep An offset in the schedule where to start trying to remove from.
* @result Returns the offset in the schedule where the actor instance was removed.
*/
virtual uint32 RemoveActorInstance(ActorInstance* actorInstance, uint32 startStep = 0) = 0;
virtual size_t RemoveActorInstance(ActorInstance* actorInstance, size_t startStep = 0) = 0;
uint32 GetNumUpdatedActorInstances() const { return mNumUpdated.GetValue(); }
uint32 GetNumVisibleActorInstances() const { return mNumVisible.GetValue(); }
uint32 GetNumSampledActorInstances() const { return mNumSampled.GetValue(); }
size_t GetNumUpdatedActorInstances() const { return mNumUpdated.GetValue(); }
size_t GetNumVisibleActorInstances() const { return mNumVisible.GetValue(); }
size_t GetNumSampledActorInstances() const { return mNumSampled.GetValue(); }
protected:
MCore::AtomicUInt32 mNumUpdated;
MCore::AtomicUInt32 mNumVisible;
MCore::AtomicUInt32 mNumSampled;
MCore::AtomicSizeT mNumUpdated;
MCore::AtomicSizeT mNumVisible;
MCore::AtomicSizeT mNumSampled;
/**
* The constructor.
@@ -7,6 +7,7 @@
*/
#include <AzCore/Debug/Timer.h>
#include <AzCore/std/numeric.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/Utils.h>
@@ -36,9 +37,7 @@ namespace EMotionFX
AnimGraph::AnimGraph()
: mGameControllerSettings(aznew AnimGraphGameControllerSettings())
{
mNodes.SetMemoryCategory(EMFX_MEMCATEGORY_ANIMGRAPH);
mID = MCore::GetIDGenerator().GenerateID();
mID = aznumeric_caster(MCore::GetIDGenerator().GenerateID());
mDirtyFlag = false;
mAutoUnregister = true;
mRetarget = false;
@@ -50,7 +49,7 @@ namespace EMotionFX
#endif // EMFX_DEVELOPMENT_BUILD
// reserve some memory
mNodes.Reserve(1024);
mNodes.reserve(1024);
// automatically register the anim graph
GetAnimGraphManager().AddAnimGraph(this);
@@ -346,12 +345,12 @@ namespace EMotionFX
AZStd::string AnimGraph::GenerateNodeName(const AZStd::unordered_set<AZStd::string>& nameReserveList, const char* prefix) const
{
AZStd::string result;
uint32 number = 0;
size_t number = 0;
bool found = false;
while (found == false)
{
// build the string
result = AZStd::string::format("%s%d", prefix, number++);
result = AZStd::string::format("%s%zu", prefix, number++);
// if there is no such state machine yet
if (!RecursiveFindNodeByName(result.c_str()) && nameReserveList.find(result) == nameReserveList.end())
@@ -364,7 +363,7 @@ namespace EMotionFX
}
uint32 AnimGraph::RecursiveCalcNumNodes() const
size_t AnimGraph::RecursiveCalcNumNodes() const
{
return mRootStateMachine->RecursiveCalcNumNodes();
}
@@ -387,9 +386,9 @@ namespace EMotionFX
}
void AnimGraph::RecursiveCalcStatistics(Statistics& outStatistics, AnimGraphNode* animGraphNode, uint32 currentHierarchyDepth) const
void AnimGraph::RecursiveCalcStatistics(Statistics& outStatistics, AnimGraphNode* animGraphNode, size_t currentHierarchyDepth) const
{
outStatistics.m_maxHierarchyDepth = MCore::Max<uint32>(currentHierarchyDepth, outStatistics.m_maxHierarchyDepth);
outStatistics.m_maxHierarchyDepth = AZStd::max(currentHierarchyDepth, outStatistics.m_maxHierarchyDepth);
// Are we dealing with a state machine? If yes, increase the number of transitions, states etc. in the statistics.
if (azrtti_typeid(animGraphNode) == azrtti_typeid<AnimGraphStateMachine>())
@@ -397,12 +396,12 @@ namespace EMotionFX
AnimGraphStateMachine* stateMachine = static_cast<AnimGraphStateMachine*>(animGraphNode);
outStatistics.m_numStateMachines++;
const AZ::u32 numTransitions = static_cast<AZ::u32>(stateMachine->GetNumTransitions());
const size_t numTransitions = stateMachine->GetNumTransitions();
outStatistics.m_numTransitions += numTransitions;
outStatistics.m_numStates += stateMachine->GetNumChildNodes();
for (uint32 i = 0; i < numTransitions; ++i)
for (size_t i = 0; i < numTransitions; ++i)
{
AnimGraphStateTransition* transition = stateMachine->GetTransition(i);
@@ -411,12 +410,12 @@ namespace EMotionFX
outStatistics.m_numWildcardTransitions++;
}
outStatistics.m_numTransitionConditions += static_cast<uint32>(transition->GetNumConditions());
outStatistics.m_numTransitionConditions += transition->GetNumConditions();
}
}
const uint32 numChildNodes = animGraphNode->GetNumChildNodes();
for (uint32 i = 0; i < numChildNodes; ++i)
const size_t numChildNodes = animGraphNode->GetNumChildNodes();
for (size_t i = 0; i < numChildNodes; ++i)
{
RecursiveCalcStatistics(outStatistics, animGraphNode->GetChildNode(i), currentHierarchyDepth + 1);
}
@@ -424,7 +423,7 @@ namespace EMotionFX
// recursively calculate the number of node connections
uint32 AnimGraph::RecursiveCalcNumNodeConnections() const
size_t AnimGraph::RecursiveCalcNumNodeConnections() const
{
return mRootStateMachine->RecursiveCalcNumNodeConnections();
}
@@ -493,7 +492,7 @@ namespace EMotionFX
// get a pointer to the given node group
AnimGraphNodeGroup* AnimGraph::GetNodeGroup(uint32 index) const
AnimGraphNodeGroup* AnimGraph::GetNodeGroup(size_t index) const
{
return mNodeGroups[index];
}
@@ -516,19 +515,13 @@ namespace EMotionFX
// find the node group index by name
uint32 AnimGraph::FindNodeGroupIndexByName(const char* groupName) const
size_t AnimGraph::FindNodeGroupIndexByName(const char* groupName) const
{
const size_t numNodeGroups = mNodeGroups.size();
for (size_t i = 0; i < numNodeGroups; ++i)
const auto foundNodeGroup = AZStd::find_if(begin(mNodeGroups), end(mNodeGroups), [groupName](const AnimGraphNodeGroup* nodeGroup)
{
// compare the node names and return the index in case they are equal
if (mNodeGroups[i]->GetNameString() == groupName)
{
return static_cast<uint32>(i);
}
}
return MCORE_INVALIDINDEX32;
return nodeGroup->GetNameString() == groupName;
});
return foundNodeGroup != end(mNodeGroups) ? AZStd::distance(begin(mNodeGroups), foundNodeGroup) : InvalidIndex;
}
@@ -540,7 +533,7 @@ namespace EMotionFX
// remove the node group at the given index from the anim graph
void AnimGraph::RemoveNodeGroup(uint32 index, bool delFromMem)
void AnimGraph::RemoveNodeGroup(size_t index, bool delFromMem)
{
// destroy the object
if (delFromMem)
@@ -571,9 +564,9 @@ namespace EMotionFX
// get the number of node groups
uint32 AnimGraph::GetNumNodeGroups() const
size_t AnimGraph::GetNumNodeGroups() const
{
return static_cast<uint32>(mNodeGroups.size());
return mNodeGroups.size();
}
@@ -628,7 +621,7 @@ namespace EMotionFX
mRootStateMachine->RecursiveCollectNodesOfType(nodeType, outNodes);
}
void AnimGraph::RecursiveCollectTransitionConditionsOfType(const AZ::TypeId& conditionType, MCore::Array<AnimGraphTransitionCondition*>* outConditions) const
void AnimGraph::RecursiveCollectTransitionConditionsOfType(const AZ::TypeId& conditionType, AZStd::vector<AnimGraphTransitionCondition*>* outConditions) const
{
mRootStateMachine->RecursiveCollectTransitionConditionsOfType(conditionType, outConditions);
}
@@ -718,15 +711,15 @@ namespace EMotionFX
MCore::LockGuard lock(mLock);
// assign the index and add it to the objects array
object->SetObjectIndex(static_cast<uint32>(mObjects.size()));
object->SetObjectIndex(mObjects.size());
mObjects.push_back(object);
// if it's a node, add it to the nodes array as well
if (azrtti_istypeof<AnimGraphNode>(object))
{
AnimGraphNode* node = static_cast<AnimGraphNode*>(object);
node->SetNodeIndex(mNodes.GetLength());
mNodes.Add(node);
node->SetNodeIndex(mNodes.size());
mNodes.emplace_back(node);
}
// create a unique data for this added object in the animgraph instances as well
@@ -763,10 +756,10 @@ namespace EMotionFX
if (azrtti_istypeof<AnimGraphNode>(object))
{
AnimGraphNode* node = static_cast<AnimGraphNode*>(object);
const uint32 nodeIndex = node->GetNodeIndex();
const size_t nodeIndex = node->GetNodeIndex();
const uint32 numNodes = mNodes.GetLength();
for (uint32 i = nodeIndex + 1; i < numNodes; ++i)
const size_t numNodes = mNodes.size();
for (size_t i = nodeIndex + 1; i < numNodes; ++i)
{
AnimGraphNode* curNode = mNodes[i];
MCORE_ASSERT(i == curNode->GetNodeIndex());
@@ -774,38 +767,32 @@ namespace EMotionFX
}
// remove the object from the array
mNodes.Remove(nodeIndex);
mNodes.erase(AZStd::next(begin(mNodes), nodeIndex));
}
}
// reserve space for a given amount of objects
void AnimGraph::ReserveNumObjects(uint32 numObjects)
void AnimGraph::ReserveNumObjects(size_t numObjects)
{
mObjects.reserve(numObjects);
}
// reserve space for a given amount of nodes
void AnimGraph::ReserveNumNodes(uint32 numNodes)
void AnimGraph::ReserveNumNodes(size_t numNodes)
{
mNodes.Reserve(numNodes);
mNodes.reserve(numNodes);
}
// Calculate number of motion nodes in the graph
uint32 AnimGraph::CalcNumMotionNodes() const
size_t AnimGraph::CalcNumMotionNodes() const
{
const uint32 numNodes = mNodes.GetLength();
uint32 numMotionNodes = 0;
for (uint32 i = 0; i < numNodes; ++i)
return AZStd::accumulate(begin(mNodes), end(mNodes), size_t{0}, [](size_t total, const AnimGraphNode* node)
{
if (azrtti_istypeof<AnimGraphMotionNode>(mNodes[i]))
{
numMotionNodes++;
}
}
return numMotionNodes;
return total + azrtti_istypeof<AnimGraphMotionNode>(node);
});
}
@@ -833,7 +820,7 @@ namespace EMotionFX
// decrease internal attribute indices by one, for values higher than the given parameter
void AnimGraph::DecreaseInternalAttributeIndices(uint32 decreaseEverythingHigherThan)
void AnimGraph::DecreaseInternalAttributeIndices(size_t decreaseEverythingHigherThan)
{
for (AnimGraphObject* object : mObjects)
{
@@ -1029,11 +1016,9 @@ namespace EMotionFX
void AnimGraph::RemoveInvalidConnections(bool logWarnings)
{
// Iterate over all nodes
const AZ::u32 numNodes = mNodes.GetLength();
for (AZ::u32 i = 0; i < numNodes; ++i)
for (AnimGraphNode* node : mNodes)
{
AnimGraphNode* node = mNodes[i];
for (AZ::u32 c = 0; c < node->GetNumConnections();)
for (size_t c = 0; c < node->GetNumConnections();)
{
BlendTreeConnection* connection = node->GetConnection(c);
if (!connection->GetSourceNode()) // Invalid source node.
@@ -20,7 +20,7 @@
#include <EMotionFX/Source/Parameter/GroupParameter.h>
#include <EMotionFX/Source/Parameter/ValueParameter.h>
#include <MCore/Source/Distance.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
namespace EMotionFX
{
@@ -65,31 +65,31 @@ namespace EMotionFX
AnimGraphStateTransition* RecursiveFindTransitionById(AnimGraphConnectionId transitionId) const;
void RecursiveCollectNodesOfType(const AZ::TypeId& nodeType, AZStd::vector<AnimGraphNode*>* outNodes) const; // note: outNodes is NOT cleared internally, nodes are added to the array
void RecursiveCollectTransitionConditionsOfType(const AZ::TypeId& conditionType, MCore::Array<AnimGraphTransitionCondition*>* outConditions) const; // note: outNodes is NOT cleared internally, nodes are added to the array
void RecursiveCollectTransitionConditionsOfType(const AZ::TypeId& conditionType, AZStd::vector<AnimGraphTransitionCondition*>* outConditions) const; // note: outNodes is NOT cleared internally, nodes are added to the array
// Collects all objects of type and/or derived type
void RecursiveCollectObjectsOfType(const AZ::TypeId& objectType, AZStd::vector<AnimGraphObject*>& outObjects);
void RecursiveCollectObjectsAffectedBy(AnimGraph* animGraph, AZStd::vector<AnimGraphObject*>& outObjects);
uint32 RecursiveCalcNumNodes() const;
size_t RecursiveCalcNumNodes() const;
struct Statistics
{
AZ::u32 m_maxHierarchyDepth;
AZ::u32 m_numStateMachines;
AZ::u32 m_numStates;
AZ::u32 m_numTransitions;
AZ::u32 m_numWildcardTransitions;
AZ::u32 m_numTransitionConditions;
size_t m_maxHierarchyDepth;
size_t m_numStateMachines;
size_t m_numStates;
size_t m_numTransitions;
size_t m_numWildcardTransitions;
size_t m_numTransitionConditions;
Statistics();
};
void RecursiveCalcStatistics(Statistics& outStatistics) const;
uint32 RecursiveCalcNumNodeConnections() const;
size_t RecursiveCalcNumNodeConnections() const;
void DecreaseInternalAttributeIndices(uint32 decreaseEverythingHigherThan);
void DecreaseInternalAttributeIndices(size_t decreaseEverythingHigherThan);
AZStd::string GenerateNodeName(const AZStd::unordered_set<AZStd::string>& nameReserveList, const char* prefix = "Node") const;
@@ -313,13 +313,13 @@ namespace EMotionFX
* Get the number of node groups.
* @result The number of node groups.
*/
uint32 GetNumNodeGroups() const;
size_t GetNumNodeGroups() const;
/**
* Get a pointer to the given node group.
* @param index The node group index, which must be in range of [0..GetNumNodeGroups()-1].
*/
AnimGraphNodeGroup* GetNodeGroup(uint32 index) const;
AnimGraphNodeGroup* GetNodeGroup(size_t index) const;
/**
* Find a node group based on the name and return a pointer.
@@ -333,7 +333,7 @@ namespace EMotionFX
* @param groupName The group name to search for.
* @result The index of the node group inside this anim graph, MCORE_INVALIDINDEX32 in case the node group wasn't found.
*/
uint32 FindNodeGroupIndexByName(const char* groupName) const;
size_t FindNodeGroupIndexByName(const char* groupName) const;
/**
* Add the given node group.
@@ -346,7 +346,7 @@ namespace EMotionFX
* @param index The node group index to remove. This value must be in range of [0..GetNumNodeGroups()-1].
* @param delFromMem Set to true (default) when you wish to also delete the specified group from memory.
*/
void RemoveNodeGroup(uint32 index, bool delFromMem = true);
void RemoveNodeGroup(size_t index, bool delFromMem = true);
/**
* Remove all node groups.
@@ -377,14 +377,14 @@ namespace EMotionFX
void AddObject(AnimGraphObject* object); // registers the object in the array and modifies the object's object index value
void RemoveObject(AnimGraphObject* object); // doesn't actually remove it from memory, just removes it from the list
uint32 GetNumObjects() const { return static_cast<uint32>(mObjects.size()); }
AnimGraphObject* GetObject(uint32 index) const { return mObjects[index]; }
void ReserveNumObjects(uint32 numObjects);
size_t GetNumObjects() const { return mObjects.size(); }
AnimGraphObject* GetObject(size_t index) const { return mObjects[index]; }
void ReserveNumObjects(size_t numObjects);
uint32 GetNumNodes() const { return mNodes.GetLength(); }
AnimGraphNode* GetNode(uint32 index) const { return mNodes[index]; }
void ReserveNumNodes(uint32 numNodes);
uint32 CalcNumMotionNodes() const;
size_t GetNumNodes() const { return mNodes.size(); }
AnimGraphNode* GetNode(size_t index) const { return mNodes[index]; }
void ReserveNumNodes(size_t numNodes);
size_t CalcNumMotionNodes() const;
size_t GetNumAnimGraphInstances() const { return m_animGraphInstances.size(); }
AnimGraphInstance* GetAnimGraphInstance(size_t index) const { return m_animGraphInstances[index]; }
@@ -405,7 +405,7 @@ namespace EMotionFX
void RemoveInvalidConnections(bool logWarnings=false);
private:
void RecursiveCalcStatistics(Statistics& outStatistics, AnimGraphNode* animGraphNode, uint32 currentHierarchyDepth = 0) const;
void RecursiveCalcStatistics(Statistics& outStatistics, AnimGraphNode* animGraphNode, size_t currentHierarchyDepth = 0) const;
void OnRetargetingEnabledChanged();
@@ -417,7 +417,7 @@ namespace EMotionFX
AZStd::unordered_map<AZStd::string_view, size_t> m_valueParameterIndexByName; /**< Cached version of parameter index by name to accelerate lookups. */
AZStd::vector<AnimGraphNodeGroup*> mNodeGroups;
AZStd::vector<AnimGraphObject*> mObjects;
MCore::Array<AnimGraphNode*> mNodes;
AZStd::vector<AnimGraphNode*> mNodes;
AZStd::vector<AnimGraphInstance*> m_animGraphInstances;
AZStd::string mFileName;
AnimGraphStateMachine* mRootStateMachine;
@@ -53,7 +53,7 @@ namespace EMotionFX
//---------------------------------------------------------------------------------------------------------------------
void AnimGraphPropertyUtils::ReinitJointIndices(const Actor* actor, const AZStd::vector<AZStd::string>& jointNames, AZStd::vector<AZ::u32>& outJointIndices)
void AnimGraphPropertyUtils::ReinitJointIndices(const Actor* actor, const AZStd::vector<AZStd::string>& jointNames, AZStd::vector<size_t>& outJointIndices)
{
const Skeleton* skeleton = actor->GetSkeleton();
const size_t jointCount = jointNames.size();
@@ -68,8 +68,8 @@ namespace EMotionFX
}
bool InitFromString(const AZStd::string& valueString) override { MCORE_UNUSED(valueString); return false; } // unsupported
bool ConvertToString(AZStd::string& outString) const override { MCORE_UNUSED(outString); return false; } // unsupported
uint32 GetClassSize() const override { return sizeof(AttributePose); }
uint32 GetDefaultInterfaceType() const override { return MCore::ATTRIBUTE_INTERFACETYPE_DEFAULT; }
size_t GetClassSize() const override { return sizeof(AttributePose); }
AZ::u32 GetDefaultInterfaceType() const override { return MCore::ATTRIBUTE_INTERFACETYPE_DEFAULT; }
private:
AnimGraphPose* mValue;
@@ -116,8 +116,8 @@ namespace EMotionFX
}
bool InitFromString(const AZStd::string& valueString) override { MCORE_UNUSED(valueString); return false; } // unsupported
bool ConvertToString(AZStd::string& outString) const override { MCORE_UNUSED(outString); return false; } // unsupported
uint32 GetClassSize() const override { return sizeof(AttributeMotionInstance); }
uint32 GetDefaultInterfaceType() const override { return MCore::ATTRIBUTE_INTERFACETYPE_DEFAULT; }
size_t GetClassSize() const override { return sizeof(AttributeMotionInstance); }
AZ::u32 GetDefaultInterfaceType() const override { return MCore::ATTRIBUTE_INTERFACETYPE_DEFAULT; }
private:
MotionInstance* mValue;
@@ -132,7 +132,7 @@ namespace EMotionFX
class AnimGraphPropertyUtils
{
public:
static void ReinitJointIndices(const Actor* actor, const AZStd::vector<AZStd::string>& jointNames, AZStd::vector<AZ::u32>& outJointIndices);
static void ReinitJointIndices(const Actor* actor, const AZStd::vector<AZStd::string>& jointNames, AZStd::vector<size_t>& outJointIndices);
};
} // namespace EMotionFX
@@ -76,12 +76,12 @@ namespace EMotionFX
}
}
void AnimGraphEventBuffer::Reserve(uint32 numEvents)
void AnimGraphEventBuffer::Reserve(size_t numEvents)
{
m_events.reserve(numEvents);
}
void AnimGraphEventBuffer::Resize(uint32 numEvents)
void AnimGraphEventBuffer::Resize(size_t numEvents)
{
m_events.resize(numEvents);
}
@@ -93,12 +93,12 @@ namespace EMotionFX
void AnimGraphEventBuffer::AddAllEventsFrom(const AnimGraphEventBuffer& eventBuffer)
{
const AZ::u32 numEventsToCopy = eventBuffer.GetNumEvents();
const uint32 numPrevEvents = GetNumEvents();
const size_t numEventsToCopy = eventBuffer.GetNumEvents();
const size_t numPrevEvents = GetNumEvents();
Resize(GetNumEvents() + numEventsToCopy);
for (uint32 i = 0; i < numEventsToCopy; ++i)
for (size_t i = 0; i < numEventsToCopy; ++i)
{
SetEvent(numPrevEvents + i, eventBuffer.GetEvent(i));
}
@@ -109,7 +109,7 @@ namespace EMotionFX
m_events.clear();
}
void AnimGraphEventBuffer::SetEvent(uint32 index, const EventInfo& eventInfo)
void AnimGraphEventBuffer::SetEvent(size_t index, const EventInfo& eventInfo)
{
m_events[index] = eventInfo;
}
@@ -38,8 +38,8 @@ namespace EMotionFX
AnimGraphEventBuffer& operator=(const AnimGraphEventBuffer&) = default;
AnimGraphEventBuffer& operator=(AnimGraphEventBuffer&&) = default;
void Reserve(uint32 numEvents);
void Resize(uint32 numEvents);
void Reserve(size_t numEvents);
void Resize(size_t numEvents);
void AddEvent(const EventInfo& newEvent);
void AddAllEventsFrom(const AnimGraphEventBuffer& eventBuffer);
@@ -49,11 +49,11 @@ namespace EMotionFX
m_events.emplace_back(AZStd::forward<Args>(args)...);
}
void SetEvent(uint32 index, const EventInfo& eventInfo);
void SetEvent(size_t index, const EventInfo& eventInfo);
void Clear();
MCORE_INLINE uint32 GetNumEvents() const { return static_cast<uint32>(m_events.size()); }
MCORE_INLINE const EventInfo& GetEvent(uint32 index) const { return m_events[index]; }
MCORE_INLINE size_t GetNumEvents() const { return m_events.size(); }
MCORE_INLINE const EventInfo& GetEvent(size_t index) const { return m_events[index]; }
void TriggerEvents() const;
void UpdateWeights(AnimGraphInstance* animGraphInstance);
@@ -6,6 +6,8 @@
*
*/
#include <AzCore/Math/Crc.h>
#include <AzCore/std/string/string_view.h>
#include <EMotionFX/Source/AnimGraphGameControllerSettings.h>
#include <AzCore/Serialization/SerializeContext.h>
@@ -181,7 +183,7 @@ namespace EMotionFX
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AnimGraphGameControllerSettings::AnimGraphGameControllerSettings()
: m_activePresetIndex(MCORE_INVALIDINDEX32)
: m_activePresetIndex(InvalidIndex)
{
}
@@ -230,50 +232,35 @@ namespace EMotionFX
size_t AnimGraphGameControllerSettings::FindPresetIndexByName(const char* presetName) const
{
const size_t presetCount = m_presets.size();
for (size_t i = 0; i < presetCount; ++i)
const auto foundPreset = AZStd::find_if(begin(m_presets), end(m_presets), [presetName](const Preset* preset)
{
if (m_presets[i]->GetNameString() == presetName)
{
return i;
}
}
// return failure
return MCORE_INVALIDINDEX32;
return preset->GetNameString() == presetName;
});
return foundPreset != end(m_presets) ? AZStd::distance(begin(m_presets), foundPreset) : InvalidIndex;
}
size_t AnimGraphGameControllerSettings::FindPresetIndex(Preset* preset) const
{
const size_t presetCount = m_presets.size();
for (size_t i = 0; i < presetCount; ++i)
{
if (m_presets[i] == preset)
{
return i;
}
}
// return failure
return MCORE_INVALIDINDEX32;
const auto foundPreset = AZStd::find(begin(m_presets), end(m_presets), preset);
return foundPreset != end(m_presets) ? AZStd::distance(begin(m_presets), foundPreset) : InvalidIndex;
}
void AnimGraphGameControllerSettings::SetActivePreset(Preset* preset)
{
m_activePresetIndex = static_cast<AZ::u32>(FindPresetIndex(preset));
m_activePresetIndex = FindPresetIndex(preset);
}
uint32 AnimGraphGameControllerSettings::GetActivePresetIndex() const
size_t AnimGraphGameControllerSettings::GetActivePresetIndex() const
{
if (m_activePresetIndex < m_presets.size())
{
return m_activePresetIndex;
}
return MCORE_INVALIDINDEX32;
return InvalidIndex;
}
@@ -384,6 +371,22 @@ namespace EMotionFX
}
static bool AnimGraphGameControllerSettingsVersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& element)
{
if (element.GetVersion() < 2)
{
constexpr AZStd::string_view activePresetIndex{"activePresetIndex"};
if (AZ::SerializeContext::DataElementNode* presetIndexElement = element.FindSubElement(AZ::Crc32(activePresetIndex)))
{
uint32 value;
presetIndexElement->GetData(value);
presetIndexElement->Convert<AZ::u64>(context);
presetIndexElement->SetData(context, static_cast<AZ::u64>(value));
}
}
return true;
}
void AnimGraphGameControllerSettings::Reflect(AZ::ReflectContext* context)
{
ParameterInfo::Reflect(context);
@@ -398,7 +401,7 @@ namespace EMotionFX
}
serializeContext->Class<AnimGraphGameControllerSettings>()
->Version(1)
->Version(2, &AnimGraphGameControllerSettingsVersionConverter)
->Field("activePresetIndex", &AnimGraphGameControllerSettings::m_activePresetIndex)
->Field("presets", &AnimGraphGameControllerSettings::m_presets)
;
@@ -10,7 +10,7 @@
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/std/string/string.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include <EMotionFX/Source/Allocators.h>
#include <EMotionFX/Source/EMotionFXConfig.h>
@@ -48,12 +48,11 @@ namespace EMotionFX
struct EMFX_API ParameterInfo final
{
AZ_RTTI(AnimGraphGameControllerSettings::ParameterInfo, "{C3220DB3-54FA-4719-80F0-CEAE5859C641}");
AZ_TYPE_INFO(AnimGraphGameControllerSettings::ParameterInfo, "{C3220DB3-54FA-4719-80F0-CEAE5859C641}");
AZ_CLASS_ALLOCATOR_DECL
ParameterInfo();
ParameterInfo(const char* parameterName);
virtual ~ParameterInfo() = default;
static void Reflect(AZ::ReflectContext* context);
@@ -66,12 +65,11 @@ namespace EMotionFX
struct EMFX_API ButtonInfo final
{
AZ_RTTI(AnimGraphGameControllerSettings::ButtonInfo, "{94027445-C44F-4310-9DF2-1A2F39518578}");
AZ_TYPE_INFO(AnimGraphGameControllerSettings::ButtonInfo, "{94027445-C44F-4310-9DF2-1A2F39518578}");
AZ_CLASS_ALLOCATOR_DECL
ButtonInfo();
ButtonInfo(AZ::u32 buttonIndex);
virtual ~ButtonInfo() = default;
static void Reflect(AZ::ReflectContext* context);
@@ -155,7 +153,7 @@ namespace EMotionFX
Preset* GetPreset(size_t index) const;
size_t GetNumPresets() const;
uint32 GetActivePresetIndex() const;
size_t GetActivePresetIndex() const;
Preset* GetActivePreset() const;
void SetActivePreset(Preset* preset);
@@ -166,6 +164,6 @@ namespace EMotionFX
private:
AZStd::vector<Preset*> m_presets;
AZ::u32 m_activePresetIndex;
AZ::u64 m_activePresetIndex;
};
} // namespace EMotionFX
@@ -57,8 +57,6 @@ namespace EMotionFX
mInitSettings = *initSettings;
}
mParamValues.SetMemoryCategory(EMFX_MEMCATEGORY_ANIMGRAPH_INSTANCE);
mObjectFlags.SetMemoryCategory(EMFX_MEMCATEGORY_ANIMGRAPH_INSTANCE);
m_eventHandlersByEventType.resize(EVENT_TYPE_ANIM_GRAPH_INSTANCE_LAST_EVENT - EVENT_TYPE_ANIM_GRAPH_INSTANCE_FIRST_EVENT + 1);
// init the internal attributes (create them)
@@ -145,17 +143,16 @@ namespace EMotionFX
{
if (delFromMem)
{
const uint32 numParams = mParamValues.GetLength();
for (uint32 i = 0; i < numParams; ++i)
for (MCore::Attribute* paramValue : mParamValues)
{
if (mParamValues[i])
if (paramValue)
{
delete mParamValues[i];
delete paramValue;
}
}
}
mParamValues.Clear();
mParamValues.clear();
}
@@ -174,12 +171,12 @@ namespace EMotionFX
}
uint32 AnimGraphInstance::AddInternalAttribute(MCore::Attribute* attribute)
size_t AnimGraphInstance::AddInternalAttribute(MCore::Attribute* attribute)
{
MCore::LockGuard lock(mMutex);
m_internalAttributes.emplace_back(attribute);
return static_cast<uint32>(m_internalAttributes.size() - 1);
return m_internalAttributes.size() - 1;
}
@@ -268,11 +265,11 @@ namespace EMotionFX
RemoveAllParameters(true);
const ValueParameterVector& valueParameters = mAnimGraph->RecursivelyGetValueParameters();
mParamValues.Resize(static_cast<uint32>(valueParameters.size()));
mParamValues.resize(valueParameters.size());
// init the values
const uint32 numParams = mParamValues.GetLength();
for (uint32 i = 0; i < numParams; ++i)
const size_t numParams = mParamValues.size();
for (size_t i = 0; i < numParams; ++i)
{
mParamValues[i] = valueParameters[i]->ConstructDefaultValueAsAttribute();
}
@@ -284,28 +281,27 @@ namespace EMotionFX
{
// check how many parameters we need to add
const ValueParameterVector& valueParameters = mAnimGraph->RecursivelyGetValueParameters();
const int32 numToAdd = static_cast<uint32>(valueParameters.size()) - mParamValues.GetLength();
const ptrdiff_t numToAdd = aznumeric_cast<ptrdiff_t>(valueParameters.size()) - mParamValues.size();
if (numToAdd <= 0)
{
return;
}
// make sure we have the right space pre-allocated
mParamValues.Reserve(static_cast<uint32>(valueParameters.size()));
mParamValues.reserve(valueParameters.size());
// add the remaining parameters
const uint32 startIndex = mParamValues.GetLength();
for (int32 i = 0; i < numToAdd; ++i)
const size_t startIndex = mParamValues.size();
for (ptrdiff_t i = 0; i < numToAdd; ++i)
{
const uint32 index = startIndex + i;
mParamValues.AddEmpty();
mParamValues.GetLast() = valueParameters[index]->ConstructDefaultValueAsAttribute();
const size_t index = startIndex + i;
mParamValues.emplace_back(valueParameters[index]->ConstructDefaultValueAsAttribute());
}
}
// remove a parameter value
void AnimGraphInstance::RemoveParameterValue(uint32 index, bool delFromMem)
void AnimGraphInstance::RemoveParameterValue(size_t index, bool delFromMem)
{
if (delFromMem)
{
@@ -315,12 +311,12 @@ namespace EMotionFX
}
}
mParamValues.Remove(index);
mParamValues.erase(AZStd::next(begin(mParamValues), index));
}
// reinitialize the parameter
void AnimGraphInstance::ReInitParameterValue(uint32 index)
void AnimGraphInstance::ReInitParameterValue(size_t index)
{
if (mParamValues[index])
{
@@ -333,8 +329,8 @@ namespace EMotionFX
void AnimGraphInstance::ReInitParameterValues()
{
const AZ::u32 parameterValueCount = mParamValues.GetLength();
for (AZ::u32 i = 0; i < parameterValueCount; ++i)
const size_t parameterValueCount = mParamValues.size();
for (size_t i = 0; i < parameterValueCount; ++i)
{
ReInitParameterValue(i);
}
@@ -442,8 +438,8 @@ namespace EMotionFX
else
{
// get the number of child nodes, iterate through them and call the function recursively in case we are dealing with a blend tree or another node
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)
{
RecursiveSwitchToEntryState(node->GetChildNode(i));
}
@@ -472,8 +468,8 @@ namespace EMotionFX
}
// get the number of child nodes, iterate through them and call the function recursively
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)
{
RecursiveResetCurrentState(node->GetChildNode(i));
}
@@ -496,28 +492,28 @@ namespace EMotionFX
return nullptr;
}
return mParamValues[static_cast<uint32>(paramIndex.GetValue())];
return mParamValues[paramIndex.GetValue()];
}
// add the last anim graph parameter to this instance
void AnimGraphInstance::AddParameterValue()
{
mParamValues.Add(nullptr);
ReInitParameterValue(mParamValues.GetLength() - 1);
mParamValues.emplace_back(nullptr);
ReInitParameterValue(mParamValues.size() - 1);
}
// add the parameter of the animgraph, at a given index
void AnimGraphInstance::InsertParameterValue(uint32 index)
void AnimGraphInstance::InsertParameterValue(size_t index)
{
mParamValues.Insert(index, nullptr);
mParamValues.emplace(AZStd::next(begin(mParamValues), index), nullptr);
ReInitParameterValue(index);
}
// move the parameter from old index to new index
void AnimGraphInstance::MoveParameterValue(uint32 oldIndex, uint32 newIndex)
void AnimGraphInstance::MoveParameterValue(size_t oldIndex, size_t newIndex)
{
MCore::Attribute* oldAttribute = mParamValues[oldIndex];
@@ -525,18 +521,18 @@ namespace EMotionFX
// otherwise, move to the left of new index
if (oldIndex > newIndex)
{
for (uint32 paramIndex = oldIndex; paramIndex > newIndex; paramIndex--)
for (size_t paramIndex = oldIndex; paramIndex > newIndex; paramIndex--)
{
const uint32 prevIndex = paramIndex - 1;
const size_t prevIndex = paramIndex - 1;
mParamValues[paramIndex] = mParamValues[prevIndex];
}
mParamValues[newIndex] = oldAttribute;
}
else
{
for (uint32 paramIndex = oldIndex; paramIndex < newIndex; paramIndex++)
for (size_t paramIndex = oldIndex; paramIndex < newIndex; paramIndex++)
{
const uint32 nexIndex = paramIndex + 1;
const size_t nexIndex = paramIndex + 1;
mParamValues[paramIndex] = mParamValues[nexIndex];
}
mParamValues[newIndex] = oldAttribute;
@@ -611,7 +607,7 @@ namespace EMotionFX
// find an actor instance based on a parent depth value
ActorInstance* AnimGraphInstance::FindActorInstanceFromParentDepth(uint32 parentDepth) const
ActorInstance* AnimGraphInstance::FindActorInstanceFromParentDepth(size_t parentDepth) const
{
// start with the actor instance this anim graph instance is working on
ActorInstance* curInstance = mActorInstance;
@@ -621,7 +617,7 @@ namespace EMotionFX
}
// repeat until we are at the root
uint32 depth = 1;
size_t depth = 1;
while (curInstance)
{
// get the attachment object
@@ -658,7 +654,7 @@ namespace EMotionFX
void AnimGraphInstance::AddUniqueObjectData()
{
m_uniqueDatas.emplace_back(nullptr);
mObjectFlags.Add(0);
mObjectFlags.emplace_back(0);
}
// remove the given unique data object
@@ -669,14 +665,14 @@ namespace EMotionFX
return;
}
const uint32 index = uniqueData->GetObject()->GetObjectIndex();
const size_t index = uniqueData->GetObject()->GetObjectIndex();
if (delFromMem && m_uniqueDatas[index])
{
m_uniqueDatas[index]->Destroy();
}
m_uniqueDatas.erase(m_uniqueDatas.begin() + index);
mObjectFlags.Remove(index);
mObjectFlags.erase(AZStd::next(begin(mObjectFlags), index));
}
@@ -684,7 +680,7 @@ namespace EMotionFX
{
AnimGraphObjectData* data = m_uniqueDatas[index];
m_uniqueDatas.erase(m_uniqueDatas.begin() + index);
mObjectFlags.Remove(static_cast<uint32>(index));
mObjectFlags.erase(AZStd::next(begin(mObjectFlags), index));
if (delFromMem && data)
{
data->Destroy();
@@ -707,7 +703,7 @@ namespace EMotionFX
}
m_uniqueDatas.clear();
mObjectFlags.Clear();
mObjectFlags.clear();
}
@@ -811,10 +807,10 @@ namespace EMotionFX
// init the hashmap
void AnimGraphInstance::InitUniqueDatas()
{
const uint32 numObjects = mAnimGraph->GetNumObjects();
const size_t numObjects = mAnimGraph->GetNumObjects();
m_uniqueDatas.resize(numObjects);
mObjectFlags.Resize(numObjects);
for (uint32 i = 0; i < numObjects; ++i)
mObjectFlags.resize(numObjects);
for (size_t i = 0; i < numObjects; ++i)
{
m_uniqueDatas[i] = nullptr;
mObjectFlags[i] = 0;
@@ -934,10 +930,9 @@ namespace EMotionFX
// reset all node flags
void AnimGraphInstance::ResetFlagsForAllObjects(uint32 flagsToDisable)
{
const uint32 numObjects = mObjectFlags.GetLength();
for (uint32 i = 0; i < numObjects; ++i)
for (uint32& objectFlag : mObjectFlags)
{
mObjectFlags[i] &= ~flagsToDisable;
objectFlag &= ~flagsToDisable;
}
}
@@ -945,8 +940,8 @@ namespace EMotionFX
// reset all node pose ref counts
void AnimGraphInstance::ResetPoseRefCountsForAllNodes()
{
const uint32 numNodes = mAnimGraph->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = mAnimGraph->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
mAnimGraph->GetNode(i)->ResetPoseRefCount(this);
}
@@ -956,8 +951,8 @@ namespace EMotionFX
// reset all node pose ref counts
void AnimGraphInstance::ResetRefDataRefCountsForAllNodes()
{
const uint32 numNodes = mAnimGraph->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = mAnimGraph->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
mAnimGraph->GetNode(i)->ResetRefDataRefCount(this);
}
@@ -967,7 +962,7 @@ namespace EMotionFX
// reset all node flags
void AnimGraphInstance::ResetFlagsForAllObjects()
{
MCore::MemSet(mObjectFlags.GetPtr(), 0, sizeof(uint32) * mObjectFlags.GetLength());
MCore::MemSet(mObjectFlags.data(), 0, sizeof(uint32) * mObjectFlags.size());
for (AnimGraphInstance* childInstance : m_childAnimGraphInstances)
{
@@ -979,8 +974,8 @@ namespace EMotionFX
// reset flags for all nodes
void AnimGraphInstance::ResetFlagsForAllNodes(uint32 flagsToDisable)
{
const uint32 numNodes = mAnimGraph->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = mAnimGraph->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
AnimGraphNode* node = mAnimGraph->GetNode(i);
mObjectFlags[node->GetObjectIndex()] &= ~flagsToDisable;
@@ -988,8 +983,8 @@ namespace EMotionFX
if (GetEMotionFX().GetIsInEditorMode())
{
// reset all connections
const uint32 numConnections = node->GetNumConnections();
for (uint32 c = 0; c < numConnections; ++c)
const size_t numConnections = node->GetNumConnections();
for (size_t c = 0; c < numConnections; ++c)
{
node->GetConnection(c)->SetIsVisited(false);
}
@@ -1026,7 +1021,7 @@ namespace EMotionFX
AnimGraphObjectData* AnimGraphInstance::FindOrCreateUniqueObjectData(const AnimGraphObject* object)
{
const AZ::u32 objectIndex = object->GetObjectIndex();
const size_t objectIndex = object->GetObjectIndex();
AnimGraphObjectData* uniqueData = m_uniqueDatas[objectIndex];
if (uniqueData)
{
@@ -1064,8 +1059,8 @@ namespace EMotionFX
// init all internal attributes
void AnimGraphInstance::InitInternalAttributes()
{
const uint32 numNodes = mAnimGraph->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = mAnimGraph->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
mAnimGraph->GetNode(i)->InitInternalAttributes(this);
}
@@ -1260,8 +1255,8 @@ namespace EMotionFX
const uint32 threadIndex = mActorInstance->GetThreadIndex();
AnimGraphRefCountedDataPool& refDataPool = GetEMotionFX().GetThreadData(threadIndex)->GetRefCountedDataPool();
const uint32 numNodes = mAnimGraph->GetNumNodes();
for (uint32 i = 0; i < numNodes; ++i)
const size_t numNodes = mAnimGraph->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
const AnimGraphNode* node = mAnimGraph->GetNode(i);
AnimGraphNodeData* nodeData = static_cast<AnimGraphNodeData*>(m_uniqueDatas[node->GetObjectIndex()]);
@@ -1294,7 +1289,7 @@ namespace EMotionFX
}
}
bool AnimGraphInstance::GetParameterValueAsFloat(uint32 paramIndex, float* outValue)
bool AnimGraphInstance::GetParameterValueAsFloat(size_t paramIndex, float* outValue)
{
MCore::AttributeFloat* floatAttribute = GetParameterValueChecked<MCore::AttributeFloat>(paramIndex);
if (floatAttribute)
@@ -1320,7 +1315,7 @@ namespace EMotionFX
return false;
}
bool AnimGraphInstance::GetParameterValueAsBool(uint32 paramIndex, bool* outValue)
bool AnimGraphInstance::GetParameterValueAsBool(size_t paramIndex, bool* outValue)
{
float floatValue;
if (GetParameterValueAsFloat(paramIndex, &floatValue))
@@ -1333,7 +1328,7 @@ namespace EMotionFX
}
bool AnimGraphInstance::GetParameterValueAsInt(uint32 paramIndex, int32* outValue)
bool AnimGraphInstance::GetParameterValueAsInt(size_t paramIndex, int32* outValue)
{
float floatValue;
if (GetParameterValueAsFloat(paramIndex, &floatValue))
@@ -1346,7 +1341,7 @@ namespace EMotionFX
}
bool AnimGraphInstance::GetVector2ParameterValue(uint32 paramIndex, AZ::Vector2* outValue)
bool AnimGraphInstance::GetVector2ParameterValue(size_t paramIndex, AZ::Vector2* outValue)
{
MCore::AttributeVector2* param = GetParameterValueChecked<MCore::AttributeVector2>(paramIndex);
if (param)
@@ -1359,7 +1354,7 @@ namespace EMotionFX
}
bool AnimGraphInstance::GetVector3ParameterValue(uint32 paramIndex, AZ::Vector3* outValue)
bool AnimGraphInstance::GetVector3ParameterValue(size_t paramIndex, AZ::Vector3* outValue)
{
MCore::AttributeVector3* param = GetParameterValueChecked<MCore::AttributeVector3>(paramIndex);
if (param)
@@ -1372,7 +1367,7 @@ namespace EMotionFX
}
bool AnimGraphInstance::GetVector4ParameterValue(uint32 paramIndex, AZ::Vector4* outValue)
bool AnimGraphInstance::GetVector4ParameterValue(size_t paramIndex, AZ::Vector4* outValue)
{
MCore::AttributeVector4* param = GetParameterValueChecked<MCore::AttributeVector4>(paramIndex);
if (param)
@@ -1385,7 +1380,7 @@ namespace EMotionFX
}
bool AnimGraphInstance::GetRotationParameterValue(uint32 paramIndex, AZ::Quaternion* outRotation)
bool AnimGraphInstance::GetRotationParameterValue(size_t paramIndex, AZ::Quaternion* outRotation)
{
MCore::AttributeQuaternion* param = GetParameterValueChecked<MCore::AttributeQuaternion>(paramIndex);
if (param)
@@ -1430,7 +1425,7 @@ namespace EMotionFX
return false;
}
return GetParameterValueAsFloat(static_cast<uint32>(index.GetValue()), outValue);
return GetParameterValueAsFloat(index.GetValue(), outValue);
}
@@ -1442,7 +1437,7 @@ namespace EMotionFX
return false;
}
return GetParameterValueAsBool(static_cast<uint32>(index.GetValue()), outValue);
return GetParameterValueAsBool(index.GetValue(), outValue);
}
@@ -1454,7 +1449,7 @@ namespace EMotionFX
return false;
}
return GetParameterValueAsInt(static_cast<uint32>(index.GetValue()), outValue);
return GetParameterValueAsInt(index.GetValue(), outValue);
}
@@ -1466,7 +1461,7 @@ namespace EMotionFX
return false;
}
return GetVector2ParameterValue(static_cast<uint32>(index.GetValue()), outValue);
return GetVector2ParameterValue(index.GetValue(), outValue);
}
@@ -1478,7 +1473,7 @@ namespace EMotionFX
return false;
}
return GetVector3ParameterValue(static_cast<uint32>(index.GetValue()), outValue);
return GetVector3ParameterValue(index.GetValue(), outValue);
}
@@ -1490,7 +1485,7 @@ namespace EMotionFX
return false;
}
return GetVector4ParameterValue(static_cast<uint32>(index.GetValue()), outValue);
return GetVector4ParameterValue(index.GetValue(), outValue);
}
@@ -1502,7 +1497,7 @@ namespace EMotionFX
return false;
}
return GetRotationParameterValue(static_cast<uint32>(index.GetValue()), outRotation);
return GetRotationParameterValue(index.GetValue(), outRotation);
}
} // namespace EMotionFX
@@ -16,7 +16,7 @@
#include <EMotionFX/Source/BaseObject.h>
#include <EMotionFX/Source/EMotionFXConfig.h>
#include <MCore/Source/Attribute.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include <MCore/Source/Random.h>
@@ -95,28 +95,28 @@ namespace EMotionFX
bool GetVector4ParameterValue(const char* paramName, AZ::Vector4* outValue);
bool GetRotationParameterValue(const char* paramName, AZ::Quaternion* outRotation);
bool GetParameterValueAsFloat(uint32 paramIndex, float* outValue);
bool GetParameterValueAsBool(uint32 paramIndex, bool* outValue);
bool GetParameterValueAsInt(uint32 paramIndex, int32* outValue);
bool GetVector2ParameterValue(uint32 paramIndex, AZ::Vector2* outValue);
bool GetVector3ParameterValue(uint32 paramIndex, AZ::Vector3* outValue);
bool GetVector4ParameterValue(uint32 paramIndex, AZ::Vector4* outValue);
bool GetRotationParameterValue(uint32 paramIndex, AZ::Quaternion* outRotation);
bool GetParameterValueAsFloat(size_t paramIndex, float* outValue);
bool GetParameterValueAsBool(size_t paramIndex, bool* outValue);
bool GetParameterValueAsInt(size_t paramIndex, int32* outValue);
bool GetVector2ParameterValue(size_t paramIndex, AZ::Vector2* outValue);
bool GetVector3ParameterValue(size_t paramIndex, AZ::Vector3* outValue);
bool GetVector4ParameterValue(size_t paramIndex, AZ::Vector4* outValue);
bool GetRotationParameterValue(size_t paramIndex, AZ::Quaternion* outRotation);
void SetMotionSet(MotionSet* motionSet);
void CreateParameterValues();
void AddMissingParameterValues(); // add the missing parameters that the anim graph has to this anim graph instance
void ReInitParameterValue(uint32 index);
void ReInitParameterValue(size_t index);
void ReInitParameterValues();
void RemoveParameterValue(uint32 index, bool delFromMem = true);
void RemoveParameterValue(size_t index, bool delFromMem = true);
void AddParameterValue(); // add the last anim graph parameter to this instance
void InsertParameterValue(uint32 index); // add the parameter of the animgraph, at a given index
void MoveParameterValue(uint32 oldIndex, uint32 newIndex); // move the parameter from old index to new index
void InsertParameterValue(size_t index); // add the parameter of the animgraph, at a given index
void MoveParameterValue(size_t oldIndex, size_t newIndex); // move the parameter from old index to new index
void RemoveAllParameters(bool delFromMem);
template <typename T>
MCORE_INLINE T* GetParameterValueChecked(uint32 index) const
MCORE_INLINE T* GetParameterValueChecked(size_t index) const
{
MCore::Attribute* baseAttrib = mParamValues[index];
if (baseAttrib->GetType() == T::TYPE_ID)
@@ -126,7 +126,7 @@ namespace EMotionFX
return nullptr;
}
MCORE_INLINE MCore::Attribute* GetParameterValue(uint32 index) const { return mParamValues[index]; }
MCORE_INLINE MCore::Attribute* GetParameterValue(size_t index) const { return mParamValues[index]; }
MCore::Attribute* FindParameter(const AZStd::string& name) const;
AZ::Outcome<size_t> FindParameterIndex(const AZStd::string& name) const;
@@ -160,7 +160,7 @@ namespace EMotionFX
void RemoveAllInternalAttributes();
void ReserveInternalAttributes(size_t totalNumInternalAttributes);
void RemoveInternalAttribute(size_t index, bool delFromMem = true); // removes the internal attribute (does not update any indices of other attributes)
uint32 AddInternalAttribute(MCore::Attribute* attribute); // returns the index of the new added attribute
size_t AddInternalAttribute(MCore::Attribute* attribute); // returns the index of the new added attribute
AnimGraphObjectData* FindOrCreateUniqueObjectData(const AnimGraphObject* object);
AnimGraphNodeData* FindOrCreateUniqueNodeData(const AnimGraphNode* node);
@@ -195,7 +195,7 @@ namespace EMotionFX
void SetIsOwnedByRuntime(bool isOwnedByRuntime);
bool GetIsOwnedByRuntime() const;
ActorInstance* FindActorInstanceFromParentDepth(uint32 parentDepth) const;
ActorInstance* FindActorInstanceFromParentDepth(size_t parentDepth) const;
void SetVisualizeScale(float scale);
float GetVisualizeScale() const;
@@ -237,11 +237,11 @@ namespace EMotionFX
void CollectActiveAnimGraphNodes(AZStd::vector<AnimGraphNode*>* outNodes, const AZ::TypeId& nodeType = AZ::TypeId::CreateNull()); // MCORE_INVALIDINDEX32 means all node types
void CollectActiveNetTimeSyncNodes(AZStd::vector<AnimGraphNode*>* outNodes);
MCORE_INLINE uint32 GetObjectFlags(uint32 objectIndex) const { return mObjectFlags[objectIndex]; }
MCORE_INLINE void SetObjectFlags(uint32 objectIndex, uint32 flags) { mObjectFlags[objectIndex] = flags; }
MCORE_INLINE void EnableObjectFlags(uint32 objectIndex, uint32 flagsToEnable) { mObjectFlags[objectIndex] |= flagsToEnable; }
MCORE_INLINE void DisableObjectFlags(uint32 objectIndex, uint32 flagsToDisable) { mObjectFlags[objectIndex] &= ~flagsToDisable; }
MCORE_INLINE void SetObjectFlags(uint32 objectIndex, uint32 flags, bool enabled)
MCORE_INLINE uint32 GetObjectFlags(size_t objectIndex) const { return mObjectFlags[objectIndex]; }
MCORE_INLINE void SetObjectFlags(size_t objectIndex, uint32 flags) { mObjectFlags[objectIndex] = flags; }
MCORE_INLINE void EnableObjectFlags(size_t objectIndex, uint32 flagsToEnable) { mObjectFlags[objectIndex] |= flagsToEnable; }
MCORE_INLINE void DisableObjectFlags(size_t objectIndex, uint32 flagsToDisable) { mObjectFlags[objectIndex] &= ~flagsToDisable; }
MCORE_INLINE void SetObjectFlags(size_t objectIndex, uint32 flags, bool enabled)
{
if (enabled)
{
@@ -252,25 +252,25 @@ namespace EMotionFX
mObjectFlags[objectIndex] &= ~flags;
}
}
MCORE_INLINE bool GetIsObjectFlagEnabled(uint32 objectIndex, uint32 flag) const { return (mObjectFlags[objectIndex] & flag) != 0; }
MCORE_INLINE bool GetIsObjectFlagEnabled(size_t objectIndex, uint32 flag) const { return (mObjectFlags[objectIndex] & flag) != 0; }
MCORE_INLINE bool GetIsOutputReady(uint32 objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_OUTPUT_READY) != 0; }
MCORE_INLINE void SetIsOutputReady(uint32 objectIndex, bool isReady) { SetObjectFlags(objectIndex, OBJECTFLAGS_OUTPUT_READY, isReady); }
MCORE_INLINE bool GetIsOutputReady(size_t objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_OUTPUT_READY) != 0; }
MCORE_INLINE void SetIsOutputReady(size_t objectIndex, bool isReady) { SetObjectFlags(objectIndex, OBJECTFLAGS_OUTPUT_READY, isReady); }
MCORE_INLINE bool GetIsSynced(uint32 objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_SYNCED) != 0; }
MCORE_INLINE void SetIsSynced(uint32 objectIndex, bool isSynced) { SetObjectFlags(objectIndex, OBJECTFLAGS_SYNCED, isSynced); }
MCORE_INLINE bool GetIsSynced(size_t objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_SYNCED) != 0; }
MCORE_INLINE void SetIsSynced(size_t objectIndex, bool isSynced) { SetObjectFlags(objectIndex, OBJECTFLAGS_SYNCED, isSynced); }
MCORE_INLINE bool GetIsResynced(uint32 objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_RESYNC) != 0; }
MCORE_INLINE void SetIsResynced(uint32 objectIndex, bool isResynced) { SetObjectFlags(objectIndex, OBJECTFLAGS_RESYNC, isResynced); }
MCORE_INLINE bool GetIsResynced(size_t objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_RESYNC) != 0; }
MCORE_INLINE void SetIsResynced(size_t objectIndex, bool isResynced) { SetObjectFlags(objectIndex, OBJECTFLAGS_RESYNC, isResynced); }
MCORE_INLINE bool GetIsUpdateReady(uint32 objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_UPDATE_READY) != 0; }
MCORE_INLINE void SetIsUpdateReady(uint32 objectIndex, bool isReady) { SetObjectFlags(objectIndex, OBJECTFLAGS_UPDATE_READY, isReady); }
MCORE_INLINE bool GetIsUpdateReady(size_t objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_UPDATE_READY) != 0; }
MCORE_INLINE void SetIsUpdateReady(size_t objectIndex, bool isReady) { SetObjectFlags(objectIndex, OBJECTFLAGS_UPDATE_READY, isReady); }
MCORE_INLINE bool GetIsTopDownUpdateReady(uint32 objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_TOPDOWNUPDATE_READY) != 0; }
MCORE_INLINE void SetIsTopDownUpdateReady(uint32 objectIndex, bool isReady) { SetObjectFlags(objectIndex, OBJECTFLAGS_TOPDOWNUPDATE_READY, isReady); }
MCORE_INLINE bool GetIsTopDownUpdateReady(size_t objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_TOPDOWNUPDATE_READY) != 0; }
MCORE_INLINE void SetIsTopDownUpdateReady(size_t objectIndex, bool isReady) { SetObjectFlags(objectIndex, OBJECTFLAGS_TOPDOWNUPDATE_READY, isReady); }
MCORE_INLINE bool GetIsPostUpdateReady(uint32 objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_POSTUPDATE_READY) != 0; }
MCORE_INLINE void SetIsPostUpdateReady(uint32 objectIndex, bool isReady) { SetObjectFlags(objectIndex, OBJECTFLAGS_POSTUPDATE_READY, isReady); }
MCORE_INLINE bool GetIsPostUpdateReady(size_t objectIndex) const { return (mObjectFlags[objectIndex] & OBJECTFLAGS_POSTUPDATE_READY) != 0; }
MCORE_INLINE void SetIsPostUpdateReady(size_t objectIndex, bool isReady) { SetObjectFlags(objectIndex, OBJECTFLAGS_POSTUPDATE_READY, isReady); }
const InitSettings& GetInitSettings() const;
const AnimGraphEventBuffer& GetEventBuffer() const;
@@ -302,9 +302,9 @@ namespace EMotionFX
ActorInstance* mActorInstance;
AnimGraphInstance* m_parentAnimGraphInstance; // If this anim graph instance is in a reference node, it will have a parent anim graph instance.
AZStd::vector<AnimGraphInstance*> m_childAnimGraphInstances; // If this anim graph instance contains reference nodes, the anim graph instances will be listed here.
MCore::Array<MCore::Attribute*> mParamValues; // a value for each AnimGraph parameter (the control parameters)
AZStd::vector<MCore::Attribute*> mParamValues; // a value for each AnimGraph parameter (the control parameters)
AZStd::vector<AnimGraphObjectData*> m_uniqueDatas; // unique object data
MCore::Array<uint32> mObjectFlags; // the object flags
AZStd::vector<uint32> mObjectFlags; // the object flags
using EventHandlerVector = AZStd::vector<AnimGraphInstanceEventHandler*>;
AZStd::vector<EventHandlerVector> m_eventHandlersByEventType; /**< The event handler to use to process events organized by EventTypes. */
AZStd::vector<MCore::Attribute*> m_internalAttributes;
@@ -128,8 +128,8 @@ namespace EMotionFX
MCore::LockGuardRecursive lock(mAnimGraphLock);
// find the index of the anim graph and return false in case the pointer is not valid
const uint32 animGraphIndex = FindAnimGraphIndex(animGraph);
if (animGraphIndex == MCORE_INVALIDINDEX32)
const size_t animGraphIndex = FindAnimGraphIndex(animGraph);
if (animGraphIndex == InvalidIndex)
{
return false;
}
@@ -156,8 +156,8 @@ namespace EMotionFX
animGraphInstance->RemoveAllObjectData(true);
// Remove all links to the anim graph instance that will get removed.
const uint32 numActorInstances = GetActorManager().GetNumActorInstances();
for (uint32 i = 0; i < numActorInstances; ++i)
const size_t numActorInstances = GetActorManager().GetNumActorInstances();
for (size_t i = 0; i < numActorInstances; ++i)
{
ActorInstance* actorInstance = GetActorManager().GetActorInstance(i);
if (animGraphInstance == actorInstance->GetAnimGraphInstance())
@@ -182,8 +182,8 @@ namespace EMotionFX
MCore::LockGuardRecursive lock(mAnimGraphInstanceLock);
// find the index of the anim graph instance and return false in case the pointer is not valid
const uint32 instanceIndex = FindAnimGraphInstanceIndex(animGraphInstance);
if (instanceIndex == MCORE_INVALIDINDEX32)
const size_t instanceIndex = FindAnimGraphInstanceIndex(animGraphInstance);
if (instanceIndex == InvalidIndex)
{
return false;
}
@@ -218,33 +218,33 @@ namespace EMotionFX
}
uint32 AnimGraphManager::FindAnimGraphIndex(AnimGraph* animGraph) const
size_t AnimGraphManager::FindAnimGraphIndex(AnimGraph* animGraph) const
{
MCore::LockGuardRecursive lock(mAnimGraphLock);
auto iterator = AZStd::find(mAnimGraphs.begin(), mAnimGraphs.end(), animGraph);
if (iterator == mAnimGraphs.end())
{
return MCORE_INVALIDINDEX32;
return InvalidIndex;
}
const size_t index = iterator - mAnimGraphs.begin();
return static_cast<uint32>(index);
return index;
}
uint32 AnimGraphManager::FindAnimGraphInstanceIndex(AnimGraphInstance* animGraphInstance) const
size_t AnimGraphManager::FindAnimGraphInstanceIndex(AnimGraphInstance* animGraphInstance) const
{
MCore::LockGuardRecursive lock(mAnimGraphInstanceLock);
auto iterator = AZStd::find(mAnimGraphInstances.begin(), mAnimGraphInstances.end(), animGraphInstance);
if (iterator == mAnimGraphInstances.end())
{
return MCORE_INVALIDINDEX32;
return InvalidIndex;
}
const size_t index = iterator - mAnimGraphInstances.begin();
return static_cast<uint32>(index);
return index;
}
@@ -11,7 +11,7 @@
#include "EMotionFXConfig.h"
#include <AzCore/std/containers/vector.h>
#include "BaseObject.h"
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include "AnimGraphObject.h"
#include <MCore/Source/MultiThreadManager.h>
@@ -48,11 +48,11 @@ namespace EMotionFX
bool RemoveAnimGraph(AnimGraph* animGraph, bool delFromMemory = true);
void RemoveAllAnimGraphs(bool delFromMemory = true);
MCORE_INLINE uint32 GetNumAnimGraphs() const { MCore::LockGuardRecursive lock(mAnimGraphLock); return static_cast<uint32>(mAnimGraphs.size()); }
MCORE_INLINE AnimGraph* GetAnimGraph(uint32 index) const { MCore::LockGuardRecursive lock(mAnimGraphLock); return mAnimGraphs[index]; }
MCORE_INLINE size_t GetNumAnimGraphs() const { MCore::LockGuardRecursive lock(mAnimGraphLock); return mAnimGraphs.size(); }
MCORE_INLINE AnimGraph* GetAnimGraph(size_t index) const { MCore::LockGuardRecursive lock(mAnimGraphLock); return mAnimGraphs[index]; }
AnimGraph* GetFirstAnimGraph() const;
uint32 FindAnimGraphIndex(AnimGraph* animGraph) const;
size_t FindAnimGraphIndex(AnimGraph* animGraph) const;
AnimGraph* FindAnimGraphByFileName(const char* filename, bool isTool = true) const;
AnimGraph* FindAnimGraphByID(uint32 animGraphID) const;
@@ -67,7 +67,7 @@ namespace EMotionFX
size_t GetNumAnimGraphInstances() const { MCore::LockGuardRecursive lock(mAnimGraphInstanceLock); return mAnimGraphInstances.size(); }
AnimGraphInstance* GetAnimGraphInstance(size_t index) const { MCore::LockGuardRecursive lock(mAnimGraphInstanceLock); return mAnimGraphInstances[index]; }
uint32 FindAnimGraphInstanceIndex(AnimGraphInstance* animGraphInstance) const;
size_t FindAnimGraphInstanceIndex(AnimGraphInstance* animGraphInstance) const;
void SetAnimGraphVisualizationEnabled(bool enabled);
@@ -156,10 +156,10 @@ namespace EMotionFX
case FUNCTION_EVENT:
{
const EMotionFX::AnimGraphEventBuffer& eventBuffer = animGraphInstance->GetEventBuffer();
const uint32 numEvents = eventBuffer.GetNumEvents();
const size_t numEvents = eventBuffer.GetNumEvents();
// Check if the triggered motion event is of the given type and parameter from the motion condition.
for (uint32 i = 0; i < numEvents; ++i)
for (size_t i = 0; i < numEvents; ++i)
{
const EMotionFX::EventInfo& eventInfo = eventBuffer.GetEvent(i);
const EventDataSet& eventDatas = eventInfo.mEvent->GetEventDatas();
@@ -50,7 +50,7 @@ namespace EMotionFX
AnimGraphNode::AnimGraphNode()
: AnimGraphObject(nullptr)
, m_id(AnimGraphNodeId::Create())
, mNodeIndex(MCORE_INVALIDINDEX32)
, mNodeIndex(InvalidIndex)
, mDisabled(false)
, mParentNode(nullptr)
, mCustomData(nullptr)
@@ -256,7 +256,7 @@ namespace EMotionFX
// remove a given node
void AnimGraphNode::RemoveChildNode(uint32 index, bool delFromMem)
void AnimGraphNode::RemoveChildNode(size_t index, bool delFromMem)
{
// remove the node from its node group
AnimGraphNodeGroup* nodeGroup = mAnimGraph->FindNodeGroupForNode(mChildNodes[index]);
@@ -287,7 +287,7 @@ namespace EMotionFX
if (iterator != mChildNodes.end())
{
const uint32 index = static_cast<uint32>(iterator - mChildNodes.begin());
const size_t index = AZStd::distance(mChildNodes.begin(), iterator);
RemoveChildNode(index, delFromMem);
}
}
@@ -384,77 +384,50 @@ namespace EMotionFX
// find a child node index by name
uint32 AnimGraphNode::FindChildNodeIndex(const char* name) const
size_t AnimGraphNode::FindChildNodeIndex(const char* name) const
{
const size_t numChildNodes = mChildNodes.size();
for (size_t i = 0; i < numChildNodes; ++i)
const auto foundChildNode = AZStd::find_if(begin(mChildNodes), end(mChildNodes), [name](const AnimGraphNode* childNode)
{
// compare the node name with the parameter and return the relative child node index in case they are equal
if (AzFramework::StringFunc::Equal(mChildNodes[i]->GetNameString().c_str(), name, true /* case sensitive */))
{
return static_cast<uint32>(i);
}
}
// failure, return invalid index
return MCORE_INVALIDINDEX32;
return childNode->GetNameString() == name;
});
return foundChildNode != end(mChildNodes) ? AZStd::distance(begin(mChildNodes), foundChildNode) : InvalidIndex;
}
// find a child node index
uint32 AnimGraphNode::FindChildNodeIndex(AnimGraphNode* node) const
size_t AnimGraphNode::FindChildNodeIndex(AnimGraphNode* node) const
{
const auto iterator = AZStd::find(mChildNodes.begin(), mChildNodes.end(), node);
if (iterator == mChildNodes.end())
{
return MCORE_INVALIDINDEX32;
}
const size_t index = iterator - mChildNodes.begin();
return static_cast<uint32>(index);
const auto foundChildNode = AZStd::find(mChildNodes.begin(), mChildNodes.end(), node);
return foundChildNode != end(mChildNodes) ? AZStd::distance(begin(mChildNodes), foundChildNode) : InvalidIndex;
}
AnimGraphNode* AnimGraphNode::FindFirstChildNodeOfType(const AZ::TypeId& nodeType) const
{
for (AnimGraphNode* childNode : mChildNodes)
const auto foundChild = AZStd::find_if(begin(mChildNodes), end(mChildNodes), [nodeType](const AnimGraphNode* childNode)
{
if (azrtti_typeid(childNode) == nodeType)
{
return childNode;
}
}
return nullptr;
return azrtti_typeid(childNode) == nodeType;
});
return foundChild != end(mChildNodes) ? *foundChild : nullptr;
}
bool AnimGraphNode::HasChildNodeOfType(const AZ::TypeId& nodeType) const
{
for (const AnimGraphNode* childNode : mChildNodes)
return AZStd::any_of(begin(mChildNodes), end(mChildNodes), [nodeType](const AnimGraphNode* childNode)
{
if (azrtti_typeid(childNode) == nodeType)
{
return true;
}
}
return false;
return azrtti_typeid(childNode) == nodeType;
});
}
// does this node has a specific incoming connection?
bool AnimGraphNode::GetHasConnection(AnimGraphNode* sourceNode, uint16 sourcePort, uint16 targetPort) const
{
for (const BlendTreeConnection* connection : mConnections)
return AZStd::any_of(begin(mConnections), end(mConnections), [sourceNode, sourcePort, targetPort](const BlendTreeConnection* connection)
{
if (connection->GetSourceNode() == sourceNode && connection->GetSourcePort() == sourcePort && connection->GetTargetPort() == targetPort)
{
return true;
}
}
return false;
return connection->GetSourceNode() == sourceNode && connection->GetSourcePort() == sourcePort && connection->GetTargetPort() == targetPort;
});
}
// remove a given connection
@@ -537,64 +510,52 @@ namespace EMotionFX
// initialize the input ports
void AnimGraphNode::InitInputPorts(uint32 numPorts)
void AnimGraphNode::InitInputPorts(size_t numPorts)
{
mInputPorts.resize(numPorts);
}
// initialize the output ports
void AnimGraphNode::InitOutputPorts(uint32 numPorts)
void AnimGraphNode::InitOutputPorts(size_t numPorts)
{
mOutputPorts.resize(numPorts);
}
// find a given output port number
uint32 AnimGraphNode::FindOutputPortIndex(const AZStd::string& name) const
size_t AnimGraphNode::FindOutputPortIndex(const AZStd::string& name) const
{
const size_t numPorts = mOutputPorts.size();
for (size_t i = 0; i < numPorts; ++i)
const auto foundPort = AZStd::find_if(begin(mOutputPorts), end(mOutputPorts), [&name](const Port& port)
{
// if the port name is equal to the name we are searching for, return the index
if (mOutputPorts[i].GetNameString() == name)
{
return static_cast<uint32>(i);
}
}
return MCORE_INVALIDINDEX32;
return port.GetNameString() == name;
});
return foundPort != end(mOutputPorts) ? AZStd::distance(begin(mOutputPorts), foundPort) : InvalidIndex;
}
// find a given input port number
uint32 AnimGraphNode::FindInputPortIndex(const AZStd::string& name) const
size_t AnimGraphNode::FindInputPortIndex(const AZStd::string& name) const
{
const size_t numPorts = mInputPorts.size();
for (size_t i = 0; i < numPorts; ++i)
const auto foundPort = AZStd::find_if(begin(mInputPorts), end(mInputPorts), [&name](const Port& port)
{
// if the port name is equal to the name we are searching for, return the index
if (mInputPorts[i].GetNameString() == name)
{
return static_cast<uint32>(i);
}
}
return MCORE_INVALIDINDEX32;
return port.GetNameString() == name;
});
return foundPort != end(mInputPorts) ? AZStd::distance(begin(mInputPorts), foundPort) : InvalidIndex;
}
// add an output port and return its index
uint32 AnimGraphNode::AddOutputPort()
size_t AnimGraphNode::AddOutputPort()
{
const size_t currentSize = mOutputPorts.size();
mOutputPorts.emplace_back();
return static_cast<uint32>(currentSize);
return currentSize;
}
// add an input port, and return its index
uint32 AnimGraphNode::AddInputPort()
size_t AnimGraphNode::AddInputPort()
{
const size_t currentSize = mInputPorts.size();
mInputPorts.emplace_back();
@@ -603,7 +564,7 @@ namespace EMotionFX
// setup a port name
void AnimGraphNode::SetInputPortName(uint32 portIndex, const char* name)
void AnimGraphNode::SetInputPortName(size_t portIndex, const char* name)
{
MCORE_ASSERT(portIndex < mInputPorts.size());
mInputPorts[portIndex].mNameID = MCore::GetStringIdPool().GenerateIdForString(name);
@@ -611,7 +572,7 @@ namespace EMotionFX
// setup a port name
void AnimGraphNode::SetOutputPortName(uint32 portIndex, const char* name)
void AnimGraphNode::SetOutputPortName(size_t portIndex, const char* name)
{
MCORE_ASSERT(portIndex < mOutputPorts.size());
mOutputPorts[portIndex].mNameID = MCore::GetStringIdPool().GenerateIdForString(name);
@@ -619,9 +580,9 @@ namespace EMotionFX
// get the total number of children
uint32 AnimGraphNode::RecursiveCalcNumNodes() const
size_t AnimGraphNode::RecursiveCalcNumNodes() const
{
uint32 result = 0;
size_t result = 0;
for (const AnimGraphNode* childNode : mChildNodes)
{
childNode->RecursiveCountChildNodes(result);
@@ -632,7 +593,7 @@ namespace EMotionFX
// recursively count the number of nodes down the hierarchy
void AnimGraphNode::RecursiveCountChildNodes(uint32& numNodes) const
void AnimGraphNode::RecursiveCountChildNodes(size_t& numNodes) const
{
// increase the counter
numNodes++;
@@ -645,16 +606,16 @@ namespace EMotionFX
// recursively calculate the number of node connections
uint32 AnimGraphNode::RecursiveCalcNumNodeConnections() const
size_t AnimGraphNode::RecursiveCalcNumNodeConnections() const
{
uint32 result = 0;
size_t result = 0;
RecursiveCountNodeConnections(result);
return result;
}
// recursively calculate the number of node connections
void AnimGraphNode::RecursiveCountNodeConnections(uint32& numConnections) const
void AnimGraphNode::RecursiveCountNodeConnections(size_t& numConnections) const
{
// add the connections to our counter
numConnections += GetNumConnections();
@@ -667,11 +628,11 @@ namespace EMotionFX
// setup an output port to output a given local pose
void AnimGraphNode::SetupOutputPortAsPose(const char* name, uint32 outputPortNr, uint32 portID)
void AnimGraphNode::SetupOutputPortAsPose(const char* name, size_t outputPortNr, uint32 portID)
{
// check if we already registered this port ID
const uint32 duplicatePort = FindOutputPortByID(portID);
if (duplicatePort != MCORE_INVALIDINDEX32)
const size_t duplicatePort = FindOutputPortByID(portID);
if (duplicatePort != InvalidIndex)
{
MCore::LogError("EMotionFX::AnimGraphNode::SetOutputPortAsPose() - There is already a port with the same ID (portID=%d existingPort='%s' newPort='%s' node='%s')", portID, mOutputPorts[duplicatePort].GetName(), name, RTTI_GetTypeName());
}
@@ -684,11 +645,11 @@ namespace EMotionFX
// setup an output port to output a given motion instance
void AnimGraphNode::SetupOutputPortAsMotionInstance(const char* name, uint32 outputPortNr, uint32 portID)
void AnimGraphNode::SetupOutputPortAsMotionInstance(const char* name, size_t outputPortNr, uint32 portID)
{
// check if we already registered this port ID
const uint32 duplicatePort = FindOutputPortByID(portID);
if (duplicatePort != MCORE_INVALIDINDEX32)
const size_t duplicatePort = FindOutputPortByID(portID);
if (duplicatePort != InvalidIndex)
{
MCore::LogError("EMotionFX::AnimGraphNode::SetOutputPortAsMotionInstance() - There is already a port with the same ID (portID=%d existingPort='%s' newPort='%s' node='%s')", portID, mOutputPorts[duplicatePort].GetName(), name, RTTI_GetTypeName());
}
@@ -701,11 +662,11 @@ namespace EMotionFX
// setup an output port
void AnimGraphNode::SetupOutputPort(const char* name, uint32 outputPortNr, uint32 attributeTypeID, uint32 portID)
void AnimGraphNode::SetupOutputPort(const char* name, size_t outputPortNr, uint32 attributeTypeID, uint32 portID)
{
// check if we already registered this port ID
const uint32 duplicatePort = FindOutputPortByID(portID);
if (duplicatePort != MCORE_INVALIDINDEX32)
const size_t duplicatePort = FindOutputPortByID(portID);
if (duplicatePort != InvalidIndex)
{
MCore::LogError("EMotionFX::AnimGraphNode::SetOutputPort() - There is already a port with the same ID (portID=%d existingPort='%s' newPort='%s' name='%s')", portID, mOutputPorts[duplicatePort].GetName(), name, RTTI_GetTypeName());
}
@@ -716,26 +677,26 @@ namespace EMotionFX
mOutputPorts[outputPortNr].mPortID = portID;
}
void AnimGraphNode::SetupInputPortAsVector3(const char* name, uint32 inputPortNr, uint32 portID)
void AnimGraphNode::SetupInputPortAsVector3(const char* name, size_t inputPortNr, uint32 portID)
{
SetupInputPort(name, inputPortNr, AZStd::vector<uint32>{MCore::AttributeVector3::TYPE_ID, MCore::AttributeVector2::TYPE_ID, MCore::AttributeVector4::TYPE_ID}, portID);
}
void AnimGraphNode::SetupInputPortAsVector2(const char* name, uint32 inputPortNr, uint32 portID)
void AnimGraphNode::SetupInputPortAsVector2(const char* name, size_t inputPortNr, uint32 portID)
{
SetupInputPort(name, inputPortNr, AZStd::vector<uint32>{MCore::AttributeVector2::TYPE_ID, MCore::AttributeVector3::TYPE_ID}, portID);
}
void AnimGraphNode::SetupInputPortAsVector4(const char* name, uint32 inputPortNr, uint32 portID)
void AnimGraphNode::SetupInputPortAsVector4(const char* name, size_t inputPortNr, uint32 portID)
{
SetupInputPort(name, inputPortNr, AZStd::vector<uint32>{MCore::AttributeVector4::TYPE_ID, MCore::AttributeVector3::TYPE_ID}, portID);
}
void AnimGraphNode::SetupInputPort(const char* name, uint32 inputPortNr, const AZStd::vector<uint32>& attributeTypeIDs, uint32 portID)
void AnimGraphNode::SetupInputPort(const char* name, size_t inputPortNr, const AZStd::vector<uint32>& attributeTypeIDs, uint32 portID)
{
// Check if we already registered this port ID
const uint32 duplicatePort = FindInputPortByID(portID);
if (duplicatePort != MCORE_INVALIDINDEX32)
const size_t duplicatePort = FindInputPortByID(portID);
if (duplicatePort != InvalidIndex)
{
MCore::LogError("EMotionFX::AnimGraphNode::SetInputPortAsNumber() - There is already a port with the same ID (portID=%d existingPort='%s' newPort='%s' node='%s')", portID, MCore::GetStringIdPool().GetName(mInputPorts[duplicatePort].mNameID).c_str(), name, RTTI_GetTypeName());
}
@@ -747,11 +708,11 @@ namespace EMotionFX
}
// setup an input port as a number (float/int/bool)
void AnimGraphNode::SetupInputPortAsNumber(const char* name, uint32 inputPortNr, uint32 portID)
void AnimGraphNode::SetupInputPortAsNumber(const char* name, size_t inputPortNr, uint32 portID)
{
// check if we already registered this port ID
const uint32 duplicatePort = FindInputPortByID(portID);
if (duplicatePort != MCORE_INVALIDINDEX32)
const size_t duplicatePort = FindInputPortByID(portID);
if (duplicatePort != InvalidIndex)
{
MCore::LogError("EMotionFX::AnimGraphNode::SetInputPortAsNumber() - There is already a port with the same ID (portID=%d existingPort='%s' newPort='%s' node='%s')", portID, mInputPorts[duplicatePort].GetName(), name, RTTI_GetTypeName());
}
@@ -764,11 +725,11 @@ namespace EMotionFX
mInputPorts[inputPortNr].mPortID = portID;
}
void AnimGraphNode::SetupInputPortAsBool(const char* name, uint32 inputPortNr, uint32 portID)
void AnimGraphNode::SetupInputPortAsBool(const char* name, size_t inputPortNr, uint32 portID)
{
// check if we already registered this port ID
const uint32 duplicatePort = FindInputPortByID(portID);
if (duplicatePort != MCORE_INVALIDINDEX32)
const size_t duplicatePort = FindInputPortByID(portID);
if (duplicatePort != InvalidIndex)
{
MCore::LogError("EMotionFX::AnimGraphNode::SetInputPortAsBool() - There is already a port with the same ID (portID=%d existingPort='%s' newPort='%s' node='%s')", portID, mInputPorts[duplicatePort].GetName(), name, RTTI_GetTypeName());
}
@@ -782,11 +743,11 @@ namespace EMotionFX
}
// setup a given input port in a generic way
void AnimGraphNode::SetupInputPort(const char* name, uint32 inputPortNr, uint32 attributeTypeID, uint32 portID)
void AnimGraphNode::SetupInputPort(const char* name, size_t inputPortNr, uint32 attributeTypeID, uint32 portID)
{
// check if we already registered this port ID
const uint32 duplicatePort = FindInputPortByID(portID);
if (duplicatePort != MCORE_INVALIDINDEX32)
const size_t duplicatePort = FindInputPortByID(portID);
if (duplicatePort != InvalidIndex)
{
MCore::LogError("EMotionFX::AnimGraphNode::SetInputPort() - There is already a port with the same ID (portID=%d existingPort='%s' newPort='%s' node='%s')", portID, mInputPorts[duplicatePort].GetName(), name, RTTI_GetTypeName());
}
@@ -834,7 +795,7 @@ namespace EMotionFX
}
// get the input value for a given port
const MCore::Attribute* AnimGraphNode::GetInputValue(AnimGraphInstance* animGraphInstance, uint32 inputPort) const
const MCore::Attribute* AnimGraphNode::GetInputValue(AnimGraphInstance* animGraphInstance, size_t inputPort) const
{
MCORE_UNUSED(animGraphInstance);
@@ -961,8 +922,8 @@ namespace EMotionFX
syncMode, weight, outLeaderFactor, outFollowerFactor, outPlaySpeed);
}
void AnimGraphNode::CalcSyncFactors(float leaderPlaySpeed, const AnimGraphSyncTrack* leaderSyncTrack, uint32 leaderSyncTrackIndex, float leaderDuration,
float followerPlaySpeed, const AnimGraphSyncTrack* followerSyncTrack, uint32 followerSyncTrackIndex, float followerDuration,
void AnimGraphNode::CalcSyncFactors(float leaderPlaySpeed, const AnimGraphSyncTrack* leaderSyncTrack, size_t leaderSyncTrackIndex, float leaderDuration,
float followerPlaySpeed, const AnimGraphSyncTrack* followerSyncTrack, size_t followerSyncTrackIndex, float followerDuration,
ESyncMode syncMode, float weight, float* outLeaderFactor, float* outFollowerFactor, float* outPlaySpeed)
{
// exit if we don't want to sync or we have no leader node to sync to
@@ -986,7 +947,7 @@ namespace EMotionFX
if (leaderSyncTrack && followerSyncTrack && leaderSyncTrack->GetNumEvents() > 0 && followerSyncTrack->GetNumEvents() > 0)
{
// if the sync indices are invalid, act like no syncing
if (leaderSyncTrackIndex == MCORE_INVALIDINDEX32 || followerSyncTrackIndex == MCORE_INVALIDINDEX32)
if (leaderSyncTrackIndex == InvalidIndex || followerSyncTrackIndex == InvalidIndex)
{
*outLeaderFactor = 1.0f;
*outFollowerFactor = 1.0f;
@@ -995,13 +956,13 @@ namespace EMotionFX
// get the segment lengths
// TODO: handle motion clip start and end
uint32 leaderSyncIndexNext = leaderSyncTrackIndex + 1;
size_t leaderSyncIndexNext = leaderSyncTrackIndex + 1;
if (leaderSyncIndexNext >= leaderSyncTrack->GetNumEvents())
{
leaderSyncIndexNext = 0;
}
uint32 followerSyncIndexNext = followerSyncTrackIndex + 1;
size_t followerSyncIndexNext = followerSyncTrackIndex + 1;
if (followerSyncIndexNext >= followerSyncTrack->GetNumEvents())
{
followerSyncIndexNext = 0;
@@ -1032,8 +993,8 @@ namespace EMotionFX
OnChangeMotionSet(animGraphInstance, newMotionSet);
// get the number of child nodes, iterate through them and recursively call this function
const uint32 numChildNodes = GetNumChildNodes();
for (uint32 i = 0; i < numChildNodes; ++i)
const size_t numChildNodes = GetNumChildNodes();
for (size_t i = 0; i < numChildNodes; ++i)
{
mChildNodes[i]->RecursiveOnChangeMotionSet(animGraphInstance, newMotionSet);
}
@@ -1086,7 +1047,7 @@ namespace EMotionFX
startEventIndex = 0;
}
if (startEventIndex == MCORE_INVALIDINDEX32)
if (startEventIndex == InvalidIndex)
{
startEventIndex = syncTrackB->GetNumEvents() - 1;
}
@@ -1118,8 +1079,8 @@ namespace EMotionFX
}
// update the sync indices
uniqueDataA->SetSyncIndex(static_cast<uint32>(firstIndexA));
uniqueDataB->SetSyncIndex(static_cast<uint32>(secondIndexA));
uniqueDataA->SetSyncIndex(firstIndexA);
uniqueDataB->SetSyncIndex(secondIndexA);
// calculate the segment lengths
const float firstSegmentLength = syncTrackA->CalcSegmentLength(firstIndexA, firstIndexB);
@@ -1194,7 +1155,7 @@ namespace EMotionFX
// check if the given node is the parent or the parent of the parent etc. of the node
bool AnimGraphNode::RecursiveIsParentNode(AnimGraphNode* node) const
bool AnimGraphNode::RecursiveIsParentNode(const AnimGraphNode* node) const
{
// if we're dealing with a root node we can directly return failure
if (!mParentNode)
@@ -1217,22 +1178,15 @@ namespace EMotionFX
bool AnimGraphNode::RecursiveIsChildNode(AnimGraphNode* node) const
{
// check if the given node is a child node of the current node
if (FindChildNodeIndex(node) != MCORE_INVALIDINDEX32)
if (FindChildNodeIndex(node) != InvalidIndex)
{
return true;
}
// get the number of child nodes, iterate through them and compare if the node is a child of the child nodes of this node
for (const AnimGraphNode* childNode : mChildNodes)
return AZStd::any_of(begin(mChildNodes), end(mChildNodes), [node](const AnimGraphNode* childNode)
{
if (childNode->RecursiveIsChildNode(node))
{
return true;
}
}
// failure, the node isn't a child or a child of a child node
return false;
return childNode->RecursiveIsChildNode(node);
});
}
@@ -1287,14 +1241,14 @@ namespace EMotionFX
// collect child nodes of the given type
void AnimGraphNode::CollectChildNodesOfType(const AZ::TypeId& nodeType, MCore::Array<AnimGraphNode*>* outNodes) const
void AnimGraphNode::CollectChildNodesOfType(const AZ::TypeId& nodeType, AZStd::vector<AnimGraphNode*>* outNodes) const
{
for (AnimGraphNode* childNode : mChildNodes)
{
// check the current node type and add it to the output array in case they are the same
if (azrtti_typeid(childNode) == nodeType)
{
outNodes->Add(childNode);
outNodes->emplace_back(childNode);
}
}
}
@@ -1324,7 +1278,7 @@ namespace EMotionFX
}
}
void AnimGraphNode::RecursiveCollectTransitionConditionsOfType(const AZ::TypeId& conditionType, MCore::Array<AnimGraphTransitionCondition*>* outConditions) const
void AnimGraphNode::RecursiveCollectTransitionConditionsOfType(const AZ::TypeId& conditionType, AZStd::vector<AnimGraphTransitionCondition*>* outConditions) const
{
// check if the current node is a state machine
if (azrtti_typeid(this) == azrtti_typeid<AnimGraphStateMachine>())
@@ -1346,7 +1300,7 @@ namespace EMotionFX
AnimGraphTransitionCondition* condition = transition->GetCondition(j);
if (azrtti_typeid(condition) == conditionType)
{
outConditions->Add(condition);
outConditions->emplace_back(condition);
}
}
}
@@ -1425,60 +1379,44 @@ namespace EMotionFX
// find the input port, based on the port name
AnimGraphNode::Port* AnimGraphNode::FindInputPortByName(const AZStd::string& portName)
{
for (Port& port : mInputPorts)
const auto foundPort = AZStd::find_if(begin(mInputPorts), end(mInputPorts), [&portName](const Port& port)
{
if (port.GetNameString() == portName)
{
return &port;
}
}
return nullptr;
return port.GetNameString() == portName;
});
return foundPort != end(mInputPorts) ? foundPort : nullptr;
}
// find the output port, based on the port name
AnimGraphNode::Port* AnimGraphNode::FindOutputPortByName(const AZStd::string& portName)
{
for (Port& port : mOutputPorts)
const auto foundPort = AZStd::find_if(begin(mOutputPorts), end(mOutputPorts), [&portName](const Port& port)
{
if (port.GetNameString() == portName)
{
return &port;
}
}
return nullptr;
return port.GetNameString() == portName;
});
return foundPort != end(mOutputPorts) ? foundPort : nullptr;
}
// find the input port index, based on the port id
uint32 AnimGraphNode::FindInputPortByID(uint32 portID) const
size_t AnimGraphNode::FindInputPortByID(uint32 portID) const
{
const size_t numPorts = mInputPorts.size();
for (size_t i = 0; i < numPorts; ++i)
const auto foundPort = AZStd::find_if(begin(mInputPorts), end(mInputPorts), [portID](const Port& port)
{
if (mInputPorts[i].mPortID == portID)
{
return static_cast<uint32>(i);
}
}
return MCORE_INVALIDINDEX32;
return port.mPortID == portID;
});
return foundPort != end(mInputPorts) ? AZStd::distance(begin(mInputPorts), foundPort) : InvalidIndex;
}
// find the output port index, based on the port id
uint32 AnimGraphNode::FindOutputPortByID(uint32 portID) const
size_t AnimGraphNode::FindOutputPortByID(uint32 portID) const
{
const size_t numPorts = mOutputPorts.size();
for (size_t i = 0; i < numPorts; ++i)
const auto foundPort = AZStd::find_if(begin(mOutputPorts), end(mOutputPorts), [portID](const Port& port)
{
if (mOutputPorts[i].mPortID == portID)
{
return static_cast<uint32>(i);
}
}
return MCORE_INVALIDINDEX32;
return port.mPortID == portID;
});
return foundPort != end(mOutputPorts) ? AZStd::distance(begin(mOutputPorts), foundPort) : InvalidIndex;
}
@@ -1521,7 +1459,7 @@ namespace EMotionFX
}
void AnimGraphNode::CollectOutgoingConnections(AZStd::vector<AZStd::pair<BlendTreeConnection*, AnimGraphNode*> >& outConnections, const uint32 portIndex) const
void AnimGraphNode::CollectOutgoingConnections(AZStd::vector<AZStd::pair<BlendTreeConnection*, AnimGraphNode*> >& outConnections, const size_t portIndex) const
{
outConnections.clear();
@@ -1553,8 +1491,8 @@ namespace EMotionFX
BlendTreeConnection* AnimGraphNode::FindConnection(uint16 port) const
{
// get the number of connections and iterate through them
const uint32 numConnections = GetNumConnections();
for (uint32 i = 0; i < numConnections; ++i)
const size_t numConnections = GetNumConnections();
for (size_t i = 0; i < numConnections; ++i)
{
// get the current connection and check if the connection is connected to the given port
BlendTreeConnection* connection = GetConnection(i);
@@ -1601,9 +1539,9 @@ namespace EMotionFX
// collect internal objects
void AnimGraphNode::RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const
void AnimGraphNode::RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const
{
outObjects.Add(const_cast<AnimGraphNode*>(this));
outObjects.emplace_back(const_cast<AnimGraphNode*>(this));
for (const AnimGraphNode* childNode : mChildNodes)
{
@@ -1644,7 +1582,7 @@ namespace EMotionFX
// iterate over all incoming connections
bool syncTrackFound = false;
size_t connectionIndex = MCORE_INVALIDINDEX32;
size_t connectionIndex = InvalidIndex;
const size_t numConnections = mConnections.size();
for (size_t i = 0; i < numConnections; ++i)
{
@@ -1662,7 +1600,7 @@ namespace EMotionFX
}
}
if (connectionIndex != MCORE_INVALIDINDEX32)
if (connectionIndex != InvalidIndex)
{
uniqueData->Init(animGraphInstance, mConnections[connectionIndex]->GetSourceNode());
}
@@ -1752,7 +1690,7 @@ namespace EMotionFX
{
// Post process all incoming nodes.
bool poseFound = false;
size_t connectionIndex = MCORE_INVALIDINDEX32;
size_t connectionIndex = InvalidIndex;
AZ::u16 minTargetPortIndex = MCORE_INVALIDINDEX16;
const size_t numConnections = mConnections.size();
for (size_t i = 0; i < numConnections; ++i)
@@ -1786,7 +1724,7 @@ namespace EMotionFX
RequestRefDatas(animGraphInstance);
AnimGraphNodeData* uniqueData = FindOrCreateUniqueNodeData(animGraphInstance);
if (poseFound && connectionIndex != MCORE_INVALIDINDEX32)
if (poseFound && connectionIndex != InvalidIndex)
{
const BlendTreeConnection* connection = mConnections[connectionIndex];
AnimGraphNode* sourceNode = connection->GetSourceNode();
@@ -1894,8 +1832,8 @@ namespace EMotionFX
{
AnimGraphRefCountedData* refDataNodeB = nodeB ? nodeB->FindOrCreateUniqueNodeData(animGraphInstance)->GetRefCountedData() : nullptr;
const uint32 numEventsA = refDataNodeA ? refDataNodeA->GetEventBuffer().GetNumEvents() : 0;
const uint32 numEventsB = refDataNodeB ? refDataNodeB->GetEventBuffer().GetNumEvents() : 0;
const size_t numEventsA = refDataNodeA ? refDataNodeA->GetEventBuffer().GetNumEvents() : 0;
const size_t numEventsB = refDataNodeB ? refDataNodeB->GetEventBuffer().GetNumEvents() : 0;
// resize to the right number of events already
AnimGraphEventBuffer& eventBuffer = refData->GetEventBuffer();
@@ -1905,7 +1843,7 @@ namespace EMotionFX
if (refDataNodeA)
{
const AnimGraphEventBuffer& eventBufferA = refDataNodeA->GetEventBuffer();
for (uint32 i = 0; i < numEventsA; ++i)
for (size_t i = 0; i < numEventsA; ++i)
{
eventBuffer.SetEvent(i, eventBufferA.GetEvent(i));
}
@@ -1914,7 +1852,7 @@ namespace EMotionFX
if (refDataNodeB)
{
const AnimGraphEventBuffer& eventBufferB = refDataNodeB->GetEventBuffer();
for (uint32 i = 0; i < numEventsB; ++i)
for (size_t i = 0; i < numEventsB; ++i)
{
eventBuffer.SetEvent(numEventsA + i, eventBufferB.GetEvent(i));
}
@@ -2075,7 +2013,7 @@ namespace EMotionFX
{
if (mOutputPorts[i].mCompatibleTypes[0] == AttributePose::TYPE_ID)
{
MCore::Attribute* attribute = GetOutputAttribute(animGraphInstance, static_cast<uint32>(i));
MCore::Attribute* attribute = GetOutputAttribute(animGraphInstance, i);
MCORE_ASSERT(attribute->GetType() == AttributePose::TYPE_ID);
AttributePose* poseAttribute = static_cast<AttributePose*>(attribute);
@@ -2103,7 +2041,7 @@ namespace EMotionFX
{
if (mOutputPorts[i].mCompatibleTypes[0] == AttributePose::TYPE_ID)
{
MCore::Attribute* attribute = GetOutputAttribute(animGraphInstance, static_cast<uint32>(i));
MCore::Attribute* attribute = GetOutputAttribute(animGraphInstance, i);
MCORE_ASSERT(attribute->GetType() == AttributePose::TYPE_ID);
AnimGraphPose* pose = posePool.RequestPose(actorInstance);
@@ -2352,8 +2290,8 @@ namespace EMotionFX
// for all output ports
for (Port& port : mOutputPorts)
{
const uint32 internalAttributeIndex = port.mAttributeIndex;
if (internalAttributeIndex != MCORE_INVALIDINDEX32)
const size_t internalAttributeIndex = port.mAttributeIndex;
if (internalAttributeIndex != InvalidIndex)
{
const size_t numInstances = mAnimGraph->GetNumAnimGraphInstances();
for (size_t i = 0; i < numInstances; ++i)
@@ -2363,18 +2301,18 @@ namespace EMotionFX
}
mAnimGraph->DecreaseInternalAttributeIndices(internalAttributeIndex);
port.mAttributeIndex = MCORE_INVALIDINDEX32;
port.mAttributeIndex = InvalidIndex;
}
}
}
// decrease values higher than a given param value
void AnimGraphNode::DecreaseInternalAttributeIndices(uint32 decreaseEverythingHigherThan)
void AnimGraphNode::DecreaseInternalAttributeIndices(size_t decreaseEverythingHigherThan)
{
for (Port& port : mOutputPorts)
{
if (port.mAttributeIndex > decreaseEverythingHigherThan && port.mAttributeIndex != MCORE_INVALIDINDEX32)
if (port.mAttributeIndex > decreaseEverythingHigherThan && port.mAttributeIndex != InvalidIndex)
{
port.mAttributeIndex--;
}
@@ -2498,7 +2436,7 @@ namespace EMotionFX
}
void AnimGraphNode::ReserveChildNodes(uint32 numChildNodes)
void AnimGraphNode::ReserveChildNodes(size_t numChildNodes)
{
mChildNodes.reserve(numChildNodes);
}
@@ -60,7 +60,7 @@ namespace EMotionFX
uint32 mCompatibleTypes[4]; // four possible compatible types
uint32 mPortID; // the unique port ID (unique inside the node input or output port lists)
uint32 mNameID; // the name of the port (using the StringIdPool)
uint32 mAttributeIndex; // the index into the animgraph instance global attributes array
size_t mAttributeIndex; // the index into the animgraph instance global attributes array
MCORE_INLINE const char* GetName() const { return MCore::GetStringIdPool().GetName(mNameID).c_str(); }
MCORE_INLINE const AZStd::string& GetNameString() const { return MCore::GetStringIdPool().GetName(mNameID); }
@@ -97,22 +97,22 @@ namespace EMotionFX
bool CheckIfIsCompatibleWith(const Port& otherPort) const
{
// check the data types
for (uint32 myCompatibleTypeindex = 0; myCompatibleTypeindex < 4; ++myCompatibleTypeindex)
for (uint32 compatibleType : mCompatibleTypes)
{
// If there aren't any more compatibility types and we haven't found a compatible one so far, return false
if (mCompatibleTypes[myCompatibleTypeindex] == 0)
if (compatibleType == 0)
{
return false;
}
for (uint32 otherCompatibleTypeIndex = 0; otherCompatibleTypeIndex < 4; ++otherCompatibleTypeIndex)
for (uint32 otherCompatibleTypeIndex : otherPort.mCompatibleTypes)
{
if (otherPort.mCompatibleTypes[otherCompatibleTypeIndex] == mCompatibleTypes[myCompatibleTypeindex])
if (otherCompatibleTypeIndex == compatibleType)
{
return true;
}
// If there aren't any more compatibility types and we haven't found a compatible one so far, return false
if (otherPort.mCompatibleTypes[otherCompatibleTypeIndex] == 0)
if (otherCompatibleTypeIndex == 0)
{
break;
}
@@ -141,7 +141,7 @@ namespace EMotionFX
: mConnection(nullptr)
, mPortID(MCORE_INVALIDINDEX32)
, mNameID(MCORE_INVALIDINDEX32)
, mAttributeIndex(MCORE_INVALIDINDEX32) { ClearCompatibleTypes(); }
, mAttributeIndex(InvalidIndex) { ClearCompatibleTypes(); }
virtual ~Port() { }
};
@@ -173,7 +173,7 @@ namespace EMotionFX
void InitInternalAttributes(AnimGraphInstance* animGraphInstance) override;
void RemoveInternalAttributesForAllInstances() override;
void DecreaseInternalAttributeIndices(uint32 decreaseEverythingHigherThan) override;
void DecreaseInternalAttributeIndices(size_t decreaseEverythingHigherThan) override;
void OutputAllIncomingNodes(AnimGraphInstance* animGraphInstance);
void UpdateAllIncomingNodes(AnimGraphInstance* animGraphInstance, float timePassedInSeconds);
@@ -217,8 +217,8 @@ namespace EMotionFX
virtual void SetCurrentPlayTime(AnimGraphInstance* animGraphInstance, float timeInSeconds) { FindOrCreateUniqueNodeData(animGraphInstance)->SetCurrentPlayTime(timeInSeconds); }
virtual float GetCurrentPlayTime(AnimGraphInstance* animGraphInstance) const { return FindOrCreateUniqueNodeData(animGraphInstance)->GetCurrentPlayTime(); }
MCORE_INLINE uint32 GetSyncIndex(AnimGraphInstance* animGraphInstance) const { return FindOrCreateUniqueNodeData(animGraphInstance)->GetSyncIndex(); }
MCORE_INLINE void SetSyncIndex(AnimGraphInstance* animGraphInstance, uint32 syncIndex) { FindOrCreateUniqueNodeData(animGraphInstance)->SetSyncIndex(syncIndex); }
MCORE_INLINE size_t GetSyncIndex(AnimGraphInstance* animGraphInstance) const { return FindOrCreateUniqueNodeData(animGraphInstance)->GetSyncIndex(); }
MCORE_INLINE void SetSyncIndex(AnimGraphInstance* animGraphInstance, size_t syncIndex) { FindOrCreateUniqueNodeData(animGraphInstance)->SetSyncIndex(syncIndex); }
virtual void SetPlaySpeed(AnimGraphInstance* animGraphInstance, float speedFactor) { FindOrCreateUniqueNodeData(animGraphInstance)->SetPlaySpeed(speedFactor); }
virtual float GetPlaySpeed(AnimGraphInstance* animGraphInstance) const { return FindOrCreateUniqueNodeData(animGraphInstance)->GetPlaySpeed(); }
@@ -235,8 +235,8 @@ namespace EMotionFX
void HierarchicalSyncAllInputNodes(AnimGraphInstance* animGraphInstance, AnimGraphNodeData* uniqueDataOfThisNode);
static void CalcSyncFactors(AnimGraphInstance* animGraphInstance, const AnimGraphNode* leaderNode, const AnimGraphNode* followerNode, ESyncMode syncMode, float weight, float* outLeaderFactor, float* outFollowerFactor, float* outPlaySpeed);
static void CalcSyncFactors(float leaderPlaySpeed, const AnimGraphSyncTrack* leaderSyncTrack, uint32 leaderSyncTrackIndex, float leaderDuration,
float followerPlaySpeed, const AnimGraphSyncTrack* followerSyncTrack, uint32 followerSyncTrackIndex, float followerDuration,
static void CalcSyncFactors(float leaderPlaySpeed, const AnimGraphSyncTrack* leaderSyncTrack, size_t leaderSyncTrackIndex, float leaderDuration,
float followerPlaySpeed, const AnimGraphSyncTrack* followerSyncTrack, size_t followerSyncTrackIndex, float followerDuration,
ESyncMode syncMode, float weight, float* outLeaderFactor, float* outFollowerFactor, float* outPlaySpeed);
void RequestPoses(AnimGraphInstance* animGraphInstance);
@@ -270,7 +270,7 @@ namespace EMotionFX
virtual bool RecursiveDetectCycles(AZStd::unordered_set<const AnimGraphNode*>& nodes) const;
void CollectChildNodesOfType(const AZ::TypeId& nodeType, MCore::Array<AnimGraphNode*>* outNodes) const; // note: outNodes is NOT cleared internally, nodes are added to the array
void CollectChildNodesOfType(const AZ::TypeId& nodeType, AZStd::vector<AnimGraphNode*>* outNodes) const; // note: outNodes is NOT cleared internally, nodes are added to the array
/**
* Collect child nodes of the given type. This will only iterate through the child nodes and isn't a recursive process.
@@ -280,7 +280,7 @@ namespace EMotionFX
void CollectChildNodesOfType(const AZ::TypeId& nodeType, AZStd::vector<AnimGraphNode*>& outNodes) const;
void RecursiveCollectNodesOfType(const AZ::TypeId& nodeType, AZStd::vector<AnimGraphNode*>* outNodes) const; // note: outNodes is NOT cleared internally, nodes are added to the array
void RecursiveCollectTransitionConditionsOfType(const AZ::TypeId& conditionType, MCore::Array<AnimGraphTransitionCondition*>* outConditions) const; // note: outNodes is NOT cleared internally, nodes are added to the array
void RecursiveCollectTransitionConditionsOfType(const AZ::TypeId& conditionType, AZStd::vector<AnimGraphTransitionCondition*>* outConditions) const; // note: outNodes is NOT cleared internally, nodes are added to the array
virtual void RecursiveCollectObjectsOfType(const AZ::TypeId& objectType, AZStd::vector<AnimGraphObject*>& outObjects) const;
@@ -315,10 +315,10 @@ namespace EMotionFX
MCORE_INLINE AnimGraphNodeId GetId() const { return m_id; }
void SetId(AnimGraphNodeId id) { m_id = id; }
const MCore::Attribute* GetInputValue(AnimGraphInstance* instance, uint32 inputPort) const;
const MCore::Attribute* GetInputValue(AnimGraphInstance* instance, size_t inputPort) const;
uint32 FindInputPortByID(uint32 portID) const;
uint32 FindOutputPortByID(uint32 portID) const;
size_t FindInputPortByID(uint32 portID) const;
size_t FindOutputPortByID(uint32 portID) const;
Port* FindInputPortByName(const AZStd::string& portName);
Port* FindOutputPortByName(const AZStd::string& portName);
@@ -360,9 +360,9 @@ namespace EMotionFX
* node of the outgoing connection. The BlendTreeConnection itself contains the pointer to the source node. The
* vector will be cleared upfront.
*/
void CollectOutgoingConnections(AZStd::vector<AZStd::pair<BlendTreeConnection*, AnimGraphNode*>>& outConnections, const uint32 portIndex) const;
void CollectOutgoingConnections(AZStd::vector<AZStd::pair<BlendTreeConnection*, AnimGraphNode*>>& outConnections, const size_t portIndex) const;
MCORE_INLINE bool GetInputNumberAsBool(AnimGraphInstance* animGraphInstance, uint32 inputPortNr) const
MCORE_INLINE bool GetInputNumberAsBool(AnimGraphInstance* animGraphInstance, size_t inputPortNr) const
{
const MCore::Attribute* attribute = GetInputAttribute(animGraphInstance, inputPortNr);
if (attribute == nullptr)
@@ -383,7 +383,7 @@ namespace EMotionFX
return false;
}
MCORE_INLINE float GetInputNumberAsFloat(AnimGraphInstance* animGraphInstance, uint32 inputPortNr) const
MCORE_INLINE float GetInputNumberAsFloat(AnimGraphInstance* animGraphInstance, size_t inputPortNr) const
{
const MCore::Attribute* attribute = GetInputAttribute(animGraphInstance, inputPortNr);
if (attribute == nullptr)
@@ -404,7 +404,7 @@ namespace EMotionFX
return 0.0f;
}
MCORE_INLINE int32 GetInputNumberAsInt32(AnimGraphInstance* animGraphInstance, uint32 inputPortNr) const
MCORE_INLINE int32 GetInputNumberAsInt32(AnimGraphInstance* animGraphInstance, size_t inputPortNr) const
{
const MCore::Attribute* attribute = GetInputAttribute(animGraphInstance, inputPortNr);
if (attribute == nullptr)
@@ -425,7 +425,7 @@ namespace EMotionFX
return 0;
}
MCORE_INLINE uint32 GetInputNumberAsUint32(AnimGraphInstance* animGraphInstance, uint32 inputPortNr) const
MCORE_INLINE uint32 GetInputNumberAsUint32(AnimGraphInstance* animGraphInstance, size_t inputPortNr) const
{
const MCore::Attribute* attribute = GetInputAttribute(animGraphInstance, inputPortNr);
if (attribute == nullptr)
@@ -446,7 +446,7 @@ namespace EMotionFX
return 0;
}
MCORE_INLINE AnimGraphNode* GetInputNode(uint32 portNr)
MCORE_INLINE AnimGraphNode* GetInputNode(size_t portNr)
{
const BlendTreeConnection* con = mInputPorts[portNr].mConnection;
if (con == nullptr)
@@ -456,7 +456,7 @@ namespace EMotionFX
return con->GetSourceNode();
}
MCORE_INLINE MCore::Attribute* GetInputAttribute(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE MCore::Attribute* GetInputAttribute(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
const BlendTreeConnection* con = mInputPorts[portNr].mConnection;
if (con == nullptr)
@@ -466,7 +466,7 @@ namespace EMotionFX
return con->GetSourceNode()->GetOutputValue(animGraphInstance, con->GetSourcePort());
}
MCORE_INLINE MCore::AttributeFloat* GetInputFloat(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE MCore::AttributeFloat* GetInputFloat(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -477,7 +477,7 @@ namespace EMotionFX
return static_cast<MCore::AttributeFloat*>(attrib);
}
MCORE_INLINE MCore::AttributeInt32* GetInputInt32(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE MCore::AttributeInt32* GetInputInt32(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -488,7 +488,7 @@ namespace EMotionFX
return static_cast<MCore::AttributeInt32*>(attrib);
}
MCORE_INLINE MCore::AttributeString* GetInputString(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE MCore::AttributeString* GetInputString(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -499,7 +499,7 @@ namespace EMotionFX
return static_cast<MCore::AttributeString*>(attrib);
}
MCORE_INLINE MCore::AttributeBool* GetInputBool(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE MCore::AttributeBool* GetInputBool(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -510,7 +510,7 @@ namespace EMotionFX
return static_cast<MCore::AttributeBool*>(attrib);
}
MCORE_INLINE bool TryGetInputVector4(AnimGraphInstance* animGraphInstance, uint32 portNr, AZ::Vector4& outResult) const
MCORE_INLINE bool TryGetInputVector4(AnimGraphInstance* animGraphInstance, size_t portNr, AZ::Vector4& outResult) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -540,7 +540,7 @@ namespace EMotionFX
return false;
}
MCORE_INLINE bool TryGetInputVector2(AnimGraphInstance* animGraphInstance, uint32 portNr, AZ::Vector2& outResult) const
MCORE_INLINE bool TryGetInputVector2(AnimGraphInstance* animGraphInstance, size_t portNr, AZ::Vector2& outResult) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -568,7 +568,7 @@ namespace EMotionFX
return false;
}
MCORE_INLINE bool TryGetInputVector3(AnimGraphInstance* animGraphInstance, uint32 portNr, AZ::Vector3& outResult) const
MCORE_INLINE bool TryGetInputVector3(AnimGraphInstance* animGraphInstance, size_t portNr, AZ::Vector3& outResult) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -606,7 +606,7 @@ namespace EMotionFX
return false;
}
MCORE_INLINE MCore::AttributeQuaternion* GetInputQuaternion(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE MCore::AttributeQuaternion* GetInputQuaternion(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -617,7 +617,7 @@ namespace EMotionFX
return static_cast<MCore::AttributeQuaternion*>(attrib);
}
MCORE_INLINE MCore::AttributeColor* GetInputColor(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE MCore::AttributeColor* GetInputColor(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -627,7 +627,7 @@ namespace EMotionFX
MCORE_ASSERT(attrib->GetType() == MCore::AttributeColor::TYPE_ID);
return static_cast<MCore::AttributeColor*>(attrib);
}
MCORE_INLINE AttributeMotionInstance* GetInputMotionInstance(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE AttributeMotionInstance* GetInputMotionInstance(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -637,7 +637,7 @@ namespace EMotionFX
MCORE_ASSERT(attrib->GetType() == AttributeMotionInstance::TYPE_ID);
return static_cast<AttributeMotionInstance*>(attrib);
}
MCORE_INLINE AttributePose* GetInputPose(AnimGraphInstance* animGraphInstance, uint32 portNr) const
MCORE_INLINE AttributePose* GetInputPose(AnimGraphInstance* animGraphInstance, size_t portNr) const
{
MCore::Attribute* attrib = GetInputAttribute(animGraphInstance, portNr);
if (attrib == nullptr)
@@ -648,8 +648,8 @@ namespace EMotionFX
return static_cast<AttributePose*>(attrib);
}
MCORE_INLINE MCore::Attribute* GetOutputAttribute(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const { return mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance); }
MCORE_INLINE MCore::AttributeFloat* GetOutputNumber(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::Attribute* GetOutputAttribute(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const { return mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance); }
MCORE_INLINE MCore::AttributeFloat* GetOutputNumber(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -658,7 +658,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeFloat::TYPE_ID);
return static_cast<MCore::AttributeFloat*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeFloat* GetOutputFloat(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeFloat* GetOutputFloat(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -667,7 +667,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeFloat::TYPE_ID);
return static_cast<MCore::AttributeFloat*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeInt32* GetOutputInt32(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeInt32* GetOutputInt32(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -676,7 +676,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeInt32::TYPE_ID);
return static_cast<MCore::AttributeInt32*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeString* GetOutputString(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeString* GetOutputString(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -685,7 +685,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeString::TYPE_ID);
return static_cast<MCore::AttributeString*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeBool* GetOutputBool(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeBool* GetOutputBool(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -694,7 +694,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeBool::TYPE_ID);
return static_cast<MCore::AttributeBool*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeVector2* GetOutputVector2(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeVector2* GetOutputVector2(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -703,7 +703,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeVector2::TYPE_ID);
return static_cast<MCore::AttributeVector2*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeVector3* GetOutputVector3(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeVector3* GetOutputVector3(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -712,7 +712,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeVector3::TYPE_ID);
return static_cast<MCore::AttributeVector3*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeVector4* GetOutputVector4(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeVector4* GetOutputVector4(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -721,7 +721,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeVector4::TYPE_ID);
return static_cast<MCore::AttributeVector4*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeQuaternion* GetOutputQuaternion(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeQuaternion* GetOutputQuaternion(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -730,7 +730,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeQuaternion::TYPE_ID);
return static_cast<MCore::AttributeQuaternion*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE MCore::AttributeColor* GetOutputColor(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE MCore::AttributeColor* GetOutputColor(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -739,7 +739,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == MCore::AttributeColor::TYPE_ID);
return static_cast<MCore::AttributeColor*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE AttributePose* GetOutputPose(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE AttributePose* GetOutputPose(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -748,7 +748,7 @@ namespace EMotionFX
MCORE_ASSERT(mOutputPorts[outputPortIndex].mCompatibleTypes[0] == AttributePose::TYPE_ID);
return static_cast<AttributePose*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
MCORE_INLINE AttributeMotionInstance* GetOutputMotionInstance(AnimGraphInstance* animGraphInstance, uint32 outputPortIndex) const
MCORE_INLINE AttributeMotionInstance* GetOutputMotionInstance(AnimGraphInstance* animGraphInstance, size_t outputPortIndex) const
{
if (mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance) == nullptr)
{
@@ -758,18 +758,18 @@ namespace EMotionFX
return static_cast<AttributeMotionInstance*>(mOutputPorts[outputPortIndex].GetAttribute(animGraphInstance));
}
void SetupInputPortAsNumber(const char* name, uint32 inputPortNr, uint32 portID);
void SetupInputPortAsBool(const char* name, uint32 inputPortNr, uint32 portID);
void SetupInputPort(const char* name, uint32 inputPortNr, uint32 attributeTypeID, uint32 portID);
void SetupInputPortAsNumber(const char* name, size_t inputPortNr, uint32 portID);
void SetupInputPortAsBool(const char* name, size_t inputPortNr, uint32 portID);
void SetupInputPort(const char* name, size_t inputPortNr, uint32 attributeTypeID, uint32 portID);
void SetupInputPortAsVector3(const char* name, uint32 inputPortNr, uint32 portID);
void SetupInputPortAsVector2(const char* name, uint32 inputPortNr, uint32 portID);
void SetupInputPortAsVector4(const char* name, uint32 inputPortNr, uint32 portID);
void SetupInputPort(const char* name, uint32 inputPortNr, const AZStd::vector<uint32>& attributeTypeIDs, uint32 portID);
void SetupInputPortAsVector3(const char* name, size_t inputPortNr, uint32 portID);
void SetupInputPortAsVector2(const char* name, size_t inputPortNr, uint32 portID);
void SetupInputPortAsVector4(const char* name, size_t inputPortNr, uint32 portID);
void SetupInputPort(const char* name, size_t inputPortNr, const AZStd::vector<uint32>& attributeTypeIDs, uint32 portID);
void SetupOutputPort(const char* name, uint32 portIndex, uint32 attributeTypeID, uint32 portID);
void SetupOutputPortAsPose(const char* name, uint32 outputPortNr, uint32 portID);
void SetupOutputPortAsMotionInstance(const char* name, uint32 outputPortNr, uint32 portID);
void SetupOutputPort(const char* name, size_t portIndex, uint32 attributeTypeID, uint32 portID);
void SetupOutputPortAsPose(const char* name, size_t outputPortNr, uint32 portID);
void SetupOutputPortAsMotionInstance(const char* name, size_t outputPortNr, uint32 portID);
bool GetHasConnection(AnimGraphNode* sourceNode, uint16 sourcePort, uint16 targetPort) const;
BlendTreeConnection* FindConnection(const AnimGraphNode* sourceNode, uint16 sourcePort, uint16 targetPort) const;
@@ -801,24 +801,24 @@ namespace EMotionFX
const AZStd::vector<AnimGraphNode::Port>& GetOutputPorts() const { return mOutputPorts; }
void SetInputPorts(const AZStd::vector<AnimGraphNode::Port>& inputPorts) { mInputPorts = inputPorts; }
void SetOutputPorts(const AZStd::vector<AnimGraphNode::Port>& outputPorts) { mOutputPorts = outputPorts; }
void InitInputPorts(uint32 numPorts);
void InitOutputPorts(uint32 numPorts);
void SetInputPortName(uint32 portIndex, const char* name);
void SetOutputPortName(uint32 portIndex, const char* name);
uint32 FindOutputPortIndex(const AZStd::string& name) const;
uint32 FindInputPortIndex(const AZStd::string& name) const;
uint32 AddOutputPort();
uint32 AddInputPort();
void InitInputPorts(size_t numPorts);
void InitOutputPorts(size_t numPorts);
void SetInputPortName(size_t portIndex, const char* name);
void SetOutputPortName(size_t portIndex, const char* name);
size_t FindOutputPortIndex(const AZStd::string& name) const;
size_t FindInputPortIndex(const AZStd::string& name) const;
size_t AddOutputPort();
size_t AddInputPort();
virtual bool GetIsStateTransitionNode() const { return false; }
MCORE_INLINE MCore::Attribute* GetOutputValue(AnimGraphInstance* animGraphInstance, uint32 portIndex) const { return animGraphInstance->GetInternalAttribute(mOutputPorts[portIndex].mAttributeIndex); }
MCORE_INLINE Port& GetInputPort(uint32 index) { return mInputPorts[index]; }
MCORE_INLINE Port& GetOutputPort(uint32 index) { return mOutputPorts[index]; }
MCORE_INLINE const Port& GetInputPort(uint32 index) const { return mInputPorts[index]; }
MCORE_INLINE const Port& GetOutputPort(uint32 index) const { return mOutputPorts[index]; }
MCORE_INLINE MCore::Attribute* GetOutputValue(AnimGraphInstance* animGraphInstance, size_t portIndex) const { return animGraphInstance->GetInternalAttribute(mOutputPorts[portIndex].mAttributeIndex); }
MCORE_INLINE Port& GetInputPort(size_t index) { return mInputPorts[index]; }
MCORE_INLINE Port& GetOutputPort(size_t index) { return mOutputPorts[index]; }
MCORE_INLINE const Port& GetInputPort(size_t index) const { return mInputPorts[index]; }
MCORE_INLINE const Port& GetOutputPort(size_t index) const { return mOutputPorts[index]; }
void RelinkPortConnections();
MCORE_INLINE uint32 GetNumConnections() const { return static_cast<uint32>(mConnections.size()); }
MCORE_INLINE BlendTreeConnection* GetConnection(uint32 index) const { return mConnections[index]; }
MCORE_INLINE size_t GetNumConnections() const { return mConnections.size(); }
MCORE_INLINE BlendTreeConnection* GetConnection(size_t index) const { return mConnections[index]; }
const AZStd::vector<BlendTreeConnection*>& GetConnections() const { return mConnections; }
AZ_FORCE_INLINE AnimGraphNode* GetParentNode() const { return mParentNode; }
@@ -829,7 +829,7 @@ namespace EMotionFX
* @param[in] node The parent node we try to search.
* @result True in case the given node is the parent or the parent of the parent etc. of the node, false in case the given node wasn't found in any of the parents.
*/
virtual bool RecursiveIsParentNode(AnimGraphNode* node) const;
virtual bool RecursiveIsParentNode(const AnimGraphNode* node) const;
/**
* Check if the given node is a child or a child of a child etc. of the node.
@@ -857,14 +857,14 @@ namespace EMotionFX
* @param[in] name The name of the node to search.
* @return The index of the child node with the given name in case of success, in the other case MCORE_INVALIDINDEX32 will be returned.
*/
uint32 FindChildNodeIndex(const char* name) const;
size_t FindChildNodeIndex(const char* name) const;
/**
* Find child node index. This will only iterate through the child nodes and isn't a recursive process.
* @param[in] node A pointer to the node for which we want to find the child node index.
* @return The index of the child node in case of success, in the other case MCORE_INVALIDINDEX32 will be returned.
*/
uint32 FindChildNodeIndex(AnimGraphNode* node) const;
size_t FindChildNodeIndex(AnimGraphNode* node) const;
AnimGraphNode* FindFirstChildNodeOfType(const AZ::TypeId& nodeType) const;
@@ -875,22 +875,22 @@ namespace EMotionFX
*/
bool HasChildNodeOfType(const AZ::TypeId& nodeType) const;
uint32 RecursiveCalcNumNodes() const;
uint32 RecursiveCalcNumNodeConnections() const;
size_t RecursiveCalcNumNodes() const;
size_t RecursiveCalcNumNodeConnections() const;
void CopyBaseNodeTo(AnimGraphNode* node) const;
MCORE_INLINE uint32 GetNumChildNodes() const { return static_cast<uint32>(mChildNodes.size()); }
MCORE_INLINE AnimGraphNode* GetChildNode(uint32 index) const { return mChildNodes[index]; }
MCORE_INLINE size_t GetNumChildNodes() const { return mChildNodes.size(); }
MCORE_INLINE AnimGraphNode* GetChildNode(size_t index) const { return mChildNodes[index]; }
const AZStd::vector<AnimGraphNode*>& GetChildNodes() const { return mChildNodes; }
void SetNodeInfo(const AZStd::string& info);
const AZStd::string& GetNodeInfo() const;
void AddChildNode(AnimGraphNode* node);
void ReserveChildNodes(uint32 numChildNodes);
void ReserveChildNodes(size_t numChildNodes);
void RemoveChildNode(uint32 index, bool delFromMem = true);
void RemoveChildNode(size_t index, bool delFromMem = true);
void RemoveChildNodeByPointer(AnimGraphNode* node, bool delFromMem = true);
void RemoveAllChildNodes(bool delFromMem = true);
bool CheckIfHasChildOfType(const AZ::TypeId& nodeType) const; // non-recursive
@@ -916,7 +916,7 @@ namespace EMotionFX
void SetHasError(AnimGraphObjectData* uniqueData, bool hasError);
// collect internal objects
void RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const override;
void RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const override;
virtual void RecursiveSetUniqueDataFlag(AnimGraphInstance* animGraphInstance, uint32 flag, bool enabled);
void FilterEvents(AnimGraphInstance* animGraphInstance, EEventMode eventMode, AnimGraphNode* nodeA, AnimGraphNode* nodeB, float localWeight, AnimGraphRefCountedData* refData);
@@ -924,8 +924,8 @@ namespace EMotionFX
bool GetCanVisualize(AnimGraphInstance* animGraphInstance) const;
MCORE_INLINE uint32 GetNodeIndex() const { return mNodeIndex; }
MCORE_INLINE void SetNodeIndex(uint32 index) { mNodeIndex = index; }
MCORE_INLINE size_t GetNodeIndex() const { return mNodeIndex; }
MCORE_INLINE void SetNodeIndex(size_t index) { mNodeIndex = index; }
void ResetPoseRefCount(AnimGraphInstance* animGraphInstance);
MCORE_INLINE void IncreasePoseRefCount(AnimGraphInstance* animGraphInstance) { FindOrCreateUniqueNodeData(animGraphInstance)->IncreasePoseRefCount(); }
@@ -944,7 +944,7 @@ namespace EMotionFX
static void Reflect(AZ::ReflectContext* context);
protected:
uint32 mNodeIndex;
size_t mNodeIndex;
AZ::u64 m_id;
AZStd::vector<BlendTreeConnection*> mConnections;
AZStd::vector<Port> mInputPorts;
@@ -967,7 +967,7 @@ namespace EMotionFX
virtual void PostUpdate(AnimGraphInstance* animGraphInstance, float timePassedInSeconds);
void Update(AnimGraphInstance* animGraphInstance, float timePassedInSeconds) override;
void RecursiveCountChildNodes(uint32& numNodes) const;
void RecursiveCountNodeConnections(uint32& numConnections) const;
void RecursiveCountChildNodes(size_t& numNodes) const;
void RecursiveCountNodeConnections(size_t& numConnections) const;
};
} // namespace EMotionFX
@@ -26,7 +26,7 @@ namespace EMotionFX
, mPreSyncTime(0.0f)
, mGlobalWeight(1.0f)
, mLocalWeight(1.0f)
, mSyncIndex(MCORE_INVALIDINDEX32)
, mSyncIndex(InvalidIndex)
, mPoseRefCount(0)
, mRefDataRefCount(0)
, mInheritFlags(0)
@@ -55,7 +55,7 @@ namespace EMotionFX
mLocalWeight = 1.0f;
mInheritFlags = 0;
m_isMirrorMotion = false;
mSyncIndex = MCORE_INVALIDINDEX32;
mSyncIndex = InvalidIndex;
mSyncTrack = nullptr;
}
@@ -54,8 +54,8 @@ namespace EMotionFX
MCORE_INLINE AnimGraphNode* GetNode() const { return reinterpret_cast<AnimGraphNode*>(mObject); }
MCORE_INLINE void SetNode(AnimGraphNode* node) { mObject = reinterpret_cast<AnimGraphObject*>(node); }
MCORE_INLINE void SetSyncIndex(uint32 syncIndex) { mSyncIndex = syncIndex; }
MCORE_INLINE uint32 GetSyncIndex() const { return mSyncIndex; }
MCORE_INLINE void SetSyncIndex(size_t syncIndex) { mSyncIndex = syncIndex; }
MCORE_INLINE size_t GetSyncIndex() const { return mSyncIndex; }
MCORE_INLINE void SetCurrentPlayTime(float absoluteTime) { mCurrentTime = absoluteTime; }
MCORE_INLINE float GetCurrentPlayTime() const { return mCurrentTime; }
@@ -108,7 +108,7 @@ namespace EMotionFX
float mPreSyncTime;
float mGlobalWeight;
float mLocalWeight;
uint32 mSyncIndex; /**< The last used sync track index. */
size_t mSyncIndex; /**< The last used sync track index. */
uint8 mPoseRefCount;
uint8 mRefDataRefCount;
uint8 mInheritFlags;
@@ -30,7 +30,7 @@ namespace EMotionFX
}
AnimGraphNodeGroup::AnimGraphNodeGroup(const char* groupName, uint32 numNodes)
AnimGraphNodeGroup::AnimGraphNodeGroup(const char* groupName, size_t numNodes)
{
SetName(groupName);
SetNumNodes(numNodes);
@@ -100,28 +100,28 @@ namespace EMotionFX
// set the number of nodes
void AnimGraphNodeGroup::SetNumNodes(uint32 numNodes)
void AnimGraphNodeGroup::SetNumNodes(size_t numNodes)
{
mNodeIds.resize(numNodes);
}
// get the number of nodes
uint32 AnimGraphNodeGroup::GetNumNodes() const
size_t AnimGraphNodeGroup::GetNumNodes() const
{
return static_cast<uint32>(mNodeIds.size());
return mNodeIds.size();
}
// set a given node to a given node number
void AnimGraphNodeGroup::SetNode(uint32 index, AnimGraphNodeId nodeId)
void AnimGraphNodeGroup::SetNode(size_t index, AnimGraphNodeId nodeId)
{
mNodeIds[index] = nodeId;
}
// get the node number of a given index
AnimGraphNodeId AnimGraphNodeGroup::GetNode(uint32 index) const
AnimGraphNodeId AnimGraphNodeGroup::GetNode(size_t index) const
{
return mNodeIds[index];
}
@@ -147,7 +147,7 @@ namespace EMotionFX
// remove a given array element from the list of nodes
void AnimGraphNodeGroup::RemoveNodeByGroupIndex(uint32 index)
void AnimGraphNodeGroup::RemoveNodeByGroupIndex(size_t index)
{
mNodeIds.erase(mNodeIds.begin() + index);
}
@@ -41,7 +41,7 @@ namespace EMotionFX
* @param numNodes The number of nodes to create inside the group. This will have all uninitialized values for the node ids in the group, so be sure that you
* set them all to some valid node index using the AnimGraphNodeGroup::SetNode(...) method. This constructor automatically calls the SetNumNodes(...) method.
*/
AnimGraphNodeGroup(const char* groupName, uint32 numNodes);
AnimGraphNodeGroup(const char* groupName, size_t numNodes);
/**
* The destructor.
@@ -96,13 +96,13 @@ namespace EMotionFX
* This will resize the array of node ids. Don't forget to initialize the node values after increasing the number of nodes.
* @param numNodes The number of nodes that are inside this group.
*/
void SetNumNodes(uint32 numNodes);
void SetNumNodes(size_t numNodes);
/**
* Get the number of nodes that remain inside this group.
* @result The number of nodes inside this group.
*/
uint32 GetNumNodes() const;
size_t GetNumNodes() const;
/**
* Set the value of a given node.
@@ -110,14 +110,14 @@ namespace EMotionFX
* @param nodeID The value for the given node. This is the node id where this group will belong to.
* To get access to the actual node object use AnimGraph::RecursiveFindNodeByID( nodeID ).
*/
void SetNode(uint32 index, AnimGraphNodeId nodeId);
void SetNode(size_t index, AnimGraphNodeId nodeId);
/**
* Get the node id for a given node inside the group.
* @param index The node number inside this group, which must be in range of [0..GetNumNodes()-1].
* @result The node id, which points inside the Actor object. Use AnimGraph::RecursiveFindNodeByID( nodeID ) to get access to the node information.
*/
AnimGraphNodeId GetNode(uint32 index) const;
AnimGraphNodeId GetNode(size_t index) const;
/**
* Check if the node with the given id is inside the node group.
@@ -149,7 +149,7 @@ namespace EMotionFX
* @param index The node index in the group. So for example an index value of 5 will remove the sixth node from the group.
* The index value must be in range of [0..GetNumNodes() - 1].
*/
void RemoveNodeByGroupIndex(uint32 index);
void RemoveNodeByGroupIndex(size_t index);
/**
* Clear the node group. This removes all nodes.
@@ -89,7 +89,7 @@ namespace EMotionFX
// save and return number of bytes written, when outputBuffer is nullptr only return num bytes it would write
uint32 AnimGraphObject::SaveUniqueData(AnimGraphInstance* animGraphInstance, uint8* outputBuffer) const
size_t AnimGraphObject::SaveUniqueData(AnimGraphInstance* animGraphInstance, uint8* outputBuffer) const
{
AnimGraphObjectData* data = animGraphInstance->FindOrCreateUniqueObjectData(this);
if (data)
@@ -103,7 +103,7 @@ namespace EMotionFX
// load and return number of bytes read, when dataBuffer is nullptr, 0 should be returned
uint32 AnimGraphObject::LoadUniqueData(AnimGraphInstance* animGraphInstance, const uint8* dataBuffer)
size_t AnimGraphObject::LoadUniqueData(AnimGraphInstance* animGraphInstance, const uint8* dataBuffer)
{
AnimGraphObjectData* data = animGraphInstance->FindOrCreateUniqueObjectData(this);
if (data)
@@ -116,9 +116,9 @@ namespace EMotionFX
// collect internal objects
void AnimGraphObject::RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const
void AnimGraphObject::RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const
{
outObjects.Add(const_cast<AnimGraphObject*>(this));
outObjects.emplace_back(const_cast<AnimGraphObject*>(this));
}
void AnimGraphObject::InvalidateUniqueDatas()
@@ -220,7 +220,7 @@ namespace EMotionFX
// decrease internal attribute indices for index values higher than the specified parameter
void AnimGraphObject::DecreaseInternalAttributeIndices(uint32 decreaseEverythingHigherThan)
void AnimGraphObject::DecreaseInternalAttributeIndices(size_t decreaseEverythingHigherThan)
{
MCORE_UNUSED(decreaseEverythingHigherThan);
// currently no implementation for the base object type, but this will come later
@@ -15,7 +15,7 @@
#include <MCore/Source/Stream.h>
#include <MCore/Source/CommandLine.h>
#include <MCore/Source/Color.h>
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
#include <MCore/Source/Attribute.h>
#include <MCore/Source/AttributeFloat.h>
#include <MCore/Source/AttributeInt32.h>
@@ -134,7 +134,7 @@ namespace EMotionFX
void InitInternalAttributesForAllInstances(); // does the init for all anim graph instances in the parent animgraph
virtual void InitInternalAttributes(AnimGraphInstance* animGraphInstance);
virtual void RemoveInternalAttributesForAllInstances();
virtual void DecreaseInternalAttributeIndices(uint32 decreaseEverythingHigherThan);
virtual void DecreaseInternalAttributeIndices(size_t decreaseEverythingHigherThan);
virtual void Update(AnimGraphInstance* animGraphInstance, float timePassedInSeconds);
@@ -144,16 +144,16 @@ namespace EMotionFX
virtual void RecursiveOnChangeMotionSet(AnimGraphInstance* animGraphInstance, MotionSet* newMotionSet) { MCORE_UNUSED(animGraphInstance); MCORE_UNUSED(newMotionSet); }
virtual void OnActorMotionExtractionNodeChanged() {}
MCORE_INLINE uint32 GetObjectIndex() const { return mObjectIndex; }
MCORE_INLINE void SetObjectIndex(size_t index) { mObjectIndex = static_cast<uint32>(index); }
MCORE_INLINE size_t GetObjectIndex() const { return mObjectIndex; }
MCORE_INLINE void SetObjectIndex(size_t index) { mObjectIndex = index; }
MCORE_INLINE AnimGraph* GetAnimGraph() const { return mAnimGraph; }
MCORE_INLINE void SetAnimGraph(AnimGraph* animGraph) { mAnimGraph = animGraph; }
uint32 SaveUniqueData(AnimGraphInstance* animGraphInstance, uint8* outputBuffer) const; // save and return number of bytes written, when outputBuffer is nullptr only return num bytes it would write
uint32 LoadUniqueData(AnimGraphInstance* animGraphInstance, const uint8* dataBuffer); // load and return number of bytes read, when dataBuffer is nullptr, 0 should be returned
size_t SaveUniqueData(AnimGraphInstance* animGraphInstance, uint8* outputBuffer) const; // save and return number of bytes written, when outputBuffer is nullptr only return num bytes it would write
size_t LoadUniqueData(AnimGraphInstance* animGraphInstance, const uint8* dataBuffer); // load and return number of bytes read, when dataBuffer is nullptr, 0 should be returned
virtual void RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const;
virtual void RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const;
bool GetHasErrorFlag(AnimGraphInstance* animGraphInstance) const;
void SetHasErrorFlag(AnimGraphInstance* animGraphInstance, bool hasError);
@@ -167,7 +167,7 @@ namespace EMotionFX
protected:
AnimGraph* mAnimGraph;
uint32 mObjectIndex;
size_t mObjectIndex;
};
} // namespace EMotionFX
@@ -39,7 +39,7 @@ namespace EMotionFX
void LinkToActorInstance(const ActorInstance* actorInstance);
void InitFromBindPose(const ActorInstance* actorInstance);
MCORE_INLINE uint32 GetNumNodes() const { return mPose.GetNumTransforms(); }
MCORE_INLINE size_t GetNumNodes() const { return mPose.GetNumTransforms(); }
MCORE_INLINE const Pose& GetPose() const { return mPose; }
MCORE_INLINE Pose& GetPose() { return mPose; }
MCORE_INLINE void SetPose(const Pose& pose) { mPose = pose; }
@@ -16,10 +16,8 @@ namespace EMotionFX
// constructor
AnimGraphPosePool::AnimGraphPosePool()
{
mPoses.SetMemoryCategory(EMFX_MEMCATEGORY_ANIMGRAPH_POSEPOOL);
mFreePoses.SetMemoryCategory(EMFX_MEMCATEGORY_ANIMGRAPH_POSEPOOL);
mPoses.Reserve(12);
mFreePoses.Reserve(12);
mPoses.reserve(12);
mFreePoses.reserve(12);
Resize(8);
mMaxUsed = 0;
}
@@ -29,44 +27,43 @@ namespace EMotionFX
AnimGraphPosePool::~AnimGraphPosePool()
{
// delete all poses
const uint32 numPoses = mPoses.GetLength();
for (uint32 i = 0; i < numPoses; ++i)
for (AnimGraphPose* pose : mPoses)
{
delete mPoses[i];
delete pose;
}
mPoses.Clear();
mPoses.clear();
// clear the free array
mFreePoses.Clear();
mFreePoses.clear();
}
// resize the number of poses in the pool
void AnimGraphPosePool::Resize(uint32 numPoses)
void AnimGraphPosePool::Resize(size_t numPoses)
{
const uint32 numOldPoses = mPoses.GetLength();
const size_t numOldPoses = mPoses.size();
// if we will remove poses
int32 difference = numPoses - numOldPoses;
if (difference < 0)
if (numPoses < numOldPoses)
{
// remove the last poses
difference = abs(difference);
for (int32 i = 0; i < difference; ++i)
const size_t numToRemove = numOldPoses - numPoses;
for (size_t i = 0; i < numToRemove; ++i)
{
AnimGraphPose* pose = mPoses[mFreePoses.GetLength() - 1];
MCORE_ASSERT(mFreePoses.Contains(pose)); // make sure the pose is not already in use
AnimGraphPose* pose = mPoses.back();
MCORE_ASSERT(AZStd::find(begin(mFreePoses), end(mFreePoses), pose) == end(mFreePoses)); // make sure the pose is not already in use
delete pose;
mPoses.Remove(mFreePoses.GetLength() - 1);
mPoses.erase(mFreePoses.end() - 1);
}
}
else // we want to add new poses
{
for (int32 i = 0; i < difference; ++i)
const size_t numToAdd = numPoses - numOldPoses;
for (size_t i = 0; i < numToAdd; ++i)
{
AnimGraphPose* newPose = new AnimGraphPose();
mPoses.Add(newPose);
mFreePoses.Add(newPose);
mPoses.emplace_back(newPose);
mFreePoses.emplace_back(newPose);
}
}
}
@@ -76,22 +73,22 @@ namespace EMotionFX
AnimGraphPose* AnimGraphPosePool::RequestPose(const ActorInstance* actorInstance)
{
// if we have no free poses left, allocate a new one
if (mFreePoses.GetLength() == 0)
if (mFreePoses.empty())
{
AnimGraphPose* newPose = new AnimGraphPose();
newPose->LinkToActorInstance(actorInstance);
mPoses.Add(newPose);
mMaxUsed = MCore::Max<uint32>(mMaxUsed, GetNumUsedPoses());
mPoses.emplace_back(newPose);
mMaxUsed = AZStd::max(mMaxUsed, GetNumUsedPoses());
newPose->SetIsInUse(true);
return newPose;
}
// request the last free pose
AnimGraphPose* pose = mFreePoses[mFreePoses.GetLength() - 1];
AnimGraphPose* pose = mFreePoses[mFreePoses.size() - 1];
//if (pose->GetActorInstance() != actorInstance)
pose->LinkToActorInstance(actorInstance);
mFreePoses.RemoveLast(); // remove it from the list of free poses
mMaxUsed = MCore::Max<uint32>(mMaxUsed, GetNumUsedPoses());
mFreePoses.pop_back(); // remove it from the list of free poses
mMaxUsed = AZStd::max(mMaxUsed, GetNumUsedPoses());
pose->SetIsInUse(true);
return pose;
}
@@ -101,7 +98,7 @@ namespace EMotionFX
void AnimGraphPosePool::FreePose(AnimGraphPose* pose)
{
//MCORE_ASSERT( mPoses.Contains(pose) );
mFreePoses.Add(pose);
mFreePoses.emplace_back(pose);
pose->SetIsInUse(false);
}
@@ -109,10 +106,8 @@ namespace EMotionFX
// free all poses
void AnimGraphPosePool::FreeAllPoses()
{
const uint32 numPoses = mPoses.GetLength();
for (uint32 i = 0; i < numPoses; ++i)
for (AnimGraphPose* curPose : mPoses)
{
AnimGraphPose* curPose = mPoses[i];
if (curPose->GetIsInUse())
{
FreePose(curPose);
@@ -10,7 +10,7 @@
// include required headers
#include "EMotionFXConfig.h"
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
@@ -34,22 +34,22 @@ namespace EMotionFX
AnimGraphPosePool();
~AnimGraphPosePool();
void Resize(uint32 numPoses);
void Resize(size_t numPoses);
AnimGraphPose* RequestPose(const ActorInstance* actorInstance);
void FreePose(AnimGraphPose* pose);
void FreeAllPoses();
MCORE_INLINE uint32 GetNumFreePoses() const { return mFreePoses.GetLength(); }
MCORE_INLINE uint32 GetNumPoses() const { return mPoses.GetLength(); }
MCORE_INLINE uint32 GetNumUsedPoses() const { return (mPoses.GetLength() - mFreePoses.GetLength()); }
MCORE_INLINE uint32 GetNumMaxUsedPoses() const { return mMaxUsed; }
MCORE_INLINE size_t GetNumFreePoses() const { return mFreePoses.size(); }
MCORE_INLINE size_t GetNumPoses() const { return mPoses.size(); }
MCORE_INLINE size_t GetNumUsedPoses() const { return mPoses.size() - mFreePoses.size(); }
MCORE_INLINE size_t GetNumMaxUsedPoses() const { return mMaxUsed; }
MCORE_INLINE void ResetMaxUsedPoses() { mMaxUsed = 0; }
private:
MCore::Array<AnimGraphPose*> mPoses;
MCore::Array<AnimGraphPose*> mFreePoses;
uint32 mMaxUsed;
AZStd::vector<AnimGraphPose*> mPoses;
AZStd::vector<AnimGraphPose*> mFreePoses;
size_t mMaxUsed;
};
} // namespace EMotionFX
@@ -8,6 +8,8 @@
// include required headers
#include "AnimGraphRefCountedDataPool.h"
#include <MCore/Source/FastMath.h>
#include <MCore/Source/Algorithms.h>
namespace EMotionFX
@@ -15,10 +17,8 @@ namespace EMotionFX
// constructor
AnimGraphRefCountedDataPool::AnimGraphRefCountedDataPool()
{
mItems.SetMemoryCategory(EMFX_MEMCATEGORY_ANIMGRAPH_REFCOUNTEDDATA);
mFreeItems.SetMemoryCategory(EMFX_MEMCATEGORY_ANIMGRAPH_REFCOUNTEDDATA);
mItems.Reserve(32);
mFreeItems.Reserve(32);
mItems.reserve(32);
mFreeItems.reserve(32);
Resize(16);
mMaxUsed = 0;
}
@@ -28,44 +28,43 @@ namespace EMotionFX
AnimGraphRefCountedDataPool::~AnimGraphRefCountedDataPool()
{
// delete all items
const uint32 numItems = mItems.GetLength();
for (uint32 i = 0; i < numItems; ++i)
for (AnimGraphRefCountedData*& item : mItems)
{
delete mItems[i];
delete item;
}
mItems.Clear();
mItems.clear();
// clear the free array
mFreeItems.Clear();
mFreeItems.clear();
}
// resize the number of items in the pool
void AnimGraphRefCountedDataPool::Resize(uint32 numItems)
void AnimGraphRefCountedDataPool::Resize(size_t numItems)
{
const uint32 numOldItems = mItems.GetLength();
const size_t numOldItems = mItems.size();
// if we will remove Items
int32 difference = numItems - numOldItems;
if (difference < 0)
if (numItems < numOldItems)
{
// remove the last Items
difference = abs(difference);
for (int32 i = 0; i < difference; ++i)
const size_t numToRemove = numOldItems - numItems;
for (size_t i = 0; i < numToRemove; ++i)
{
AnimGraphRefCountedData* item = mItems[mFreeItems.GetLength() - 1];
MCORE_ASSERT(mFreeItems.Contains(item)); // make sure the Item is not already in use
AnimGraphRefCountedData* item = mItems.back();
MCORE_ASSERT(AZStd::find(begin(mFreeItems), end(mFreeItems), item) != end(mFreeItems)); // make sure the Item is not already in use
delete item;
mItems.Remove(mFreeItems.GetLength() - 1);
mItems.erase(mItems.end() - 1);
}
}
else // we want to add new Items
{
for (int32 i = 0; i < difference; ++i)
const size_t numToAdd = numItems - numOldItems;
for (size_t i = 0; i < numToAdd; ++i)
{
AnimGraphRefCountedData* newItem = new AnimGraphRefCountedData();
mItems.Add(newItem);
mFreeItems.Add(newItem);
mItems.emplace_back(newItem);
mFreeItems.emplace_back(newItem);
}
}
}
@@ -75,18 +74,18 @@ namespace EMotionFX
AnimGraphRefCountedData* AnimGraphRefCountedDataPool::RequestNew()
{
// if we have no free items left, allocate a new one
if (mFreeItems.GetLength() == 0)
if (mFreeItems.empty())
{
AnimGraphRefCountedData* newItem = new AnimGraphRefCountedData();
mItems.Add(newItem);
mMaxUsed = MCore::Max<uint32>(mMaxUsed, GetNumUsedItems());
mItems.emplace_back(newItem);
mMaxUsed = AZStd::max(mMaxUsed, GetNumUsedItems());
return newItem;
}
// request the last free item
AnimGraphRefCountedData* item = mFreeItems[mFreeItems.GetLength() - 1];
mFreeItems.RemoveLast(); // remove it from the list of free Items
mMaxUsed = MCore::Max<uint32>(mMaxUsed, GetNumUsedItems());
AnimGraphRefCountedData* item = mFreeItems[mFreeItems.size() - 1];
mFreeItems.pop_back(); // remove it from the list of free Items
mMaxUsed = AZStd::max(mMaxUsed, GetNumUsedItems());
return item;
}
@@ -94,7 +93,7 @@ namespace EMotionFX
// free the item again
void AnimGraphRefCountedDataPool::Free(AnimGraphRefCountedData* item)
{
MCORE_ASSERT(mItems.Contains(item));
mFreeItems.Add(item);
MCORE_ASSERT(AZStd::find(begin(mItems), end(mItems), item) != end(mItems));
mFreeItems.emplace_back(item);
}
} // namespace EMotionFX
@@ -11,7 +11,7 @@
// include required headers
#include "EMotionFXConfig.h"
#include "AnimGraphRefCountedData.h"
#include <MCore/Source/Array.h>
#include <AzCore/std/containers/vector.h>
namespace EMotionFX
@@ -29,20 +29,20 @@ namespace EMotionFX
AnimGraphRefCountedDataPool();
~AnimGraphRefCountedDataPool();
void Resize(uint32 numItems);
void Resize(size_t numItems);
AnimGraphRefCountedData* RequestNew();
void Free(AnimGraphRefCountedData* item);
MCORE_INLINE uint32 GetNumFreeItems() const { return mFreeItems.GetLength(); }
MCORE_INLINE uint32 GetNumItems() const { return mItems.GetLength(); }
MCORE_INLINE uint32 GetNumUsedItems() const { return (mItems.GetLength() - mFreeItems.GetLength()); }
MCORE_INLINE uint32 GetNumMaxUsedItems() const { return mMaxUsed; }
MCORE_INLINE size_t GetNumFreeItems() const { return mFreeItems.size(); }
MCORE_INLINE size_t GetNumItems() const { return mItems.size(); }
MCORE_INLINE size_t GetNumUsedItems() const { return mItems.size() - mFreeItems.size(); }
MCORE_INLINE size_t GetNumMaxUsedItems() const { return mMaxUsed; }
MCORE_INLINE void ResetMaxUsedItems() { mMaxUsed = 0; }
private:
MCore::Array<AnimGraphRefCountedData*> mItems;
MCore::Array<AnimGraphRefCountedData*> mFreeItems;
uint32 mMaxUsed;
AZStd::vector<AnimGraphRefCountedData*> mItems;
AZStd::vector<AnimGraphRefCountedData*> mFreeItems;
size_t mMaxUsed;
};
} // namespace EMotionFX
@@ -56,7 +56,7 @@ namespace EMotionFX
// to the non-existing old anim graph, while the new one is about to be loaded asynchronously.
// In case the asset already got destroyed (AnimGraphAssetHandler::DestroyAsset()), it removed all anim graph instances already.
if (GetAnimGraphManager().FindAnimGraphInstanceIndex(m_referencedAnimGraphInstance) != InvalidIndex32)
if (GetAnimGraphManager().FindAnimGraphInstanceIndex(m_referencedAnimGraphInstance) != InvalidIndex)
{
m_referencedAnimGraphInstance->Destroy();
}
@@ -375,8 +375,8 @@ namespace EMotionFX
// Release any left over ref data for the referenced anim graph instance.
const uint32 threadIndex = referencedAnimGraphInstance->GetActorInstance()->GetThreadIndex();
AnimGraphRefCountedDataPool& refDataPool = GetEMotionFX().GetThreadData(threadIndex)->GetRefCountedDataPool();
const uint32 numReferencedNodes = referencedAnimGraph->GetNumNodes();
for (uint32 i = 0; i < numReferencedNodes; ++i)
const size_t numReferencedNodes = referencedAnimGraph->GetNumNodes();
for (size_t i = 0; i < numReferencedNodes; ++i)
{
const AnimGraphNode* node = referencedAnimGraph->GetNode(i);
AnimGraphNodeData* nodeData = static_cast<AnimGraphNodeData*>(referencedAnimGraphInstance->GetUniqueObjectData(node->GetObjectIndex()));
@@ -499,7 +499,7 @@ namespace EMotionFX
}
void AnimGraphReferenceNode::RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const
void AnimGraphReferenceNode::RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const
{
AnimGraphNode::RecursiveCollectObjects(outObjects);
@@ -98,7 +98,7 @@ namespace EMotionFX
void RecursiveCollectActiveNodes(AnimGraphInstance* animGraphInstance, AZStd::vector<AnimGraphNode*>* outNodes, const AZ::TypeId& nodeType) const override;
AnimGraphPose* GetMainOutputPose(AnimGraphInstance* animGraphInstance) const override;
void RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const override;
void RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const override;
void RecursiveCollectObjectsAffectedBy(AnimGraph* animGraph, AZStd::vector<AnimGraphObject*>& outObjects) const override;
bool RecursiveDetectCycles(AZStd::unordered_set<const AnimGraphNode*>& nodes) const override;
@@ -41,7 +41,7 @@ namespace EMotionFX
const size_t numValueParameters = instance.GetAnimGraph()->GetNumValueParameters();
for (size_t i = 0; i < numValueParameters; ++i)
{
m_parameters.emplace_back(instance.GetParameterValue(static_cast<AZ::u32>(i))->Clone());
m_parameters.emplace_back(instance.GetParameterValue(i)->Clone());
}
}
@@ -62,7 +62,7 @@ namespace EMotionFX
return m_parameters;
}
void AnimGraphSnapshot::SetActiveNodes(const AZStd::vector<AZ::u32>& activeNodes)
void AnimGraphSnapshot::SetActiveNodes(const NodeIndexContainer& activeNodes)
{
if (m_activeStateNodes != activeNodes)
{
@@ -71,7 +71,7 @@ namespace EMotionFX
}
}
const AZStd::vector<AZ::u32>& AnimGraphSnapshot::GetActiveNodes() const
const NodeIndexContainer& AnimGraphSnapshot::GetActiveNodes() const
{
return m_activeStateNodes;
}
@@ -94,7 +94,7 @@ namespace EMotionFX
for (size_t i = 0; i < numParams; ++i)
{
m_parameters[i]->InitFrom(instance.GetParameterValue(static_cast<AZ::u32>(i)));
m_parameters[i]->InitFrom(instance.GetParameterValue(i));
}
}
@@ -111,7 +111,7 @@ namespace EMotionFX
AnimGraphNode* currentState = stateMachine->GetCurrentState(&instance);
AZ_Assert(currentState, "There should always be a valid current state.");
m_activeStateNodes.emplace_back(currentState->GetNodeIndex());
m_activeStateNodes.emplace_back(aznumeric_caster(currentState->GetNodeIndex()));
}
}
@@ -123,9 +123,9 @@ namespace EMotionFX
for (const AnimGraphNode* animGraphNode : tempGraphNodes)
{
const AZ::u32 nodeIndex = animGraphNode->GetNodeIndex();
const size_t nodeIndex = animGraphNode->GetNodeIndex();
float normalizedPlaytime = animGraphNode->GetCurrentPlayTime(&instance) / animGraphNode->GetDuration(&instance);
m_motionNodePlaytimes.emplace_back(nodeIndex, normalizedPlaytime);
m_motionNodePlaytimes.emplace_back(aznumeric_caster(nodeIndex), normalizedPlaytime);
}
}
@@ -135,14 +135,14 @@ namespace EMotionFX
for (size_t i = 0; i < numParams; ++i)
{
MCore::Attribute* attribute = instance.GetParameterValue(static_cast<AZ::u32>(i));
MCore::Attribute* attribute = instance.GetParameterValue(i);
attribute->InitFrom(m_parameters[i]);
}
}
void AnimGraphSnapshot::RestoreActiveNodes(AnimGraphInstance& instance)
{
for (const AZ::u32 nodeIndex : m_activeStateNodes)
for (const size_t nodeIndex : m_activeStateNodes)
{
AnimGraphNode* node = instance.GetAnimGraph()->GetNode(nodeIndex);
AnimGraphNode* parent = node->GetParentNode();
@@ -36,7 +36,7 @@ namespace EMotionFX
AnimGraphStateMachine::AnimGraphStateMachine()
: AnimGraphNode()
, mEntryState(nullptr)
, mEntryStateNodeNr(MCORE_INVALIDINDEX32)
, mEntryStateNodeNr(InvalidIndex)
, m_entryStateId(AnimGraphNodeId::InvalidId)
, m_alwaysStartInEntryState(true)
{
@@ -204,7 +204,6 @@ namespace EMotionFX
bool requestInterruption = false;
const bool isTransitioning = IsTransitioning(animGraphInstance);
AnimGraphStateTransition* latestActiveTransition = GetLatestActiveTransition(uniqueData);
const AnimGraphNodeId sourceNodeId = sourceNode->GetId();
for (AnimGraphStateTransition* curTransition : mTransitions)
{
@@ -423,7 +422,6 @@ namespace EMotionFX
AnimGraphNode* targetState = transition->GetTargetNode();
AnimGraphStateTransition* latestActiveTransition = GetLatestActiveTransition(uniqueData);
const bool isLatestTransition = (latestActiveTransition == transition);
const bool isDone = transition->GetIsDone(animGraphInstance);
EventManager& eventManager = GetEventManager();
// End transition and emit transition events.
@@ -973,7 +971,7 @@ namespace EMotionFX
// Legacy file format way.
if (!mEntryState)
{
if (mEntryStateNodeNr != MCORE_INVALIDINDEX32 && mEntryStateNodeNr < GetNumChildNodes())
if (mEntryStateNodeNr != InvalidIndex && mEntryStateNodeNr < GetNumChildNodes())
{
mEntryState = GetChildNode(mEntryStateNodeNr);
}
@@ -1095,11 +1093,11 @@ namespace EMotionFX
AZ_Assert(stateMachine, "Unique data linked to incorrect node type.");
// check if any of the active states are invalid and reset them if they are
if (mCurrentState && stateMachine->FindChildNodeIndex(mCurrentState) == MCORE_INVALIDINDEX32)
if (mCurrentState && stateMachine->FindChildNodeIndex(mCurrentState) == InvalidIndex)
{
mCurrentState = nullptr;
}
if (mPreviousState && stateMachine->FindChildNodeIndex(mPreviousState) == MCORE_INVALIDINDEX32)
if (mPreviousState && stateMachine->FindChildNodeIndex(mPreviousState) == InvalidIndex)
{
mPreviousState = nullptr;
}
@@ -1113,8 +1111,8 @@ namespace EMotionFX
const bool isTransitionValid = transition &&
stateMachine->FindTransitionIndex(transition).IsSuccess() &&
stateMachine->FindChildNodeIndex(transition->GetSourceNode(GetAnimGraphInstance())) != MCORE_INVALIDINDEX32 &&
stateMachine->FindChildNodeIndex(transition->GetTargetNode()) != MCORE_INVALIDINDEX32;
stateMachine->FindChildNodeIndex(transition->GetSourceNode(GetAnimGraphInstance())) != InvalidIndex &&
stateMachine->FindChildNodeIndex(transition->GetTargetNode()) != InvalidIndex;
if (!isTransitionValid)
{
@@ -1277,7 +1275,7 @@ namespace EMotionFX
return result;
}
void AnimGraphStateMachine::RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const
void AnimGraphStateMachine::RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const
{
for (const AnimGraphStateTransition* transition : mTransitions)
{
@@ -95,7 +95,7 @@ namespace EMotionFX
AnimGraphPose* GetMainOutputPose(AnimGraphInstance* animGraphInstance) const override { return GetOutputPose(animGraphInstance, OUTPUTPORT_POSE)->GetValue(); }
void RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const override;
void RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const override;
void RecursiveCollectObjectsOfType(const AZ::TypeId& objectType, AZStd::vector<AnimGraphObject*>& outObjects) const override;
@@ -267,7 +267,7 @@ namespace EMotionFX
private:
AZStd::vector<AnimGraphStateTransition*> mTransitions; /**< The higher the index, the older the active transtion, the more time passed since it got started. Index = 0 is the most recent transition and the one with the highest global influence.*/
AnimGraphNode* mEntryState; /**< A pointer to the initial state, so the state where the machine starts. */
uint32 mEntryStateNodeNr; /**< Used only in the legacy file format. Remove after the legacy file format will be removed. */
size_t mEntryStateNodeNr; /**< Used only in the legacy file format. Remove after the legacy file format will be removed. */
AZ::u64 m_entryStateId; /**< The node id of the entry state. */
bool m_alwaysStartInEntryState;
@@ -117,8 +117,8 @@ namespace EMotionFX
continue;
}
const AZ::u32 numNodes = nodeGroup->GetNumNodes();
for (AZ::u32 i = 0; i < numNodes; ++i)
const size_t numNodes = nodeGroup->GetNumNodes();
for (size_t i = 0; i < numNodes; ++i)
{
AnimGraphNodeId nodeId = nodeGroup->GetNode(i);
AnimGraphNode* node = stateMachine->FindChildNodeById(nodeId);
@@ -663,14 +663,14 @@ namespace EMotionFX
}
// add all sub objects
void AnimGraphStateTransition::RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const
void AnimGraphStateTransition::RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const
{
for (const AnimGraphTransitionCondition* condition : mConditions)
{
condition->RecursiveCollectObjects(outObjects);
}
outObjects.Add(const_cast<AnimGraphStateTransition*>(this));
outObjects.emplace_back(const_cast<AnimGraphStateTransition*>(this));
}
// calculate the blend weight, based on the type of smoothing
@@ -120,7 +120,7 @@ namespace EMotionFX
AnimGraphObjectData* CreateUniqueData(AnimGraphInstance* animGraphInstance) override { return aznew UniqueData(this, animGraphInstance); }
void InvalidateUniqueData(AnimGraphInstance* animGraphInstance) override;
void RecursiveCollectObjects(MCore::Array<AnimGraphObject*>& outObjects) const override;
void RecursiveCollectObjects(AZStd::vector<AnimGraphObject*>& outObjects) const override;
void ExtractMotion(AnimGraphInstance* animGraphInstance, AnimGraphRefCountedData* sourceData, Transform* outTransform, Transform* outTransformMirrored) const;
void OnStartTransition(AnimGraphInstance* animGraphInstance);
@@ -114,8 +114,8 @@ namespace EMotionFX
const size_t numEvents = m_events.size();
if (numEvents == 0 || timeInSeconds > GetDuration() || timeInSeconds < 0.0f)
{
*outIndexA = MCORE_INVALIDINDEX32;
*outIndexB = MCORE_INVALIDINDEX32;
*outIndexA = InvalidIndex;
*outIndexB = InvalidIndex;
return false;
}
@@ -189,7 +189,7 @@ namespace EMotionFX
}
// actually we didn't find this combination
return MCORE_INVALIDINDEX32;
return InvalidIndex;
}
@@ -200,8 +200,8 @@ namespace EMotionFX
const size_t numEvents = m_events.size();
if (numEvents == 0)
{
*outIndexA = MCORE_INVALIDINDEX32;
*outIndexB = MCORE_INVALIDINDEX32;
*outIndexA = InvalidIndex;
*outIndexB = InvalidIndex;
return false;
}
@@ -217,8 +217,8 @@ namespace EMotionFX
}
else
{
*outIndexA = MCORE_INVALIDINDEX32;
*outIndexB = MCORE_INVALIDINDEX32;
*outIndexA = InvalidIndex;
*outIndexB = InvalidIndex;
return false;
}
}
@@ -271,15 +271,15 @@ namespace EMotionFX
// if we didn't find a single hit we won't find any other
if (found == false)
{
*outIndexA = MCORE_INVALIDINDEX32;
*outIndexB = MCORE_INVALIDINDEX32;
*outIndexA = InvalidIndex;
*outIndexB = InvalidIndex;
return false;
}
}
// we didn't find it
*outIndexA = MCORE_INVALIDINDEX32;
*outIndexB = MCORE_INVALIDINDEX32;
*outIndexA = InvalidIndex;
*outIndexB = InvalidIndex;
return false;
}
@@ -307,8 +307,8 @@ namespace EMotionFX
current = AdvanceAndWrapIterator(current, forward, m_events.cbegin(), m_events.cend());
} while (current != start);
*outIndexA = MCORE_INVALIDINDEX32;
*outIndexB = MCORE_INVALIDINDEX32;
*outIndexA = InvalidIndex;
*outIndexB = InvalidIndex;
return false;
};
@@ -319,13 +319,13 @@ namespace EMotionFX
const size_t numEvents = m_events.size();
if (numEvents == 0)
{
*outIndexA = MCORE_INVALIDINDEX32;
*outIndexB = MCORE_INVALIDINDEX32;
*outIndexA = InvalidIndex;
*outIndexB = InvalidIndex;
return false;
}
// if the sync index is not set, start at the first pair (which starts from the last sync key)
if (syncIndex == MCORE_INVALIDINDEX32)
if (syncIndex == InvalidIndex)
{
if (forward)
{
@@ -19,7 +19,7 @@ namespace EMotionFX
{
AZ_CLASS_ALLOCATOR_IMPL(AttachmentNode, AttachmentAllocator, 0)
AttachmentNode::AttachmentNode(ActorInstance* attachToActorInstance, AZ::u32 attachToNodeIndex, ActorInstance* attachment, bool managedExternally)
AttachmentNode::AttachmentNode(ActorInstance* attachToActorInstance, size_t attachToNodeIndex, ActorInstance* attachment, bool managedExternally)
: Attachment(attachToActorInstance, attachment)
, m_attachedToNode(attachToNodeIndex)
, m_isManagedExternally(managedExternally)
@@ -33,7 +33,7 @@ namespace EMotionFX
}
AttachmentNode* AttachmentNode::Create(ActorInstance* attachToActorInstance, AZ::u32 attachToNodeIndex, ActorInstance* attachment, bool managedExternally)
AttachmentNode* AttachmentNode::Create(ActorInstance* attachToActorInstance, size_t attachToNodeIndex, ActorInstance* attachment, bool managedExternally)
{
return aznew AttachmentNode(attachToActorInstance, attachToNodeIndex, attachment, managedExternally);
}
@@ -55,7 +55,7 @@ namespace EMotionFX
}
uint32 AttachmentNode::GetAttachToNodeIndex() const
size_t AttachmentNode::GetAttachToNodeIndex() const
{
return m_attachedToNode;
}
@@ -44,7 +44,7 @@ namespace EMotionFX
* @param attachment The actor instance that you want to attach to this node (for example a gun).
* @param managedExternally Specify whether the parent transform (where we are attached to) propagates into the attachment actor instance.
*/
static AttachmentNode* Create(ActorInstance* attachToActorInstance, AZ::u32 attachToNodeIndex, ActorInstance* attachment, bool managedExternally = false);
static AttachmentNode* Create(ActorInstance* attachToActorInstance, size_t attachToNodeIndex, ActorInstance* attachment, bool managedExternally = false);
/**
* Get the attachment type ID.
@@ -72,7 +72,7 @@ namespace EMotionFX
* This node is part of the actor from which the actor instance returned by GetAttachToActorInstance() is created.
* @result The node index where we will attach this attachment to.
*/
AZ::u32 GetAttachToNodeIndex() const;
size_t GetAttachToNodeIndex() const;
/**
* Check whether the transformations of the attachment are modified by using a parent-child relationship in forward kinematics.
@@ -97,7 +97,7 @@ namespace EMotionFX
protected:
AZ::u32 m_attachedToNode; /**< The node where the attachment is linked to. */
size_t m_attachedToNode; /**< The node where the attachment is linked to. */
bool m_isManagedExternally; /**< Is this attachment basically managed (transformation wise) by something else? (like an Attachment component). The default is false. */
/**
@@ -107,7 +107,7 @@ namespace EMotionFX
* @param attachment The actor instance that you want to attach to this node (for example a gun).
* @param managedExternally Specify whether the parent transform (where we are attached to) propagates into the attachment actor instance.
*/
AttachmentNode(ActorInstance* attachToActorInstance, AZ::u32 attachToNodeIndex, ActorInstance* attachment, bool managedExternally = false);
AttachmentNode(ActorInstance* attachToActorInstance, size_t attachToNodeIndex, ActorInstance* attachment, bool managedExternally = false);
/**
* The destructor.
@@ -53,12 +53,12 @@ namespace EMotionFX
}
// Iterate over the morph targets inside the attachment, and try to locate them inside the actor instance we are attaching to.
const AZ::u32 numTargetMorphs = targetMorphSetup->GetNumMorphTargets();
m_morphMap.reserve(static_cast<size_t>(numTargetMorphs));
for (AZ::u32 i = 0; i < numTargetMorphs; ++i)
const size_t numTargetMorphs = targetMorphSetup->GetNumMorphTargets();
m_morphMap.reserve(numTargetMorphs);
for (size_t i = 0; i < numTargetMorphs; ++i)
{
const AZ::u32 sourceMorphIndex = sourceMorphSetup->FindMorphTargetNumberByID(targetMorphSetup->GetMorphTarget(i)->GetID());
if (sourceMorphIndex == MCORE_INVALIDINDEX32)
const size_t sourceMorphIndex = sourceMorphSetup->FindMorphTargetNumberByID(targetMorphSetup->GetMorphTarget(i)->GetID());
if (sourceMorphIndex == InvalidIndex)
{
continue;
}
@@ -82,9 +82,9 @@ namespace EMotionFX
Skeleton* attachmentSkeleton = m_attachment->GetActor()->GetSkeleton();
Skeleton* skeleton = m_actorInstance->GetActor()->GetSkeleton();
const uint32 numNodes = attachmentSkeleton->GetNumNodes();
const size_t numNodes = attachmentSkeleton->GetNumNodes();
m_jointMap.reserve(numNodes);
for (uint32 i = 0; i < numNodes; ++i)
for (size_t i = 0; i < numNodes; ++i)
{
Node* attachmentNode = attachmentSkeleton->GetNode(i);
@@ -37,14 +37,14 @@ namespace EMotionFX
*/
struct EMFX_API JointMapping
{
AZ::u32 m_sourceJoint; /**< The source joint in the actor where this is attached to. */
AZ::u32 m_targetJoint; /**< The target joint in the attachment actor instance. */
size_t m_sourceJoint; /**< The source joint in the actor where this is attached to. */
size_t m_targetJoint; /**< The target joint in the attachment actor instance. */
};
struct EMFX_API MorphMapping
{
AZ::u32 m_sourceMorphIndex; /**< The source morph target index. The source is the actor instance we are attaching to. */
AZ::u32 m_targetMorphIndex; /**< The target morph target index. The target is the attachment actor instance. */
size_t m_sourceMorphIndex; /**< The source morph target index. The source is the actor instance we are attaching to. */
size_t m_targetMorphIndex; /**< The target morph target index. The target is the attachment actor instance. */
};
/**
@@ -92,14 +92,14 @@ namespace EMotionFX
* @param nodeIndex The joint index inside the actor instance that represents the attachment.
* @result A reference to the mapping information for this joint.
*/
MCORE_INLINE JointMapping& GetJointMapping(uint32 nodeIndex) { return m_jointMap[nodeIndex]; }
MCORE_INLINE JointMapping& GetJointMapping(size_t nodeIndex) { return m_jointMap[nodeIndex]; }
/**
* Get the mapping for a given joint.
* @param nodeIndex The joint index inside the actor instance that represents the attachment.
* @result A reference to the mapping information for this joint.
*/
MCORE_INLINE const JointMapping& GetJointMapping(uint32 nodeIndex) const { return m_jointMap[nodeIndex]; }
MCORE_INLINE const JointMapping& GetJointMapping(size_t nodeIndex) const { return m_jointMap[nodeIndex]; }
protected:
AZStd::vector<JointMapping> m_jointMap; /**< Specifies which joints we need to copy transforms from and to. */
@@ -356,8 +356,8 @@ namespace EMotionFX
void BlendTree::RecursiveFindCycles(AnimGraphNode* nextNode, AZStd::unordered_set<AnimGraphNode*>& visitedNodes, AZStd::unordered_set<AZStd::pair<BlendTreeConnection*, AnimGraphNode*> >& cycleConnections) const
{
AZStd::unordered_map<AnimGraphNode*, AZStd::vector<BlendTreeConnection*> > sourceNodesAndConnections;
const uint32 numConnections = nextNode->GetNumConnections();
for (uint32 j = 0; j < numConnections; ++j)
const size_t numConnections = nextNode->GetNumConnections();
for (size_t j = 0; j < numConnections; ++j)
{
AnimGraphNode* sourceNode = nextNode->GetConnection(j)->GetSourceNode();
sourceNodesAndConnections[sourceNode].emplace_back(nextNode->GetConnection(j));
@@ -49,7 +49,7 @@ namespace EMotionFX
}
else
{
mNodeIndex = InvalidIndex32;
mNodeIndex = InvalidIndex;
SetHasError(true);
}
}

Some files were not shown because too many files have changed in this diff Show More