Remove MCore::Array
This translates all usages of MCore::Array to AZStd::vector. It is designed to be as minimal of a change as possible (no changing to range-for loops or other C++11 stuff). We can decide to submit this wholesale, or submit it to a separate branch that we can then integrate individual files from once we're ready to do a specific class's transition. It does not completely solve the `uint32`->`size_t` transition. One important finding from doing this: `MCore::Array` uses a `memcpy` when it reallocates. `AZStd::vector` will use the contained type's copy or move constructor, per element. This is a significant change in behavior. If you have type, `SomeStruct` that defines a destructor, that type is copyable and not movable. So if you have a `MCore::Array<SomeStruct>`, and you call `Add(); Add(); Add()`, that reallocates 3 times, copying the contents using `memcpy`, and never invokes `SomeStruct`'s copy constructor or destructor. Translating that to `AZStd::vector<SomeStruct>` and calling `push_back(); push_back(); push_back();` will still reallocate 3 times, but it sees that `SomeStruct` is non-movable, and uses the copy constructor to make the copies, and then the destructor on the previous values. This call to the destructor wasn't there before, and can cause things to be deleted that weren't before. The solution to this is to make that struct be a move-only type. Where possible, this was done by changing that type to use `AZStd::unique_ptr` instead of a raw pointer, to get the proper move behavior. Where that is not possible (types that inherit from `MCore::MemoryObject`), a hand-written move constructor was created. In general: GetLength() becomes size() GetMaxLength() becomes capacity() GetIsEmpty() becomes empty() Reserve() becomes reserve() ReserveExact() becomes reserve() Resize() becomes resize() ResizeFast() becomes resize_no_construct() Add() becomes emplace_back() AddExact() becomes emplace_back() AddEmpty() becomes emplace_back() AddEmptyExact() becomes emplace_back() GetPtr() becomes data() GetItem() becomes at() Shrink() becomes shrink_to_fit() GetFirst() becomes front() GetLast() becomes back() Remove() becomes erase() RemoveFirst() becomes erase() RemoveLast() becomes pop_back() RemoveByValue() becomes if (const auto it = AZStd::find(...); it != end(container)) container.erase(it); Insert() becomes emplace() Swap() becomes swap() Clear(true) becomes clear(); shrink_to_fit() Clear() becomes clear(); shrink_to_fit() Clear(false) becomes clear() Swap() becomes swap() Find() becomes AZStd::find MoveElements() becomes AZStd::move SetMemoryCategory() is removed Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
@@ -25,7 +25,7 @@ namespace CommandSystem
|
||||
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);
|
||||
|
||||
@@ -1204,10 +1204,10 @@ 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 uint32 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();
|
||||
|
||||
@@ -865,7 +865,7 @@ namespace CommandSystem
|
||||
parameter->GetName().c_str(),
|
||||
parameterContents.c_str());
|
||||
|
||||
if (insertAtIndex != MCORE_INVALIDINDEX32)
|
||||
if (insertAtIndex != InvalidIndex32)
|
||||
{
|
||||
outResult += AZStd::string::format(" -index \"%i\"", insertAtIndex);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,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, uint32 insertAtIndex = InvalidIndex32);
|
||||
|
||||
} // namespace CommandSystem
|
||||
|
||||
@@ -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<uint32>& eventNumbers, MCore::CommandGroup* commandGroup)
|
||||
{
|
||||
// find the motion by id
|
||||
EMotionFX::Motion* motion = EMotionFX::GetMotionManager().FindMotionByID(motionID);
|
||||
@@ -1191,7 +1191,7 @@ namespace CommandSystem
|
||||
MCore::CommandGroup internalCommandGroup("Remove motion events");
|
||||
|
||||
// get the number of events to remove and iterate through them
|
||||
const int32 numEvents = eventNumbers.GetLength();
|
||||
const int32 numEvents = eventNumbers.size();
|
||||
for (int32 i = 0; i < numEvents; ++i)
|
||||
{
|
||||
// remove the events from back to front
|
||||
@@ -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<uint32>& eventNumbers, MCore::CommandGroup* commandGroup)
|
||||
{
|
||||
EMotionFX::Motion* motion = GetCommandManager()->GetCurrentSelection().GetSingleMotion();
|
||||
if (motion == nullptr)
|
||||
|
||||
@@ -222,6 +222,6 @@ namespace CommandSystem
|
||||
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 CommandHelperRemoveMotionEvents(const char* trackName, const AZStd::vector<uint32>& eventNumbers, MCore::CommandGroup* commandGroup = nullptr);
|
||||
void COMMANDSYSTEM_API CommandHelperMotionEventTrackChanged(uint32 eventNr, float startTime, float endTime, const char* oldTrackName, const char* newTrackName);
|
||||
} // namespace CommandSystem
|
||||
|
||||
@@ -33,10 +33,10 @@ 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 uint32 numSelectedActorInstances = selectedActorInstances.size();
|
||||
|
||||
// check if the current selection is equal to the desired actor instances selection list
|
||||
bool nothingChanged = true;
|
||||
@@ -52,7 +52,7 @@ namespace CommandSystem
|
||||
for (uint32 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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
@@ -100,9 +99,9 @@ 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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -227,13 +227,13 @@ 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 uint32 numGroups = nodeGroups.size();
|
||||
|
||||
if (numGroups == 0)
|
||||
{
|
||||
@@ -286,13 +286,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 +300,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,7 +311,7 @@ namespace ExporterLib
|
||||
|
||||
MCORE_ASSERT(nodeMirrorInfos);
|
||||
|
||||
const uint32 numNodes = nodeMirrorInfos->GetLength();
|
||||
const uint32 numNodes = nodeMirrorInfos->size();
|
||||
|
||||
// chunk information
|
||||
EMotionFX::FileFormat::FileChunk chunkHeader;
|
||||
@@ -342,7 +342,7 @@ namespace ExporterLib
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
// get the motion node source
|
||||
uint16 nodeMotionSource = nodeMirrorInfos->GetItem(i).mSourceNode;
|
||||
uint16 nodeMotionSource = nodeMirrorInfos->at(i).mSourceNode;
|
||||
|
||||
//if (actor && nodeMotionSource != MCORE_INVALIDINDEX16)
|
||||
//LogInfo(" + '%s' (NodeNr=%i) -> '%s' (NodeNr=%i)", actor->GetNode( i )->GetName(), i, actor->GetNode( nodeMotionSource )->GetName(), nodeMotionSource);
|
||||
@@ -355,14 +355,14 @@ namespace ExporterLib
|
||||
// write all axes
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
uint8 axis = static_cast<uint8>(nodeMirrorInfos->GetItem(i).mAxis);
|
||||
uint8 axis = static_cast<uint8>(nodeMirrorInfos->at(i).mAxis);
|
||||
file->Write(&axis, sizeof(uint8));
|
||||
}
|
||||
|
||||
// write all flags
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
uint8 flags = static_cast<uint8>(nodeMirrorInfos->GetItem(i).mFlags);
|
||||
uint8 flags = static_cast<uint8>(nodeMirrorInfos->at(i).mFlags);
|
||||
file->Write(&flags, sizeof(uint8));
|
||||
}
|
||||
}
|
||||
@@ -430,7 +430,7 @@ namespace ExporterLib
|
||||
MCore::LogInfo("============================================================");
|
||||
|
||||
// get all nodes that are affected by the skin
|
||||
MCore::Array<uint32> bones;
|
||||
AZStd::vector<uint32> bones;
|
||||
if (actor)
|
||||
{
|
||||
actor->ExtractBoneList(0, &bones);
|
||||
@@ -455,7 +455,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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<uint32>& boneList, const AZStd::unordered_set<AZ::u32>* visibleJointIndices, const AZStd::unordered_set<AZ::u32>* 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)
|
||||
@@ -680,7 +678,7 @@ namespace MCommon
|
||||
const AZ::u32 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 == MCORE_INVALIDINDEX32 || 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<uint32>& boneList, const AZStd::unordered_set<AZ::u32>* visibleJointIndices, const AZStd::unordered_set<AZ::u32>* 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());
|
||||
@@ -739,7 +737,7 @@ namespace MCommon
|
||||
(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 != MCORE_INVALIDINDEX32 && AZStd::find(begin(boneList), end(boneList), jointIndex) != end(boneList))
|
||||
{
|
||||
static const float axisBoneScale = 50.0f;
|
||||
axisRenderingSettings.mSize = GetBoneScale(actorInstance, joint) * constPreScale * axisBoneScale;
|
||||
@@ -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 int32 numTraceParticles = traceParticles.size();
|
||||
if (traceParticles.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1858,7 +1856,7 @@ namespace MCommon
|
||||
}
|
||||
|
||||
// remove all particles while keeping the data in memory
|
||||
trajectoryPath->mTraceParticles.Clear(false);
|
||||
trajectoryPath->mTraceParticles.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<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));
|
||||
|
||||
/**
|
||||
* 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<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);
|
||||
|
||||
/**
|
||||
* Render the bind pose of the given actor.
|
||||
@@ -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);
|
||||
}
|
||||
@@ -71,14 +62,14 @@ namespace RenderGL
|
||||
for (uint32 a = 0; a < 3; ++a)
|
||||
{
|
||||
// get rid of the given vertex buffers
|
||||
const uint32 numVertexBuffers = mVertexBuffers[a].GetLength();
|
||||
const uint32 numVertexBuffers = mVertexBuffers[a].size();
|
||||
for (i = 0; i < numVertexBuffers; ++i)
|
||||
{
|
||||
delete mVertexBuffers[a][i];
|
||||
}
|
||||
|
||||
// get rid of the given index buffers
|
||||
const uint32 numIndexBuffers = mIndexBuffers[a].GetLength();
|
||||
const uint32 numIndexBuffers = mIndexBuffers[a].size();
|
||||
for (i = 0; i < numIndexBuffers; ++i)
|
||||
{
|
||||
delete mIndexBuffers[a][i];
|
||||
@@ -86,10 +77,10 @@ namespace RenderGL
|
||||
}
|
||||
|
||||
// delete all materials
|
||||
const uint32 numLOD = mMaterials.GetLength();
|
||||
const uint32 numLOD = mMaterials.size();
|
||||
for (uint32 l = 0; l < numLOD; l++)
|
||||
{
|
||||
const uint32 numMaterials = mMaterials[l].GetLength();
|
||||
const uint32 numMaterials = mMaterials[l].size();
|
||||
for (uint32 n = 0; n < numMaterials; n++)
|
||||
{
|
||||
delete mMaterials[l][n]->mMaterial;
|
||||
@@ -126,13 +117,13 @@ namespace RenderGL
|
||||
const uint32 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)
|
||||
{
|
||||
mVertexBuffers[a].Resize(numGeometryLODLevels);
|
||||
mIndexBuffers[a].Resize(numGeometryLODLevels);
|
||||
mVertexBuffers[a].resize(numGeometryLODLevels);
|
||||
mIndexBuffers[a].resize(numGeometryLODLevels);
|
||||
mPrimitives[a].Resize(numGeometryLODLevels);
|
||||
|
||||
// reset the vertex and index buffers
|
||||
@@ -143,7 +134,7 @@ namespace RenderGL
|
||||
}
|
||||
}
|
||||
|
||||
mHomoMaterials.Resize(numGeometryLODLevels);
|
||||
mHomoMaterials.resize(numGeometryLODLevels);
|
||||
mDynamicNodes.Resize (numGeometryLODLevels);
|
||||
|
||||
EMotionFX::Skeleton* skeleton = actor->GetSkeleton();
|
||||
@@ -206,7 +197,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();
|
||||
@@ -373,7 +364,7 @@ namespace RenderGL
|
||||
{
|
||||
EMotionFX::Material* emfxMaterial = mActor->GetMaterial(lodLevel, m);
|
||||
Material* material = InitMaterial(emfxMaterial);
|
||||
mMaterials[lodLevel].Add( new MaterialPrimitives(material) );
|
||||
mMaterials[lodLevel].emplace_back( new MaterialPrimitives(material) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +403,7 @@ namespace RenderGL
|
||||
void GLActor::RenderMeshes(EMotionFX::ActorInstance* actorInstance, EMotionFX::Mesh::EMeshType meshType, uint32 renderFlags)
|
||||
{
|
||||
const uint32 lodLevel = actorInstance->GetLODLevel();
|
||||
const uint32 numMaterials = mMaterials[lodLevel].GetLength();
|
||||
const uint32 numMaterials = mMaterials[lodLevel].size();
|
||||
|
||||
if (numMaterials == 0)
|
||||
{
|
||||
@@ -437,7 +428,7 @@ namespace RenderGL
|
||||
for (uint32 n = 0; n < numMaterials; n++)
|
||||
{
|
||||
const MaterialPrimitives* materialPrims = mMaterials[lodLevel][n];
|
||||
const uint32 numPrimitives = materialPrims->mPrimitives[meshType].GetLength();
|
||||
const uint32 numPrimitives = materialPrims->mPrimitives[meshType].size();
|
||||
if (numPrimitives == 0)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -110,7 +110,6 @@ namespace RenderGL
|
||||
mTextures = new TextureEntry[mMaxNumTextures];
|
||||
|
||||
// text rendering
|
||||
mTextEntries.SetMemoryCategory(MEMCATEGORY_RENDERING);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,12 +163,12 @@ namespace RenderGL
|
||||
delete[] mTextures;
|
||||
|
||||
// get rid of texture entries
|
||||
const uint32 numTextEntries = mTextEntries.GetLength();
|
||||
const uint32 numTextEntries = mTextEntries.size();
|
||||
for (uint32 i = 0; i < numTextEntries; ++i)
|
||||
{
|
||||
delete mTextEntries[i];
|
||||
}
|
||||
mTextEntries.Clear();
|
||||
mTextEntries.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -481,10 +480,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 +491,7 @@ namespace RenderGL
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
// get the number of vertices to render
|
||||
const uint32 numVertices = triangleVertices.GetLength();
|
||||
const uint32 numVertices = triangleVertices.size();
|
||||
MCORE_ASSERT(numVertices <= mNumMaxTriangleVertices);
|
||||
|
||||
// lock the vertex buffer
|
||||
@@ -552,7 +551,7 @@ namespace RenderGL
|
||||
textEntry->mFontSize = fontSize;
|
||||
textEntry->mCentered = centered;
|
||||
|
||||
mTextEntries.Add(textEntry);
|
||||
mTextEntries.emplace_back(textEntry);
|
||||
}
|
||||
|
||||
|
||||
@@ -560,7 +559,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 +568,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);
|
||||
@@ -108,7 +108,7 @@ namespace RenderGL
|
||||
bool mCentered;
|
||||
};
|
||||
|
||||
MCore::Array<TextEntry*> mTextEntries;
|
||||
AZStd::vector<TextEntry*> mTextEntries;
|
||||
TextureEntry* mTextures;
|
||||
uint32 mNumTextures;
|
||||
uint32 mMaxNumTextures;
|
||||
|
||||
@@ -36,16 +36,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,14 +65,14 @@ namespace RenderGL
|
||||
// Deactivate
|
||||
void GLSLShader::Deactivate()
|
||||
{
|
||||
const uint32 numAttribs = mActivatedAttribs.GetLength();
|
||||
const uint32 numAttribs = mActivatedAttribs.size();
|
||||
for (uint32 i = 0; i < numAttribs; ++i)
|
||||
{
|
||||
const uint32 index = mActivatedAttribs[i];
|
||||
glDisableVertexAttribArray(mAttributes[index].mLocation);
|
||||
}
|
||||
|
||||
const uint32 numTextures = mActivatedTextures.GetLength();
|
||||
const uint32 numTextures = mActivatedTextures.size();
|
||||
for (uint32 i = 0; i < numTextures; ++i)
|
||||
{
|
||||
const uint32 index = mActivatedTextures[i];
|
||||
@@ -86,8 +81,8 @@ namespace RenderGL
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
mActivatedAttribs.Clear(false);
|
||||
mActivatedTextures.Clear(false);
|
||||
mActivatedAttribs.clear();
|
||||
mActivatedTextures.clear();
|
||||
}
|
||||
|
||||
bool GLSLShader::Validate()
|
||||
@@ -129,7 +124,7 @@ namespace RenderGL
|
||||
text = "#version 120\n";
|
||||
|
||||
// build define string
|
||||
const uint32 numDefines = mDefines.GetLength();
|
||||
const uint32 numDefines = mDefines.size();
|
||||
for (uint32 n = 0; n < numDefines; ++n)
|
||||
{
|
||||
text += AZStd::string::format("#define %s\n", mDefines[n].c_str());
|
||||
@@ -180,10 +175,10 @@ 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.size() > 0)
|
||||
{
|
||||
AZStd::string dStr;
|
||||
const uint32 numDefines = mDefines.GetLength();
|
||||
const uint32 numDefines = mDefines.size();
|
||||
for (uint32 n = 0; n < numDefines; ++n)
|
||||
{
|
||||
if (n < numDefines - 1)
|
||||
@@ -209,7 +204,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",
|
||||
@@ -276,9 +271,9 @@ namespace RenderGL
|
||||
|
||||
|
||||
// FindAttributeIndex
|
||||
uint32 GLSLShader::FindAttributeIndex(const char* name)
|
||||
size_t GLSLShader::FindAttributeIndex(const char* name)
|
||||
{
|
||||
const uint32 numAttribs = mAttributes.GetLength();
|
||||
const uint32 numAttribs = mAttributes.size();
|
||||
for (uint32 i = 0; i < numAttribs; ++i)
|
||||
{
|
||||
if (AzFramework::StringFunc::Equal(mAttributes[i].mName.c_str(), name, false /* no case */))
|
||||
@@ -296,14 +291,14 @@ namespace RenderGL
|
||||
|
||||
// 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 mAttributes.GetLength() - 1;
|
||||
return mAttributes.size() - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -334,9 +329,9 @@ namespace RenderGL
|
||||
|
||||
|
||||
// FindUniformIndex
|
||||
uint32 GLSLShader::FindUniformIndex(const char* name)
|
||||
size_t GLSLShader::FindUniformIndex(const char* name)
|
||||
{
|
||||
const uint32 numUniforms = mUniforms.GetLength();
|
||||
const uint32 numUniforms = mUniforms.size();
|
||||
for (uint32 i = 0; i < numUniforms; ++i)
|
||||
{
|
||||
if (AzFramework::StringFunc::Equal(mUniforms[i].mName.c_str(), name, false /* no case */))
|
||||
@@ -352,14 +347,14 @@ namespace RenderGL
|
||||
|
||||
// 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 mUniforms.GetLength() - 1;
|
||||
return mUniforms.size() - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +372,7 @@ namespace RenderGL
|
||||
glEnableVertexAttribArray(param->mLocation);
|
||||
glVertexAttribPointer(param->mLocation, dim, type, GL_FALSE, stride, (GLvoid*)offset);
|
||||
|
||||
mActivatedAttribs.Add(index);
|
||||
mActivatedAttribs.emplace_back(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -532,7 +527,7 @@ namespace RenderGL
|
||||
glBindTexture(GL_TEXTURE_2D, texture->GetID());
|
||||
glUniform1i(mUniforms[index].mLocation, mUniforms[index].mTextureUnit);
|
||||
|
||||
mActivatedTextures.Add(index);
|
||||
mActivatedTextures.emplace_back(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -563,7 +558,7 @@ namespace RenderGL
|
||||
glBindTexture(GL_TEXTURE_2D, textureID);
|
||||
glUniform1i(mUniforms[index].mLocation, mUniforms[index].mTextureUnit);
|
||||
|
||||
mActivatedTextures.Add(index);
|
||||
mActivatedTextures.emplace_back(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -571,7 +566,7 @@ namespace RenderGL
|
||||
bool GLSLShader::CheckIfIsDefined(const char* attributeName)
|
||||
{
|
||||
// get the number of defines and iterate through them
|
||||
const uint32 numDefines = mDefines.GetLength();
|
||||
const uint32 numDefines = mDefines.size();
|
||||
for (uint32 i = 0; i < numDefines; ++i)
|
||||
{
|
||||
// compare the given attribute with the current define and return if they are equal
|
||||
|
||||
@@ -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>
|
||||
@@ -42,7 +42,7 @@ namespace RenderGL
|
||||
MCORE_INLINE unsigned int GetProgram() const { return mProgram; }
|
||||
bool CheckIfIsDefined(const char* attributeName);
|
||||
|
||||
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<uint32> mActivatedAttribs;
|
||||
AZStd::vector<uint32> mActivatedTextures;
|
||||
AZStd::vector<ShaderParameter> mUniforms;
|
||||
AZStd::vector<ShaderParameter> mAttributes;
|
||||
AZStd::vector<AZStd::string> mDefines;
|
||||
|
||||
unsigned int mVertexShader;
|
||||
unsigned int mPixelShader;
|
||||
|
||||
@@ -403,20 +403,20 @@ 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();
|
||||
const uint32 numDefines = defines.size();
|
||||
for (uint32 n = 0; n < numDefines; n++)
|
||||
{
|
||||
cacheLookupStr += AZStd::string::format("#%s", defines[n].c_str());
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace RenderGL
|
||||
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<uint32> 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,7 +30,7 @@ namespace RenderGL
|
||||
void ShaderCache::Release()
|
||||
{
|
||||
// delete all shaders
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
mEntries[i].mName.clear();
|
||||
@@ -39,23 +38,21 @@ namespace RenderGL
|
||||
}
|
||||
|
||||
// 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();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
if (AzFramework::StringFunc::Equal(mEntries[i].mName, filename, false /* no case */)) // non-case-sensitive name compare
|
||||
@@ -72,7 +69,7 @@ namespace RenderGL
|
||||
// check if we have a given shader in the cache
|
||||
bool ShaderCache::CheckIfHasShader(Shader* shader) const
|
||||
{
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
if (mEntries[i].mShader == shader)
|
||||
|
||||
@@ -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);
|
||||
@@ -266,7 +264,7 @@ namespace RenderGL
|
||||
const AZ::Matrix3x4* skinningMatrices = transformData->GetSkinningMatrices();
|
||||
|
||||
// multiple each transform by its inverse bind pose
|
||||
const uint32 numBones = primitive->mBoneNodeIndices.GetLength();
|
||||
const uint32 numBones = primitive->mBoneNodeIndices.size();
|
||||
for (uint32 i = 0; i < numBones; ++i)
|
||||
{
|
||||
const uint32 nodeNr = primitive->mBoneNodeIndices[i];
|
||||
@@ -307,7 +305,7 @@ namespace RenderGL
|
||||
mActiveShader = nullptr;
|
||||
|
||||
// get the number of shaders and iterate through them
|
||||
const uint32 numShaders = mShaders.GetLength();
|
||||
const uint32 numShaders = mShaders.size();
|
||||
for (uint32 i = 0; i < numShaders; ++i)
|
||||
{
|
||||
if (mShaders[i] == nullptr)
|
||||
@@ -351,18 +349,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,14 @@ namespace RenderGL
|
||||
void TextureCache::Release()
|
||||
{
|
||||
// delete all textures
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
delete mEntries[i].mTexture;
|
||||
}
|
||||
|
||||
// clear all entries
|
||||
mEntries.Clear();
|
||||
mEntries.clear();
|
||||
|
||||
// delete the white texture
|
||||
delete mWhiteTexture;
|
||||
@@ -95,9 +94,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,7 +102,7 @@ namespace RenderGL
|
||||
Texture* TextureCache::FindTexture(const char* filename) const
|
||||
{
|
||||
// get the number of entries and iterate through them
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
if (AzFramework::StringFunc::Equal(mEntries[i].mName.c_str(), filename, false /* no case */)) // non-case-sensitive name compare
|
||||
@@ -123,7 +120,7 @@ namespace RenderGL
|
||||
bool TextureCache::CheckIfHasTexture(Texture* texture) const
|
||||
{
|
||||
// get the number of entries and iterate through them
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
if (mEntries[i].mTexture == texture)
|
||||
@@ -139,13 +136,13 @@ namespace RenderGL
|
||||
// remove an item from the cache
|
||||
void TextureCache::RemoveTexture(Texture* texture)
|
||||
{
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
if (mEntries[i].mTexture == texture)
|
||||
{
|
||||
delete mEntries[i].mTexture;
|
||||
mEntries.Remove(i);
|
||||
mEntries.erase(AZStd::next(begin(mEntries), i));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -85,12 +85,12 @@ namespace RenderGL
|
||||
|
||||
EMotionFX::Mesh::EMeshType ClassifyMeshType(EMotionFX::Node* node, EMotionFX::Mesh* mesh, uint32 lodLevel);
|
||||
|
||||
MCore::Array< MCore::Array<MaterialPrimitives*> > mMaterials;
|
||||
AZStd::vector< AZStd::vector<MaterialPrimitives*> > mMaterials;
|
||||
MCore::Array2D<uint32> 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
|
||||
|
||||
|
||||
@@ -49,14 +49,10 @@ namespace EMotionFX
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(Actor, ActorAllocator, 0)
|
||||
|
||||
Actor::LODLevel::LODLevel()
|
||||
{
|
||||
}
|
||||
|
||||
Actor::MeshLODData::MeshLODData()
|
||||
{
|
||||
// Create the default LOD level
|
||||
m_lodLevels.push_back({});
|
||||
m_lodLevels.emplace_back();
|
||||
}
|
||||
|
||||
Actor::NodeLODInfo::NodeLODInfo()
|
||||
@@ -77,11 +73,6 @@ namespace EMotionFX
|
||||
{
|
||||
SetName(name);
|
||||
|
||||
// setup the array memory categories
|
||||
mMaterials.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
mDependencies.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
mMorphSetups.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
|
||||
mSkeleton = Skeleton::Create();
|
||||
|
||||
mMotionExtractionNode = MCORE_INVALIDINDEX32;
|
||||
@@ -105,11 +96,10 @@ namespace EMotionFX
|
||||
#endif // EMFX_DEVELOPMENT_BUILD
|
||||
|
||||
// make sure we have at least allocated the first LOD of materials and facial setups
|
||||
mMaterials.Reserve(4); // reserve space for 4 lods
|
||||
mMorphSetups.Reserve(4); //
|
||||
mMaterials.AddEmpty();
|
||||
mMaterials[0].SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
mMorphSetups.Add(nullptr);
|
||||
mMaterials.reserve(4); // reserve space for 4 lods
|
||||
mMorphSetups.reserve(4); //
|
||||
mMaterials.emplace_back();
|
||||
mMorphSetups.emplace_back(nullptr);
|
||||
|
||||
GetEventManager().OnCreateActor(this);
|
||||
ActorNotificationBus::Broadcast(&ActorNotificationBus::Events::OnActorCreated, this);
|
||||
@@ -120,7 +110,7 @@ namespace EMotionFX
|
||||
ActorNotificationBus::Broadcast(&ActorNotificationBus::Events::OnActorDestroyed, this);
|
||||
GetEventManager().OnDeleteActor(this);
|
||||
|
||||
mNodeMirrorInfos.Clear(true);
|
||||
mNodeMirrorInfos.clear();
|
||||
|
||||
RemoveAllMaterials();
|
||||
RemoveAllMorphSetups();
|
||||
@@ -158,12 +148,12 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// clone the materials
|
||||
result->mMaterials.Resize(mMaterials.GetLength());
|
||||
for (uint32 i = 0; i < mMaterials.GetLength(); ++i)
|
||||
result->mMaterials.resize(mMaterials.size());
|
||||
for (uint32 i = 0; i < mMaterials.size(); ++i)
|
||||
{
|
||||
// get the number of materials in the current LOD
|
||||
const uint32 numMaterials = mMaterials[i].GetLength();
|
||||
result->mMaterials[i].Reserve(numMaterials);
|
||||
const uint32 numMaterials = mMaterials[i].size();
|
||||
result->mMaterials[i].reserve(numMaterials);
|
||||
for (uint32 m = 0; m < numMaterials; ++m)
|
||||
{
|
||||
// retrieve the current material
|
||||
@@ -190,10 +180,10 @@ namespace EMotionFX
|
||||
result->SetNumLODLevels(static_cast<uint32>(numLodLevels));
|
||||
for (size_t lodLevel = 0; lodLevel < numLodLevels; ++lodLevel)
|
||||
{
|
||||
const MCore::Array<NodeLODInfo>& nodeInfos = m_meshLodData.m_lodLevels[lodLevel].mNodeInfos;
|
||||
MCore::Array<NodeLODInfo>& resultNodeInfos = resultMeshLodData.m_lodLevels[lodLevel].mNodeInfos;
|
||||
const AZStd::vector<NodeLODInfo>& nodeInfos = m_meshLodData.m_lodLevels[lodLevel].mNodeInfos;
|
||||
AZStd::vector<NodeLODInfo>& resultNodeInfos = resultMeshLodData.m_lodLevels[lodLevel].mNodeInfos;
|
||||
|
||||
resultNodeInfos.Resize(numNodes);
|
||||
resultNodeInfos.resize(numNodes);
|
||||
for (uint32 n = 0; n < numNodes; ++n)
|
||||
{
|
||||
NodeLODInfo& resultNodeInfo = resultNodeInfos[n];
|
||||
@@ -204,8 +194,8 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// clone the morph setups
|
||||
result->mMorphSetups.Resize(mMorphSetups.GetLength());
|
||||
for (uint32 i = 0; i < mMorphSetups.GetLength(); ++i)
|
||||
result->mMorphSetups.resize(mMorphSetups.size());
|
||||
for (uint32 i = 0; i < mMorphSetups.size(); ++i)
|
||||
{
|
||||
if (mMorphSetups[i])
|
||||
{
|
||||
@@ -241,7 +231,7 @@ namespace EMotionFX
|
||||
void Actor::AllocateNodeMirrorInfos()
|
||||
{
|
||||
const uint32 numNodes = mSkeleton->GetNumNodes();
|
||||
mNodeMirrorInfos.Resize(numNodes);
|
||||
mNodeMirrorInfos.resize(numNodes);
|
||||
|
||||
// init the data
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
@@ -255,19 +245,20 @@ namespace EMotionFX
|
||||
// remove the node mirror info
|
||||
void Actor::RemoveNodeMirrorInfos()
|
||||
{
|
||||
mNodeMirrorInfos.Clear(true);
|
||||
mNodeMirrorInfos.clear();
|
||||
mNodeMirrorInfos.shrink_to_fit();
|
||||
}
|
||||
|
||||
|
||||
// check if we have our axes detected
|
||||
bool Actor::GetHasMirrorAxesDetected() const
|
||||
{
|
||||
if (mNodeMirrorInfos.GetLength() == 0)
|
||||
if (mNodeMirrorInfos.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < mNodeMirrorInfos.GetLength(); ++i)
|
||||
for (uint32 i = 0; i < mNodeMirrorInfos.size(); ++i)
|
||||
{
|
||||
if (mNodeMirrorInfos[i].mAxis == MCORE_INVALIDINDEX8)
|
||||
{
|
||||
@@ -283,17 +274,17 @@ namespace EMotionFX
|
||||
void Actor::RemoveAllMaterials()
|
||||
{
|
||||
// for all LODs
|
||||
for (uint32 i = 0; i < mMaterials.GetLength(); ++i)
|
||||
for (uint32 i = 0; i < mMaterials.size(); ++i)
|
||||
{
|
||||
// delete all materials
|
||||
const uint32 numMats = mMaterials[i].GetLength();
|
||||
const uint32 numMats = mMaterials[i].size();
|
||||
for (uint32 m = 0; m < numMats; ++m)
|
||||
{
|
||||
mMaterials[i][m]->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
mMaterials.Clear();
|
||||
mMaterials.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -305,8 +296,7 @@ namespace EMotionFX
|
||||
lodLevels.emplace_back();
|
||||
LODLevel& newLOD = lodLevels.back();
|
||||
const uint32 numNodes = mSkeleton->GetNumNodes();
|
||||
newLOD.mNodeInfos.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
newLOD.mNodeInfos.Resize(numNodes);
|
||||
newLOD.mNodeInfos.resize(numNodes);
|
||||
|
||||
const size_t numLODs = lodLevels.size();
|
||||
const size_t lodIndex = numLODs - 1;
|
||||
@@ -329,11 +319,10 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// create a new material array for the new LOD level
|
||||
mMaterials.Resize(static_cast<uint32>(lodLevels.size()));
|
||||
mMaterials[static_cast<uint32>(lodIndex)].SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
mMaterials.resize(lodLevels.size());
|
||||
|
||||
// create an empty morph setup for the new LOD level
|
||||
mMorphSetups.Add(nullptr);
|
||||
mMorphSetups.emplace_back(nullptr);
|
||||
|
||||
// copy data from the previous LOD level if wanted
|
||||
if (copyFromLastLODLevel && numLODs > 0)
|
||||
@@ -347,12 +336,11 @@ namespace EMotionFX
|
||||
{
|
||||
AZStd::vector<LODLevel>& lodLevels = m_meshLodData.m_lodLevels;
|
||||
|
||||
lodLevels.insert(lodLevels.begin()+insertAt, {});
|
||||
lodLevels.emplace(lodLevels.begin()+insertAt);
|
||||
LODLevel& newLOD = lodLevels[insertAt];
|
||||
const uint32 lodIndex = insertAt;
|
||||
const uint32 numNodes = mSkeleton->GetNumNodes();
|
||||
newLOD.mNodeInfos.SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
newLOD.mNodeInfos.Resize(numNodes);
|
||||
newLOD.mNodeInfos.resize(numNodes);
|
||||
|
||||
// get the number of nodes, iterate through them, create a new LOD level and copy over the meshes from the last LOD level
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
@@ -363,11 +351,10 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// create a new material array for the new LOD level
|
||||
mMaterials.Insert(insertAt);
|
||||
mMaterials[lodIndex].SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
mMaterials.emplace(AZStd::next(begin(mMaterials), insertAt));
|
||||
|
||||
// create an empty morph setup for the new LOD level
|
||||
mMorphSetups.Insert(insertAt, nullptr);
|
||||
mMorphSetups.emplace(AZStd::next(begin(mMorphSetups), insertAt), nullptr);
|
||||
}
|
||||
|
||||
// replace existing LOD level with the current actor
|
||||
@@ -424,12 +411,12 @@ namespace EMotionFX
|
||||
|
||||
// copy the materials
|
||||
const uint32 numMaterials = copyActor->GetNumMaterials(copyLODLevel);
|
||||
for (uint32 i = 0; i < mMaterials[replaceLODLevel].GetLength(); ++i)
|
||||
for (uint32 i = 0; i < mMaterials[replaceLODLevel].size(); ++i)
|
||||
{
|
||||
mMaterials[replaceLODLevel][i]->Destroy();
|
||||
}
|
||||
mMaterials[replaceLODLevel].Clear();
|
||||
mMaterials[replaceLODLevel].Reserve(numMaterials);
|
||||
mMaterials[replaceLODLevel].clear();
|
||||
mMaterials[replaceLODLevel].reserve(numMaterials);
|
||||
for (uint32 i = 0; i < numMaterials; ++i)
|
||||
{
|
||||
AddMaterial(replaceLODLevel, copyActor->GetMaterial(copyLODLevel, i)->Clone());
|
||||
@@ -457,15 +444,11 @@ namespace EMotionFX
|
||||
m_meshLodData.m_lodLevels.resize(numLODs);
|
||||
|
||||
// reserve space for the materials
|
||||
mMaterials.Resize(numLODs);
|
||||
for (uint32 i = 0; i < numLODs; ++i)
|
||||
{
|
||||
mMaterials[i].SetMemoryCategory(EMFX_MEMCATEGORY_ACTORS);
|
||||
}
|
||||
mMaterials.resize(numLODs);
|
||||
|
||||
if (adjustMorphSetup)
|
||||
{
|
||||
mMorphSetups.Resize(numLODs);
|
||||
mMorphSetups.resize(numLODs);
|
||||
for (uint32 i = 0; i < numLODs; ++i)
|
||||
{
|
||||
mMorphSetups[i] = nullptr;
|
||||
@@ -639,7 +622,7 @@ namespace EMotionFX
|
||||
|
||||
|
||||
// verify if the skinning will look correctly in the given geometry LOD for a given skeletal LOD level
|
||||
void Actor::VerifySkinning(MCore::Array<uint8>& conflictNodeFlags, uint32 skeletalLODLevel, uint32 geometryLODLevel)
|
||||
void Actor::VerifySkinning(AZStd::vector<uint8>& conflictNodeFlags, uint32 skeletalLODLevel, uint32 geometryLODLevel)
|
||||
{
|
||||
uint32 n;
|
||||
|
||||
@@ -647,13 +630,13 @@ namespace EMotionFX
|
||||
const uint32 numNodes = mSkeleton->GetNumNodes();
|
||||
|
||||
// check if the conflict node flag array's size is set to the number of nodes inside the actor
|
||||
if (conflictNodeFlags.GetLength() != numNodes)
|
||||
if (conflictNodeFlags.size() != numNodes)
|
||||
{
|
||||
conflictNodeFlags.Resize(numNodes);
|
||||
conflictNodeFlags.resize(numNodes);
|
||||
}
|
||||
|
||||
// reset the conflict node array to zero which means we don't have any conflicting nodes yet
|
||||
MCore::MemSet(conflictNodeFlags.GetPtr(), 0, numNodes * sizeof(int8));
|
||||
MCore::MemSet(conflictNodeFlags.data(), 0, numNodes * sizeof(int8));
|
||||
|
||||
// iterate over the all nodes in the actor
|
||||
for (n = 0; n < numNodes; ++n)
|
||||
@@ -791,7 +774,7 @@ namespace EMotionFX
|
||||
const uint32 numLODs = GetNumLODLevels();
|
||||
|
||||
// for all LODs, get rid of all the morph setups for each geometry LOD
|
||||
for (i = 0; i < mMorphSetups.GetLength(); ++i)
|
||||
for (i = 0; i < mMorphSetups.size(); ++i)
|
||||
{
|
||||
if (mMorphSetups[i])
|
||||
{
|
||||
@@ -882,11 +865,11 @@ namespace EMotionFX
|
||||
// remove the given material and reassign all material numbers of the submeshes
|
||||
void Actor::RemoveMaterial(uint32 lodLevel, uint32 index)
|
||||
{
|
||||
MCORE_ASSERT(lodLevel < mMaterials.GetLength());
|
||||
MCORE_ASSERT(lodLevel < mMaterials.size());
|
||||
|
||||
// first of all remove the given material
|
||||
mMaterials[lodLevel][index]->Destroy();
|
||||
mMaterials[lodLevel].Remove(index);
|
||||
mMaterials[lodLevel].erase(AZStd::next(begin(mMaterials[lodLevel]), index));
|
||||
}
|
||||
|
||||
|
||||
@@ -930,10 +913,10 @@ namespace EMotionFX
|
||||
|
||||
|
||||
// extract a bone list
|
||||
void Actor::ExtractBoneList(uint32 lodLevel, MCore::Array<uint32>* outBoneList) const
|
||||
void Actor::ExtractBoneList(uint32 lodLevel, AZStd::vector<uint32>* outBoneList) const
|
||||
{
|
||||
// clear the existing items
|
||||
outBoneList->Clear();
|
||||
outBoneList->clear();
|
||||
|
||||
// for all nodes
|
||||
const uint32 numNodes = mSkeleton->GetNumNodes();
|
||||
@@ -966,9 +949,9 @@ namespace EMotionFX
|
||||
uint32 nodeNr = skinningLayer->GetInfluence(v, i)->GetNodeNr();
|
||||
|
||||
// check if it is already in the bone list, if not, add it
|
||||
if (outBoneList->Contains(nodeNr) == false)
|
||||
if (AZStd::find(begin(*outBoneList), end(*outBoneList), nodeNr) == end(*outBoneList))
|
||||
{
|
||||
outBoneList->Add(nodeNr);
|
||||
outBoneList->emplace_back(nodeNr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -984,7 +967,7 @@ namespace EMotionFX
|
||||
for (uint32 i = 0; i < numDependencies; ++i)
|
||||
{
|
||||
// add it to the actor instance
|
||||
mDependencies.Add(*actor->GetDependency(i));
|
||||
mDependencies.emplace_back(*actor->GetDependency(i));
|
||||
|
||||
// recursive into the actor we are dependent on
|
||||
RecursiveAddDependencies(actor->GetDependency(i)->mActor);
|
||||
@@ -1083,7 +1066,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// allocate the data if we haven't already
|
||||
if (mNodeMirrorInfos.GetLength() == 0)
|
||||
if (mNodeMirrorInfos.size() == 0)
|
||||
{
|
||||
AllocateNodeMirrorInfos();
|
||||
}
|
||||
@@ -1101,7 +1084,7 @@ namespace EMotionFX
|
||||
bool Actor::MapNodeMotionSource(uint16 sourceNodeIndex, uint16 targetNodeIndex)
|
||||
{
|
||||
// allocate the data if we haven't already
|
||||
if (mNodeMirrorInfos.GetLength() == 0)
|
||||
if (mNodeMirrorInfos.size() == 0)
|
||||
{
|
||||
AllocateNodeMirrorInfos();
|
||||
}
|
||||
@@ -1267,17 +1250,17 @@ namespace EMotionFX
|
||||
|
||||
|
||||
// generate a path from the current node towards the root
|
||||
void Actor::GenerateUpdatePathToRoot(uint32 endNodeIndex, MCore::Array<uint32>& outPath) const
|
||||
void Actor::GenerateUpdatePathToRoot(uint32 endNodeIndex, AZStd::vector<uint32>& outPath) const
|
||||
{
|
||||
outPath.Clear(false);
|
||||
outPath.Reserve(32);
|
||||
outPath.clear();
|
||||
outPath.reserve(32);
|
||||
|
||||
// start at the end effector
|
||||
Node* currentNode = mSkeleton->GetNode(endNodeIndex);
|
||||
while (currentNode)
|
||||
{
|
||||
// add the current node to the update list
|
||||
outPath.Add(currentNode->GetNodeIndex());
|
||||
outPath.emplace_back(currentNode->GetNodeIndex());
|
||||
|
||||
// move up the hierarchy, towards the root and end node
|
||||
currentNode = currentNode->GetParentNode();
|
||||
@@ -1361,7 +1344,7 @@ namespace EMotionFX
|
||||
ReinitializeMeshDeformers();
|
||||
|
||||
// make sure our world space bind pose is updated too
|
||||
if (mMorphSetups.GetLength() > 0 && mMorphSetups[0])
|
||||
if (mMorphSetups.size() > 0 && mMorphSetups[0])
|
||||
{
|
||||
mSkeleton->GetBindPose()->ResizeNumMorphs(mMorphSetups[0]->GetNumMorphTargets());
|
||||
}
|
||||
@@ -1594,7 +1577,7 @@ namespace EMotionFX
|
||||
Pose pose;
|
||||
pose.LinkToActor(this);
|
||||
|
||||
const uint32 numNodes = mNodeMirrorInfos.GetLength();
|
||||
const uint32 numNodes = mNodeMirrorInfos.size();
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
const uint16 motionSource = (GetHasMirrorInfo()) ? GetNodeMirrorInfo(i).mSourceNode : static_cast<uint16>(i);
|
||||
@@ -1723,21 +1706,21 @@ namespace EMotionFX
|
||||
|
||||
|
||||
// get the array of node mirror infos
|
||||
const MCore::Array<Actor::NodeMirrorInfo>& Actor::GetNodeMirrorInfos() const
|
||||
const AZStd::vector<Actor::NodeMirrorInfo>& Actor::GetNodeMirrorInfos() const
|
||||
{
|
||||
return mNodeMirrorInfos;
|
||||
}
|
||||
|
||||
|
||||
// get the array of node mirror infos
|
||||
MCore::Array<Actor::NodeMirrorInfo>& Actor::GetNodeMirrorInfos()
|
||||
AZStd::vector<Actor::NodeMirrorInfo>& Actor::GetNodeMirrorInfos()
|
||||
{
|
||||
return mNodeMirrorInfos;
|
||||
}
|
||||
|
||||
|
||||
// set the node mirror infos directly
|
||||
void Actor::SetNodeMirrorInfos(const MCore::Array<NodeMirrorInfo>& mirrorInfos)
|
||||
void Actor::SetNodeMirrorInfos(const AZStd::vector<NodeMirrorInfo>& mirrorInfos)
|
||||
{
|
||||
mNodeMirrorInfos = mirrorInfos;
|
||||
}
|
||||
@@ -1862,7 +1845,7 @@ namespace EMotionFX
|
||||
AZStd::vector<LODLevel>& lodLevels = m_meshLodData.m_lodLevels;
|
||||
for (LODLevel& lodLevel : lodLevels)
|
||||
{
|
||||
lodLevel.mNodeInfos.Resize(numNodes);
|
||||
lodLevel.mNodeInfos.resize(numNodes);
|
||||
}
|
||||
|
||||
Pose* bindPose = mSkeleton->GetBindPose();
|
||||
@@ -1878,7 +1861,7 @@ namespace EMotionFX
|
||||
AZStd::vector<LODLevel>& lodLevels = m_meshLodData.m_lodLevels;
|
||||
for (LODLevel& lodLevel : lodLevels)
|
||||
{
|
||||
lodLevel.mNodeInfos.AddEmpty();
|
||||
lodLevel.mNodeInfos.emplace_back();
|
||||
}
|
||||
|
||||
mSkeleton->GetBindPose()->LinkToActor(this, Pose::FLAG_LOCALTRANSFORMREADY, false);
|
||||
@@ -1909,7 +1892,7 @@ namespace EMotionFX
|
||||
AZStd::vector<LODLevel>& lodLevels = m_meshLodData.m_lodLevels;
|
||||
for (LODLevel& lodLevel : lodLevels)
|
||||
{
|
||||
lodLevel.mNodeInfos.Remove(nr);
|
||||
lodLevel.mNodeInfos.erase(AZStd::next(begin(lodLevel.mNodeInfos), nr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1920,20 +1903,20 @@ namespace EMotionFX
|
||||
AZStd::vector<LODLevel>& lodLevels = m_meshLodData.m_lodLevels;
|
||||
for (LODLevel& lodLevel : lodLevels)
|
||||
{
|
||||
lodLevel.mNodeInfos.Clear();
|
||||
lodLevel.mNodeInfos.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::ReserveMaterials(uint32 lodLevel, uint32 numMaterials)
|
||||
{
|
||||
mMaterials[lodLevel].Reserve(numMaterials);
|
||||
mMaterials[lodLevel].reserve(numMaterials);
|
||||
}
|
||||
|
||||
// get a material
|
||||
Material* Actor::GetMaterial(uint32 lodLevel, uint32 nr) const
|
||||
{
|
||||
MCORE_ASSERT(lodLevel < mMaterials.GetLength());
|
||||
MCORE_ASSERT(nr < mMaterials[lodLevel].GetLength());
|
||||
MCORE_ASSERT(lodLevel < mMaterials.size());
|
||||
MCORE_ASSERT(nr < mMaterials[lodLevel].size());
|
||||
return mMaterials[lodLevel][nr];
|
||||
}
|
||||
|
||||
@@ -1941,10 +1924,10 @@ namespace EMotionFX
|
||||
// get a material by name
|
||||
uint32 Actor::FindMaterialIndexByName(uint32 lodLevel, const char* name) const
|
||||
{
|
||||
MCORE_ASSERT(lodLevel < mMaterials.GetLength());
|
||||
MCORE_ASSERT(lodLevel < mMaterials.size());
|
||||
|
||||
// search through all materials
|
||||
const uint32 numMaterials = mMaterials[lodLevel].GetLength();
|
||||
const uint32 numMaterials = mMaterials[lodLevel].size();
|
||||
for (uint32 i = 0; i < numMaterials; ++i)
|
||||
{
|
||||
if (mMaterials[lodLevel][i]->GetNameString() == name)
|
||||
@@ -1960,27 +1943,26 @@ namespace EMotionFX
|
||||
// set a material
|
||||
void Actor::SetMaterial(uint32 lodLevel, uint32 nr, Material* mat)
|
||||
{
|
||||
MCORE_ASSERT(lodLevel < mMaterials.GetLength());
|
||||
MCORE_ASSERT(nr < mMaterials[lodLevel].GetLength());
|
||||
MCORE_ASSERT(lodLevel < mMaterials.size());
|
||||
MCORE_ASSERT(nr < mMaterials[lodLevel].size());
|
||||
mMaterials[lodLevel][nr] = mat;
|
||||
}
|
||||
|
||||
void Actor::AddMaterial(uint32 lodLevel, Material* mat)
|
||||
{
|
||||
MCORE_ASSERT(lodLevel < mMaterials.GetLength());
|
||||
mMaterials[lodLevel].Add(mat);
|
||||
MCORE_ASSERT(lodLevel < mMaterials.size());
|
||||
mMaterials[lodLevel].emplace_back(mat);
|
||||
}
|
||||
|
||||
uint32 Actor::GetNumMaterials(uint32 lodLevel) const
|
||||
size_t Actor::GetNumMaterials(uint32 lodLevel) const
|
||||
{
|
||||
MCORE_ASSERT(lodLevel < mMaterials.GetLength());
|
||||
return mMaterials[lodLevel].GetLength();
|
||||
MCORE_ASSERT(lodLevel < mMaterials.size());
|
||||
return mMaterials[lodLevel].size();
|
||||
}
|
||||
|
||||
uint32 Actor::GetNumLODLevels() const
|
||||
size_t Actor::GetNumLODLevels() const
|
||||
{
|
||||
const AZStd::vector<LODLevel>& lodLevels = m_meshLodData.m_lodLevels;
|
||||
return static_cast<uint32>(lodLevels.size());
|
||||
return m_meshLodData.m_lodLevels.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -2022,7 +2004,7 @@ namespace EMotionFX
|
||||
|
||||
void Actor::AddDependency(const Dependency& dependency)
|
||||
{
|
||||
mDependencies.Add(dependency);
|
||||
mDependencies.emplace_back(dependency);
|
||||
}
|
||||
|
||||
|
||||
@@ -2459,8 +2441,8 @@ namespace EMotionFX
|
||||
const AZ::u32 numSubMeshes = mesh->GetNumSubMeshes();
|
||||
for (AZ::u32 subMeshIndex = 0; subMeshIndex < numSubMeshes; ++subMeshIndex)
|
||||
{
|
||||
const MCore::Array<AZ::u32>& subMeshJoints = mesh->GetSubMesh(subMeshIndex)->GetBonesArray();
|
||||
const AZ::u32 numSubMeshJoints = subMeshJoints.GetLength();
|
||||
const AZStd::vector<AZ::u32>& subMeshJoints = mesh->GetSubMesh(subMeshIndex)->GetBonesArray();
|
||||
const AZ::u32 numSubMeshJoints = subMeshJoints.size();
|
||||
for (AZ::u32 i = 0; i < numSubMeshJoints; ++i)
|
||||
{
|
||||
InsertJointAndParents(subMeshJoints[i], includedJointIndices);
|
||||
@@ -2678,13 +2660,13 @@ namespace EMotionFX
|
||||
// Remove all the materials and add them back based on the meshAsset. Eventually we will remove all the material from Actor and
|
||||
// GLActor.
|
||||
RemoveAllMaterials();
|
||||
mMaterials.Resize(static_cast<uint32>(numLODLevels));
|
||||
mMaterials.resize(numLODLevels);
|
||||
|
||||
for (size_t lodLevel = 0; lodLevel < numLODLevels; ++lodLevel)
|
||||
{
|
||||
const AZ::Data::Asset<AZ::RPI::ModelLodAsset>& lodAsset = lodAssets[lodLevel];
|
||||
|
||||
lodLevels[lodLevel].mNodeInfos.Resize(numNodes);
|
||||
lodLevels[lodLevel].mNodeInfos.resize(numNodes);
|
||||
|
||||
// Create a single mesh for the actor.
|
||||
Mesh* mesh = Mesh::CreateFromModelLod(lodAsset, m_skinToSkeletonIndexMap);
|
||||
@@ -2798,7 +2780,7 @@ namespace EMotionFX
|
||||
const AZStd::array_view<AZ::Data::Asset<AZ::RPI::ModelLodAsset>>& lodAssets = m_meshAsset->GetLodAssets();
|
||||
const size_t numLODLevels = lodAssets.size();
|
||||
|
||||
AZ_Assert(mMorphSetups.GetLength() == numLODLevels, "There needs to be a morph setup for every single LOD level.");
|
||||
AZ_Assert(mMorphSetups.size() == numLODLevels, "There needs to be a morph setup for every single LOD level.");
|
||||
|
||||
for (size_t lodLevel = 0; lodLevel < numLODLevels; ++lodLevel)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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(uint32 endNodeIndex, AZStd::vector<uint32>& outPath) const;
|
||||
|
||||
/**
|
||||
* Set the motion extraction node.
|
||||
@@ -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(uint32 lodLevel, AZStd::vector<uint32>* outBoneList) const;
|
||||
|
||||
//------------------------------------------------
|
||||
void SetPhysicsSetup(const AZStd::shared_ptr<PhysicsSetup>& physicsSetup);
|
||||
@@ -313,7 +313,7 @@ namespace EMotionFX
|
||||
* @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(uint32 lodLevel) const;
|
||||
|
||||
/**
|
||||
* Removes all materials from this actor.
|
||||
@@ -367,7 +367,7 @@ namespace EMotionFX
|
||||
* 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;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -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, uint32 skeletalLODLevel, uint32 geometryLODLevel);
|
||||
|
||||
/**
|
||||
* Checks if the given material is used by a given mesh.
|
||||
@@ -522,7 +522,7 @@ 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.
|
||||
@@ -658,7 +658,7 @@ namespace EMotionFX
|
||||
*/
|
||||
MCORE_INLINE const NodeMirrorInfo& GetNodeMirrorInfo(uint32 nodeIndex) const { return mNodeMirrorInfos[nodeIndex]; }
|
||||
|
||||
MCORE_INLINE bool GetHasMirrorInfo() const { return (mNodeMirrorInfos.GetLength() != 0); }
|
||||
MCORE_INLINE bool GetHasMirrorInfo() const { return (mNodeMirrorInfos.size() != 0); }
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
@@ -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; }
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
@@ -174,7 +170,7 @@ namespace EMotionFX
|
||||
|
||||
// delete all attachments
|
||||
// actor instances that are attached will be detached, and not deleted from memory
|
||||
const uint32 numAttachments = mAttachments.GetLength();
|
||||
const uint32 numAttachments = mAttachments.size();
|
||||
for (uint32 i = 0; i < numAttachments; ++i)
|
||||
{
|
||||
ActorInstance* attachmentActorInstance = mAttachments[i]->GetAttachmentActorInstance();
|
||||
@@ -187,7 +183,7 @@ namespace EMotionFX
|
||||
}
|
||||
mAttachments[i]->Destroy();
|
||||
}
|
||||
mAttachments.Clear();
|
||||
mAttachments.clear();
|
||||
|
||||
if (mMorphSetup)
|
||||
{
|
||||
@@ -396,7 +392,7 @@ namespace EMotionFX
|
||||
|
||||
// Update the mesh deformers.
|
||||
const Skeleton* skeleton = mActor->GetSkeleton();
|
||||
const uint32 numNodes = mEnabledNodes.GetLength();
|
||||
const uint32 numNodes = mEnabledNodes.size();
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
const uint16 nodeNr = mEnabledNodes[i];
|
||||
@@ -416,7 +412,7 @@ namespace EMotionFX
|
||||
|
||||
// Update the mesh morph deformers.
|
||||
const Skeleton* skeleton = mActor->GetSkeleton();
|
||||
const uint32 numNodes = mEnabledNodes.GetLength();
|
||||
const uint32 numNodes = mEnabledNodes.size();
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
const uint16 nodeNr = mEnabledNodes[i];
|
||||
@@ -448,7 +444,7 @@ namespace EMotionFX
|
||||
GetActorManager().GetScheduler()->RecursiveRemoveActorInstance(root);
|
||||
|
||||
// add the attachment
|
||||
mAttachments.Add(attachment);
|
||||
mAttachments.emplace_back(attachment);
|
||||
ActorInstance* attachmentActorInstance = attachment->GetAttachmentActorInstance();
|
||||
if (attachmentActorInstance)
|
||||
{
|
||||
@@ -468,7 +464,7 @@ namespace EMotionFX
|
||||
uint32 ActorInstance::FindAttachmentNr(ActorInstance* actorInstance)
|
||||
{
|
||||
// for all attachments
|
||||
const uint32 numAttachments = mAttachments.GetLength();
|
||||
const uint32 numAttachments = mAttachments.size();
|
||||
for (uint32 i = 0; i < numAttachments; ++i)
|
||||
{
|
||||
if (mAttachments[i]->GetAttachmentActorInstance() == actorInstance)
|
||||
@@ -498,7 +494,7 @@ namespace EMotionFX
|
||||
// remove an attachment
|
||||
void ActorInstance::RemoveAttachment(uint32 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 +524,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 +540,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,19 +550,19 @@ 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)
|
||||
{
|
||||
mDependencies.Add(*mActor->GetDependency(i));
|
||||
mDependencies.emplace_back(*mActor->GetDependency(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +570,7 @@ namespace EMotionFX
|
||||
void ActorInstance::UpdateAttachments()
|
||||
{
|
||||
// update all attachments
|
||||
const uint32 numAttachments = mAttachments.GetLength();
|
||||
const uint32 numAttachments = mAttachments.size();
|
||||
for (uint32 i = 0; i < numAttachments; ++i)
|
||||
{
|
||||
mAttachments[i]->Update();
|
||||
@@ -1089,7 +1085,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;
|
||||
}
|
||||
@@ -1105,16 +1101,16 @@ namespace EMotionFX
|
||||
uint32 parentIndex = skeleton->GetNode(curNode)->GetParentIndex();
|
||||
if (parentIndex != MCORE_INVALIDINDEX32)
|
||||
{
|
||||
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 +1121,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,14 +1131,18 @@ 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);
|
||||
mEnabledNodes.resize(numNodes);
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
mEnabledNodes[i] = static_cast<uint16>(i);
|
||||
@@ -1152,7 +1152,7 @@ namespace EMotionFX
|
||||
// disable all nodes
|
||||
void ActorInstance::DisableAllNodes()
|
||||
{
|
||||
mEnabledNodes.Clear();
|
||||
mEnabledNodes.clear();
|
||||
}
|
||||
|
||||
// change the skeletal LOD level
|
||||
@@ -1587,9 +1587,9 @@ 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
|
||||
@@ -1612,9 +1612,9 @@ 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)
|
||||
@@ -1779,7 +1779,7 @@ namespace EMotionFX
|
||||
SetIsVisible(isVisible);
|
||||
|
||||
// recurse to all child attachments
|
||||
const uint32 numAttachments = mAttachments.GetLength();
|
||||
const uint32 numAttachments = mAttachments.size();
|
||||
for (uint32 i = 0; i < numAttachments; ++i)
|
||||
{
|
||||
mAttachments[i]->GetAttachmentActorInstance()->RecursiveSetIsVisible(isVisible);
|
||||
|
||||
@@ -599,7 +599,7 @@ namespace EMotionFX
|
||||
* 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.
|
||||
@@ -664,7 +664,7 @@ 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.
|
||||
@@ -788,13 +788,13 @@ 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.
|
||||
@@ -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. */
|
||||
|
||||
@@ -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,7 +100,7 @@ namespace EMotionFX
|
||||
mScheduler = scheduler;
|
||||
|
||||
// adjust all visibility flags to false for all actor instances
|
||||
const uint32 numActorInstances = mActorInstances.GetLength();
|
||||
const uint32 numActorInstances = mActorInstances.size();
|
||||
for (uint32 i = 0; i < numActorInstances; ++i)
|
||||
{
|
||||
mActorInstances[i]->SetIsVisible(false);
|
||||
@@ -139,7 +135,7 @@ namespace EMotionFX
|
||||
{
|
||||
LockActorInstances();
|
||||
|
||||
mActorInstances.Add(actorInstance);
|
||||
mActorInstances.emplace_back(actorInstance);
|
||||
UpdateActorInstanceStatus(actorInstance, false);
|
||||
|
||||
UnlockActorInstances();
|
||||
@@ -213,7 +209,7 @@ namespace EMotionFX
|
||||
LockActorInstances();
|
||||
|
||||
// get the number of actor instances and iterate through them
|
||||
const uint32 numActorInstances = mActorInstances.GetLength();
|
||||
const uint32 numActorInstances = mActorInstances.size();
|
||||
for (uint32 i = 0; i < numActorInstances; ++i)
|
||||
{
|
||||
if (mActorInstances[i] == actorInstance)
|
||||
@@ -233,7 +229,7 @@ namespace EMotionFX
|
||||
uint32 ActorManager::FindActorInstanceIndex(ActorInstance* actorInstance) const
|
||||
{
|
||||
// get the number of actor instances and iterate through them
|
||||
const uint32 numActorInstances = mActorInstances.GetLength();
|
||||
const uint32 numActorInstances = mActorInstances.size();
|
||||
for (uint32 i = 0; i < numActorInstances; ++i)
|
||||
{
|
||||
if (mActorInstances[i] == actorInstance)
|
||||
@@ -251,7 +247,7 @@ namespace EMotionFX
|
||||
ActorInstance* ActorManager::FindActorInstanceByID(uint32 id) const
|
||||
{
|
||||
// get the number of actor instances and iterate through them
|
||||
const uint32 numActorInstances = mActorInstances.GetLength();
|
||||
const uint32 numActorInstances = mActorInstances.size();
|
||||
for (uint32 i = 0; i < numActorInstances; ++i)
|
||||
{
|
||||
if (mActorInstances[i]->GetID() == id)
|
||||
@@ -349,15 +345,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 +373,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);
|
||||
@@ -416,7 +421,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
|
||||
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>
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ 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.
|
||||
@@ -137,7 +137,7 @@ namespace EMotionFX
|
||||
* 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.
|
||||
@@ -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.
|
||||
@@ -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. */
|
||||
|
||||
@@ -36,8 +36,6 @@ namespace EMotionFX
|
||||
AnimGraph::AnimGraph()
|
||||
: mGameControllerSettings(aznew AnimGraphGameControllerSettings())
|
||||
{
|
||||
mNodes.SetMemoryCategory(EMFX_MEMCATEGORY_ANIMGRAPH);
|
||||
|
||||
mID = MCore::GetIDGenerator().GenerateID();
|
||||
mDirtyFlag = false;
|
||||
mAutoUnregister = true;
|
||||
@@ -50,7 +48,7 @@ namespace EMotionFX
|
||||
#endif // EMFX_DEVELOPMENT_BUILD
|
||||
|
||||
// reserve some memory
|
||||
mNodes.Reserve(1024);
|
||||
mNodes.reserve(1024);
|
||||
|
||||
// automatically register the anim graph
|
||||
GetAnimGraphManager().AddAnimGraph(this);
|
||||
@@ -628,7 +626,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);
|
||||
}
|
||||
@@ -725,8 +723,8 @@ namespace EMotionFX
|
||||
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
|
||||
@@ -765,7 +763,7 @@ namespace EMotionFX
|
||||
AnimGraphNode* node = static_cast<AnimGraphNode*>(object);
|
||||
const uint32 nodeIndex = node->GetNodeIndex();
|
||||
|
||||
const uint32 numNodes = mNodes.GetLength();
|
||||
const uint32 numNodes = mNodes.size();
|
||||
for (uint32 i = nodeIndex + 1; i < numNodes; ++i)
|
||||
{
|
||||
AnimGraphNode* curNode = mNodes[i];
|
||||
@@ -774,7 +772,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// remove the object from the array
|
||||
mNodes.Remove(nodeIndex);
|
||||
mNodes.erase(AZStd::next(begin(mNodes), nodeIndex));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,14 +787,14 @@ namespace EMotionFX
|
||||
// reserve space for a given amount of nodes
|
||||
void AnimGraph::ReserveNumNodes(uint32 numNodes)
|
||||
{
|
||||
mNodes.Reserve(numNodes);
|
||||
mNodes.reserve(numNodes);
|
||||
}
|
||||
|
||||
|
||||
// Calculate number of motion nodes in the graph
|
||||
uint32 AnimGraph::CalcNumMotionNodes() const
|
||||
{
|
||||
const uint32 numNodes = mNodes.GetLength();
|
||||
const uint32 numNodes = mNodes.size();
|
||||
uint32 numMotionNodes = 0;
|
||||
for (uint32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
@@ -1029,7 +1027,7 @@ namespace EMotionFX
|
||||
void AnimGraph::RemoveInvalidConnections(bool logWarnings)
|
||||
{
|
||||
// Iterate over all nodes
|
||||
const AZ::u32 numNodes = mNodes.GetLength();
|
||||
const AZ::u32 numNodes = mNodes.size();
|
||||
for (AZ::u32 i = 0; i < numNodes; ++i)
|
||||
{
|
||||
AnimGraphNode* node = mNodes[i];
|
||||
|
||||
@@ -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,7 +65,7 @@ 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);
|
||||
@@ -381,7 +381,7 @@ namespace EMotionFX
|
||||
AnimGraphObject* GetObject(uint32 index) const { return mObjects[index]; }
|
||||
void ReserveNumObjects(uint32 numObjects);
|
||||
|
||||
uint32 GetNumNodes() const { return mNodes.GetLength(); }
|
||||
size_t GetNumNodes() const { return mNodes.size(); }
|
||||
AnimGraphNode* GetNode(uint32 index) const { return mNodes[index]; }
|
||||
void ReserveNumNodes(uint32 numNodes);
|
||||
uint32 CalcNumMotionNodes() const;
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,7 +143,7 @@ namespace EMotionFX
|
||||
{
|
||||
if (delFromMem)
|
||||
{
|
||||
const uint32 numParams = mParamValues.GetLength();
|
||||
const uint32 numParams = mParamValues.size();
|
||||
for (uint32 i = 0; i < numParams; ++i)
|
||||
{
|
||||
if (mParamValues[i])
|
||||
@@ -155,7 +153,7 @@ namespace EMotionFX
|
||||
}
|
||||
}
|
||||
|
||||
mParamValues.Clear();
|
||||
mParamValues.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -268,10 +266,10 @@ namespace EMotionFX
|
||||
RemoveAllParameters(true);
|
||||
|
||||
const ValueParameterVector& valueParameters = mAnimGraph->RecursivelyGetValueParameters();
|
||||
mParamValues.Resize(static_cast<uint32>(valueParameters.size()));
|
||||
mParamValues.resize(static_cast<uint32>(valueParameters.size()));
|
||||
|
||||
// init the values
|
||||
const uint32 numParams = mParamValues.GetLength();
|
||||
const uint32 numParams = mParamValues.size();
|
||||
for (uint32 i = 0; i < numParams; ++i)
|
||||
{
|
||||
mParamValues[i] = valueParameters[i]->ConstructDefaultValueAsAttribute();
|
||||
@@ -284,22 +282,22 @@ 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 int32 numToAdd = static_cast<uint32>(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(static_cast<uint32>(valueParameters.size()));
|
||||
|
||||
// add the remaining parameters
|
||||
const uint32 startIndex = mParamValues.GetLength();
|
||||
const uint32 startIndex = mParamValues.size();
|
||||
for (int32 i = 0; i < numToAdd; ++i)
|
||||
{
|
||||
const uint32 index = startIndex + i;
|
||||
mParamValues.AddEmpty();
|
||||
mParamValues.GetLast() = valueParameters[index]->ConstructDefaultValueAsAttribute();
|
||||
mParamValues.emplace_back();
|
||||
mParamValues.back() = valueParameters[index]->ConstructDefaultValueAsAttribute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +313,7 @@ namespace EMotionFX
|
||||
}
|
||||
}
|
||||
|
||||
mParamValues.Remove(index);
|
||||
mParamValues.erase(AZStd::next(begin(mParamValues), index));
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +331,7 @@ namespace EMotionFX
|
||||
|
||||
void AnimGraphInstance::ReInitParameterValues()
|
||||
{
|
||||
const AZ::u32 parameterValueCount = mParamValues.GetLength();
|
||||
const AZ::u32 parameterValueCount = mParamValues.size();
|
||||
for (AZ::u32 i = 0; i < parameterValueCount; ++i)
|
||||
{
|
||||
ReInitParameterValue(i);
|
||||
@@ -503,15 +501,15 @@ namespace EMotionFX
|
||||
// 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)
|
||||
{
|
||||
mParamValues.Insert(index, nullptr);
|
||||
mParamValues.emplace(AZStd::next(begin(mParamValues), index), nullptr);
|
||||
ReInitParameterValue(index);
|
||||
}
|
||||
|
||||
@@ -658,7 +656,7 @@ namespace EMotionFX
|
||||
void AnimGraphInstance::AddUniqueObjectData()
|
||||
{
|
||||
m_uniqueDatas.emplace_back(nullptr);
|
||||
mObjectFlags.Add(0);
|
||||
mObjectFlags.emplace_back(0);
|
||||
}
|
||||
|
||||
// remove the given unique data object
|
||||
@@ -676,7 +674,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
m_uniqueDatas.erase(m_uniqueDatas.begin() + index);
|
||||
mObjectFlags.Remove(index);
|
||||
mObjectFlags.erase(AZStd::next(begin(mObjectFlags), index));
|
||||
}
|
||||
|
||||
|
||||
@@ -684,7 +682,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), static_cast<uint32>(index)));
|
||||
if (delFromMem && data)
|
||||
{
|
||||
data->Destroy();
|
||||
@@ -707,7 +705,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
m_uniqueDatas.clear();
|
||||
mObjectFlags.Clear();
|
||||
mObjectFlags.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -813,7 +811,7 @@ namespace EMotionFX
|
||||
{
|
||||
const uint32 numObjects = mAnimGraph->GetNumObjects();
|
||||
m_uniqueDatas.resize(numObjects);
|
||||
mObjectFlags.Resize(numObjects);
|
||||
mObjectFlags.resize(numObjects);
|
||||
for (uint32 i = 0; i < numObjects; ++i)
|
||||
{
|
||||
m_uniqueDatas[i] = nullptr;
|
||||
@@ -934,7 +932,7 @@ namespace EMotionFX
|
||||
// reset all node flags
|
||||
void AnimGraphInstance::ResetFlagsForAllObjects(uint32 flagsToDisable)
|
||||
{
|
||||
const uint32 numObjects = mObjectFlags.GetLength();
|
||||
const uint32 numObjects = mObjectFlags.size();
|
||||
for (uint32 i = 0; i < numObjects; ++i)
|
||||
{
|
||||
mObjectFlags[i] &= ~flagsToDisable;
|
||||
@@ -967,7 +965,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)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -1287,14 +1287,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 +1324,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 +1346,7 @@ namespace EMotionFX
|
||||
AnimGraphTransitionCondition* condition = transition->GetCondition(j);
|
||||
if (azrtti_typeid(condition) == conditionType)
|
||||
{
|
||||
outConditions->Add(condition);
|
||||
outConditions->emplace_back(condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1601,9 +1601,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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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>
|
||||
@@ -153,7 +153,7 @@ namespace EMotionFX
|
||||
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
|
||||
|
||||
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);
|
||||
|
||||
@@ -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,22 +27,22 @@ namespace EMotionFX
|
||||
AnimGraphPosePool::~AnimGraphPosePool()
|
||||
{
|
||||
// delete all poses
|
||||
const uint32 numPoses = mPoses.GetLength();
|
||||
const uint32 numPoses = mPoses.size();
|
||||
for (uint32 i = 0; i < numPoses; ++i)
|
||||
{
|
||||
delete mPoses[i];
|
||||
}
|
||||
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)
|
||||
{
|
||||
const uint32 numOldPoses = mPoses.GetLength();
|
||||
const uint32 numOldPoses = mPoses.size();
|
||||
|
||||
// if we will remove poses
|
||||
int32 difference = numPoses - numOldPoses;
|
||||
@@ -54,10 +52,10 @@ namespace EMotionFX
|
||||
difference = abs(difference);
|
||||
for (int32 i = 0; i < difference; ++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
|
||||
@@ -65,8 +63,8 @@ namespace EMotionFX
|
||||
for (int32 i = 0; i < difference; ++i)
|
||||
{
|
||||
AnimGraphPose* newPose = new AnimGraphPose();
|
||||
mPoses.Add(newPose);
|
||||
mFreePoses.Add(newPose);
|
||||
mPoses.emplace_back(newPose);
|
||||
mFreePoses.emplace_back(newPose);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,21 +74,21 @@ 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.size() == 0)
|
||||
{
|
||||
AnimGraphPose* newPose = new AnimGraphPose();
|
||||
newPose->LinkToActorInstance(actorInstance);
|
||||
mPoses.Add(newPose);
|
||||
mPoses.emplace_back(newPose);
|
||||
mMaxUsed = MCore::Max<uint32>(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
|
||||
mFreePoses.pop_back(); // remove it from the list of free poses
|
||||
mMaxUsed = MCore::Max<uint32>(mMaxUsed, GetNumUsedPoses());
|
||||
pose->SetIsInUse(true);
|
||||
return pose;
|
||||
@@ -101,7 +99,7 @@ namespace EMotionFX
|
||||
void AnimGraphPosePool::FreePose(AnimGraphPose* pose)
|
||||
{
|
||||
//MCORE_ASSERT( mPoses.Contains(pose) );
|
||||
mFreePoses.Add(pose);
|
||||
mFreePoses.emplace_back(pose);
|
||||
pose->SetIsInUse(false);
|
||||
}
|
||||
|
||||
@@ -109,7 +107,7 @@ namespace EMotionFX
|
||||
// free all poses
|
||||
void AnimGraphPosePool::FreeAllPoses()
|
||||
{
|
||||
const uint32 numPoses = mPoses.GetLength();
|
||||
const uint32 numPoses = mPoses.size();
|
||||
for (uint32 i = 0; i < numPoses; ++i)
|
||||
{
|
||||
AnimGraphPose* curPose = mPoses[i];
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// include required headers
|
||||
#include "EMotionFXConfig.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
|
||||
|
||||
@@ -41,15 +41,15 @@ namespace EMotionFX
|
||||
|
||||
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 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 uint32 GetNumMaxUsedPoses() const { return mMaxUsed; }
|
||||
MCORE_INLINE void ResetMaxUsedPoses() { mMaxUsed = 0; }
|
||||
|
||||
private:
|
||||
MCore::Array<AnimGraphPose*> mPoses;
|
||||
MCore::Array<AnimGraphPose*> mFreePoses;
|
||||
AZStd::vector<AnimGraphPose*> mPoses;
|
||||
AZStd::vector<AnimGraphPose*> mFreePoses;
|
||||
uint32 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,22 +28,22 @@ namespace EMotionFX
|
||||
AnimGraphRefCountedDataPool::~AnimGraphRefCountedDataPool()
|
||||
{
|
||||
// delete all items
|
||||
const uint32 numItems = mItems.GetLength();
|
||||
const uint32 numItems = mItems.size();
|
||||
for (uint32 i = 0; i < numItems; ++i)
|
||||
{
|
||||
delete mItems[i];
|
||||
}
|
||||
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)
|
||||
{
|
||||
const uint32 numOldItems = mItems.GetLength();
|
||||
const uint32 numOldItems = mItems.size();
|
||||
|
||||
// if we will remove Items
|
||||
int32 difference = numItems - numOldItems;
|
||||
@@ -53,10 +53,10 @@ namespace EMotionFX
|
||||
difference = abs(difference);
|
||||
for (int32 i = 0; i < difference; ++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
|
||||
@@ -64,8 +64,8 @@ namespace EMotionFX
|
||||
for (int32 i = 0; i < difference; ++i)
|
||||
{
|
||||
AnimGraphRefCountedData* newItem = new AnimGraphRefCountedData();
|
||||
mItems.Add(newItem);
|
||||
mFreeItems.Add(newItem);
|
||||
mItems.emplace_back(newItem);
|
||||
mFreeItems.emplace_back(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,17 +75,17 @@ namespace EMotionFX
|
||||
AnimGraphRefCountedData* AnimGraphRefCountedDataPool::RequestNew()
|
||||
{
|
||||
// if we have no free items left, allocate a new one
|
||||
if (mFreeItems.GetLength() == 0)
|
||||
if (mFreeItems.size() == 0)
|
||||
{
|
||||
AnimGraphRefCountedData* newItem = new AnimGraphRefCountedData();
|
||||
mItems.Add(newItem);
|
||||
mItems.emplace_back(newItem);
|
||||
mMaxUsed = MCore::Max<uint32>(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
|
||||
AnimGraphRefCountedData* item = mFreeItems[mFreeItems.size() - 1];
|
||||
mFreeItems.pop_back(); // remove it from the list of free Items
|
||||
mMaxUsed = MCore::Max<uint32>(mMaxUsed, GetNumUsedItems());
|
||||
return item;
|
||||
}
|
||||
@@ -94,7 +94,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
|
||||
@@ -34,15 +34,15 @@ namespace EMotionFX
|
||||
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 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 uint32 GetNumMaxUsedItems() const { return mMaxUsed; }
|
||||
MCORE_INLINE void ResetMaxUsedItems() { mMaxUsed = 0; }
|
||||
|
||||
private:
|
||||
MCore::Array<AnimGraphRefCountedData*> mItems;
|
||||
MCore::Array<AnimGraphRefCountedData*> mFreeItems;
|
||||
AZStd::vector<AnimGraphRefCountedData*> mItems;
|
||||
AZStd::vector<AnimGraphRefCountedData*> mFreeItems;
|
||||
uint32 mMaxUsed;
|
||||
};
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1277,7 +1277,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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace EMotionFX
|
||||
* This is the number of different bones that the skinning information of the mesh where this deformer works on uses.
|
||||
* @result The number of bones.
|
||||
*/
|
||||
MCORE_INLINE uint32 GetNumLocalBones() const { return static_cast<uint32>(m_bones.size()); }
|
||||
MCORE_INLINE size_t GetNumLocalBones() const { return m_bones.size(); }
|
||||
|
||||
/**
|
||||
* Get the node number of a given local bone.
|
||||
|
||||
@@ -107,7 +107,6 @@ namespace EMotionFX
|
||||
// constructor
|
||||
EMotionFXManager::EMotionFXManager()
|
||||
{
|
||||
mThreadDatas.SetMemoryCategory(EMFX_MEMCATEGORY_EMOTIONFXMANAGER);
|
||||
// build the low version string
|
||||
AZStd::string lowVersionString;
|
||||
BuildLowVersionString(lowVersionString);
|
||||
@@ -174,11 +173,11 @@ namespace EMotionFX
|
||||
mEventManager = nullptr;
|
||||
|
||||
// delete the thread datas
|
||||
for (uint32 i = 0; i < mThreadDatas.GetLength(); ++i)
|
||||
for (uint32 i = 0; i < mThreadDatas.size(); ++i)
|
||||
{
|
||||
mThreadDatas[i]->Destroy();
|
||||
}
|
||||
mThreadDatas.Clear();
|
||||
mThreadDatas.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -477,19 +476,19 @@ namespace EMotionFX
|
||||
numThreads = 1;
|
||||
}
|
||||
|
||||
if (mThreadDatas.GetLength() == numThreads)
|
||||
if (mThreadDatas.size() == numThreads)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// get rid of old data
|
||||
for (uint32 i = 0; i < mThreadDatas.GetLength(); ++i)
|
||||
for (uint32 i = 0; i < mThreadDatas.size(); ++i)
|
||||
{
|
||||
mThreadDatas[i]->Destroy();
|
||||
}
|
||||
|
||||
mThreadDatas.Clear(false); // force calling constructors again to reset everything
|
||||
mThreadDatas.Resize(numThreads);
|
||||
mThreadDatas.clear(); // force calling constructors again to reset everything
|
||||
mThreadDatas.resize(numThreads);
|
||||
|
||||
for (uint32 i = 0; i < numThreads; ++i)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// include the required headers
|
||||
#include "EMotionFXConfig.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/Distance.h>
|
||||
#include "ThreadData.h"
|
||||
#include "BaseObject.h"
|
||||
@@ -268,13 +268,13 @@ namespace EMotionFX
|
||||
* @param threadIndex The thread index, which must be between [0..GetNumThreads()-1].
|
||||
* @return The unique thread data for this thread.
|
||||
*/
|
||||
MCORE_INLINE ThreadData* GetThreadData(uint32 threadIndex) const { MCORE_ASSERT(threadIndex < mThreadDatas.GetLength()); return mThreadDatas[threadIndex]; }
|
||||
MCORE_INLINE ThreadData* GetThreadData(uint32 threadIndex) const { MCORE_ASSERT(threadIndex < mThreadDatas.size()); return mThreadDatas[threadIndex]; }
|
||||
|
||||
/**
|
||||
* Get the number of threads that are internally created.
|
||||
* @return The number of threads that we have internally created.
|
||||
*/
|
||||
MCORE_INLINE uint32 GetNumThreads() const { return mThreadDatas.GetLength(); }
|
||||
MCORE_INLINE size_t GetNumThreads() const { return mThreadDatas.size(); }
|
||||
|
||||
/**
|
||||
* Shrink the memory pools, to reduce memory usage.
|
||||
@@ -354,7 +354,7 @@ namespace EMotionFX
|
||||
Recorder* mRecorder; /**< The recorder. */
|
||||
MotionInstancePool* mMotionInstancePool; /**< The motion instance pool. */
|
||||
DebugDraw* mDebugDraw; /**< The debug drawing system. */
|
||||
MCore::Array<ThreadData*> mThreadDatas; /**< The per thread data. */
|
||||
AZStd::vector<ThreadData*> mThreadDatas; /**< The per thread data. */
|
||||
MCore::Distance::EUnitType mUnitType; /**< The unit type, on default it is MCore::Distance::UNITTYPE_METERS. */
|
||||
float mGlobalSimulationSpeed; /**< The global simulation speed, default is 1.0. */
|
||||
bool m_isInEditorMode; /**< True when the runtime requires to support an editor. Optimizations can be made if there is no need for editor support. */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// include the required headers
|
||||
#include "EMotionFXConfig.h"
|
||||
#include "BaseObject.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/MultiThreadManager.h>
|
||||
#include "MemoryCategories.h"
|
||||
#include "MotionInstance.h"
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace EMotionFX
|
||||
mStringStorageSize = 0;
|
||||
}
|
||||
|
||||
const char* SharedHelperData::ReadString(MCore::Stream* file, MCore::Array<SharedData*>* sharedData, MCore::Endian::EEndianType endianType)
|
||||
const char* SharedHelperData::ReadString(MCore::Stream* file, AZStd::vector<SharedData*>* sharedData, MCore::Endian::EEndianType endianType)
|
||||
{
|
||||
MCORE_ASSERT(file);
|
||||
MCORE_ASSERT(sharedData);
|
||||
@@ -904,9 +904,9 @@ namespace EMotionFX
|
||||
|
||||
// read all tracks
|
||||
AZStd::string trackName;
|
||||
MCore::Array<AZStd::string> typeStrings;
|
||||
MCore::Array<AZStd::string> paramStrings;
|
||||
MCore::Array<AZStd::string> mirrorTypeStrings;
|
||||
AZStd::vector<AZStd::string> typeStrings;
|
||||
AZStd::vector<AZStd::string> paramStrings;
|
||||
AZStd::vector<AZStd::string> mirrorTypeStrings;
|
||||
for (uint32 t = 0; t < fileEventTable.mNumTracks; ++t)
|
||||
{
|
||||
// read the motion event table header
|
||||
@@ -934,9 +934,9 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// the even type and parameter strings
|
||||
typeStrings.Resize(fileTrack.mNumTypeStrings);
|
||||
paramStrings.Resize(fileTrack.mNumParamStrings);
|
||||
mirrorTypeStrings.Resize(fileTrack.mNumMirrorTypeStrings);
|
||||
typeStrings.resize(fileTrack.mNumTypeStrings);
|
||||
paramStrings.resize(fileTrack.mNumParamStrings);
|
||||
mirrorTypeStrings.resize(fileTrack.mNumMirrorTypeStrings);
|
||||
|
||||
// read all type strings
|
||||
if (GetLogging())
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EMotionFXConfig.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/CompressedQuaternion.h>
|
||||
#include "../MemoryCategories.h"
|
||||
#include "../BaseObject.h"
|
||||
@@ -94,7 +94,7 @@ namespace EMotionFX
|
||||
* @param endianType The endian type to read the string in.
|
||||
* @return The actual string.
|
||||
*/
|
||||
static const char* ReadString(MCore::Stream* file, MCore::Array<SharedData*>* sharedData, MCore::Endian::EEndianType endianType);
|
||||
static const char* ReadString(MCore::Stream* file, AZStd::vector<SharedData*>* sharedData, MCore::Endian::EEndianType endianType);
|
||||
|
||||
public:
|
||||
uint32 mFileHighVersion; /**< The high file version. For example 3 in case of v3.10. */
|
||||
|
||||
@@ -47,9 +47,6 @@ namespace EMotionFX
|
||||
Importer::Importer()
|
||||
: BaseObject()
|
||||
{
|
||||
// set the memory category
|
||||
mChunkProcessors.SetMemoryCategory(EMFX_MEMCATEGORY_IMPORTER);
|
||||
|
||||
// register all standard chunks
|
||||
RegisterStandardChunks();
|
||||
|
||||
@@ -63,7 +60,7 @@ namespace EMotionFX
|
||||
Importer::~Importer()
|
||||
{
|
||||
// remove all chunk processors
|
||||
const uint32 numProcessors = mChunkProcessors.GetLength();
|
||||
const uint32 numProcessors = mChunkProcessors.size();
|
||||
for (uint32 i = 0; i < numProcessors; ++i)
|
||||
{
|
||||
mChunkProcessors[i]->Destroy();
|
||||
@@ -110,7 +107,6 @@ namespace EMotionFX
|
||||
MCore::LogError("Unsupported endian type used! (endian type = %d)", header.mEndianType);
|
||||
return false;
|
||||
}
|
||||
;
|
||||
|
||||
// yes, it is a valid actor file!
|
||||
return true;
|
||||
@@ -150,7 +146,6 @@ namespace EMotionFX
|
||||
MCore::LogError("Unsupported endian type used! (endian type = %d)", header.mEndianType);
|
||||
return false;
|
||||
}
|
||||
;
|
||||
|
||||
// yes, it is a valid motion file!
|
||||
return true;
|
||||
@@ -291,8 +286,7 @@ namespace EMotionFX
|
||||
MCORE_ASSERT(f->GetIsOpen());
|
||||
|
||||
// create the shared data
|
||||
MCore::Array<SharedData*> sharedData;
|
||||
sharedData.SetMemoryCategory(EMFX_MEMCATEGORY_IMPORTER);
|
||||
AZStd::vector<SharedData*> sharedData;
|
||||
PrepareSharedData(sharedData);
|
||||
|
||||
// verify if this is a valid actor file or not
|
||||
@@ -360,7 +354,7 @@ namespace EMotionFX
|
||||
|
||||
// get rid of shared data
|
||||
ResetSharedData(sharedData);
|
||||
sharedData.Clear();
|
||||
sharedData.clear();
|
||||
|
||||
// return the created actor
|
||||
return actor;
|
||||
@@ -461,8 +455,7 @@ namespace EMotionFX
|
||||
MCORE_ASSERT(f->GetIsOpen());
|
||||
|
||||
// create the shared data
|
||||
MCore::Array<SharedData*> sharedData;
|
||||
sharedData.SetMemoryCategory(EMFX_MEMCATEGORY_IMPORTER);
|
||||
AZStd::vector<SharedData*> sharedData;
|
||||
PrepareSharedData(sharedData);
|
||||
|
||||
// verify if this is a valid actor file or not
|
||||
@@ -513,7 +506,7 @@ namespace EMotionFX
|
||||
|
||||
// get rid of shared data
|
||||
ResetSharedData(sharedData);
|
||||
sharedData.Clear();
|
||||
sharedData.clear();
|
||||
|
||||
return motion;
|
||||
}
|
||||
@@ -671,8 +664,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// create the shared data
|
||||
MCore::Array<SharedData*> sharedData;
|
||||
sharedData.SetMemoryCategory(EMFX_MEMCATEGORY_IMPORTER);
|
||||
AZStd::vector<SharedData*> sharedData;
|
||||
PrepareSharedData(sharedData);
|
||||
|
||||
//-----------------------------------------------
|
||||
@@ -710,7 +702,7 @@ namespace EMotionFX
|
||||
|
||||
// get rid of shared data
|
||||
ResetSharedData(sharedData);
|
||||
sharedData.Clear();
|
||||
sharedData.clear();
|
||||
|
||||
// return the created actor
|
||||
return nodeMap;
|
||||
@@ -722,26 +714,26 @@ namespace EMotionFX
|
||||
void Importer::RegisterChunkProcessor(ChunkProcessor* processorToRegister)
|
||||
{
|
||||
MCORE_ASSERT(processorToRegister);
|
||||
mChunkProcessors.Add(processorToRegister);
|
||||
mChunkProcessors.emplace_back(processorToRegister);
|
||||
}
|
||||
|
||||
|
||||
// add shared data object to the importer
|
||||
void Importer::AddSharedData(MCore::Array<SharedData*>& sharedData, SharedData* data)
|
||||
void Importer::AddSharedData(AZStd::vector<SharedData*>& sharedData, SharedData* data)
|
||||
{
|
||||
MCORE_ASSERT(data);
|
||||
sharedData.Add(data);
|
||||
sharedData.emplace_back(data);
|
||||
}
|
||||
|
||||
|
||||
// search for shared data
|
||||
SharedData* Importer::FindSharedData(MCore::Array<SharedData*>* sharedDataArray, uint32 type)
|
||||
SharedData* Importer::FindSharedData(AZStd::vector<SharedData*>* sharedDataArray, uint32 type)
|
||||
{
|
||||
// for all shared data
|
||||
const uint32 numSharedData = sharedDataArray->GetLength();
|
||||
const uint32 numSharedData = sharedDataArray->size();
|
||||
for (uint32 i = 0; i < numSharedData; ++i)
|
||||
{
|
||||
SharedData* sharedData = sharedDataArray->GetItem(i);
|
||||
SharedData* sharedData = sharedDataArray->at(i);
|
||||
|
||||
// check if it's the type we are searching for
|
||||
if (sharedData->GetType() == type)
|
||||
@@ -772,7 +764,7 @@ namespace EMotionFX
|
||||
mLogDetails = detailLoggingActive;
|
||||
|
||||
// set the processors logging flag
|
||||
const int32 numProcessors = mChunkProcessors.GetLength();
|
||||
const int32 numProcessors = mChunkProcessors.size();
|
||||
for (int32 i = 0; i < numProcessors; i++)
|
||||
{
|
||||
ChunkProcessor* processor = mChunkProcessors[i];
|
||||
@@ -787,7 +779,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
|
||||
void Importer::PrepareSharedData(MCore::Array<SharedData*>& sharedData)
|
||||
void Importer::PrepareSharedData(AZStd::vector<SharedData*>& sharedData)
|
||||
{
|
||||
// create standard shared objects
|
||||
AddSharedData(sharedData, SharedHelperData::Create());
|
||||
@@ -795,16 +787,16 @@ namespace EMotionFX
|
||||
|
||||
|
||||
// reset shared objects so that the importer is ready for use again
|
||||
void Importer::ResetSharedData(MCore::Array<SharedData*>& sharedData)
|
||||
void Importer::ResetSharedData(AZStd::vector<SharedData*>& sharedData)
|
||||
{
|
||||
const int32 numSharedData = sharedData.GetLength();
|
||||
const int32 numSharedData = sharedData.size();
|
||||
for (int32 i = 0; i < numSharedData; i++)
|
||||
{
|
||||
SharedData* data = sharedData[i];
|
||||
data->Reset();
|
||||
data->Destroy();
|
||||
}
|
||||
sharedData.Clear();
|
||||
sharedData.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -812,7 +804,7 @@ namespace EMotionFX
|
||||
ChunkProcessor* Importer::FindChunk(uint32 chunkID, uint32 version) const
|
||||
{
|
||||
// for all chunk processors
|
||||
const uint32 numProcessors = mChunkProcessors.GetLength();
|
||||
const uint32 numProcessors = mChunkProcessors.size();
|
||||
for (uint32 i = 0; i < numProcessors; ++i)
|
||||
{
|
||||
ChunkProcessor* processor = mChunkProcessors[i];
|
||||
@@ -833,7 +825,7 @@ namespace EMotionFX
|
||||
void Importer::RegisterStandardChunks()
|
||||
{
|
||||
// reserve space for 75 chunk processors
|
||||
mChunkProcessors.Reserve(75);
|
||||
mChunkProcessors.reserve(75);
|
||||
|
||||
// shared processors
|
||||
RegisterChunkProcessor(aznew ChunkProcessorMotionEventTrackTable());
|
||||
@@ -912,12 +904,12 @@ namespace EMotionFX
|
||||
bool mustSkip = false;
|
||||
|
||||
// check if we specified to ignore this chunk
|
||||
if (actorSettings && actorSettings->mChunkIDsToIgnore.Contains(chunk.mChunkID))
|
||||
if (actorSettings && AZStd::find(begin(actorSettings->mChunkIDsToIgnore), end(actorSettings->mChunkIDsToIgnore), chunk.mChunkID) != end(actorSettings->mChunkIDsToIgnore))
|
||||
{
|
||||
mustSkip = true;
|
||||
}
|
||||
|
||||
if (skelMotionSettings && skelMotionSettings->mChunkIDsToIgnore.Contains(chunk.mChunkID))
|
||||
if (skelMotionSettings && AZStd::find(begin(skelMotionSettings->mChunkIDsToIgnore), end(skelMotionSettings->mChunkIDsToIgnore), chunk.mChunkID) != end(skelMotionSettings->mChunkIDsToIgnore))
|
||||
{
|
||||
mustSkip = true;
|
||||
}
|
||||
@@ -963,20 +955,29 @@ namespace EMotionFX
|
||||
void Importer::ValidateActorSettings(ActorSettings* settings)
|
||||
{
|
||||
// After atom: Make sure we are not loading the tangents and bitangents
|
||||
if (!settings->mLayerIDsToIgnore.Contains(Mesh::ATTRIB_TANGENTS))
|
||||
if (AZStd::find(begin(settings->mLayerIDsToIgnore), end(settings->mLayerIDsToIgnore), Mesh::ATTRIB_TANGENTS) == end(settings->mLayerIDsToIgnore))
|
||||
{
|
||||
settings->mLayerIDsToIgnore.Add(Mesh::ATTRIB_TANGENTS);
|
||||
settings->mLayerIDsToIgnore.emplace_back(Mesh::ATTRIB_TANGENTS);
|
||||
}
|
||||
|
||||
if (!settings->mLayerIDsToIgnore.Contains(Mesh::ATTRIB_BITANGENTS))
|
||||
if (AZStd::find(begin(settings->mLayerIDsToIgnore), end(settings->mLayerIDsToIgnore), Mesh::ATTRIB_BITANGENTS) == end(settings->mLayerIDsToIgnore))
|
||||
{
|
||||
settings->mLayerIDsToIgnore.Add(Mesh::ATTRIB_BITANGENTS);
|
||||
settings->mLayerIDsToIgnore.emplace_back(Mesh::ATTRIB_BITANGENTS);
|
||||
}
|
||||
|
||||
// make sure we load at least the position and normals and org vertex numbers
|
||||
settings->mLayerIDsToIgnore.RemoveByValue(Mesh::ATTRIB_ORGVTXNUMBERS);
|
||||
settings->mLayerIDsToIgnore.RemoveByValue(Mesh::ATTRIB_NORMALS);
|
||||
settings->mLayerIDsToIgnore.RemoveByValue(Mesh::ATTRIB_POSITIONS);
|
||||
if(const auto it = AZStd::find(begin(settings->mLayerIDsToIgnore), end(settings->mLayerIDsToIgnore), Mesh::ATTRIB_ORGVTXNUMBERS); it != end(settings->mLayerIDsToIgnore))
|
||||
{
|
||||
settings->mLayerIDsToIgnore.erase(it);
|
||||
}
|
||||
if(const auto it = AZStd::find(begin(settings->mLayerIDsToIgnore), end(settings->mLayerIDsToIgnore), Mesh::ATTRIB_NORMALS); it != end(settings->mLayerIDsToIgnore))
|
||||
{
|
||||
settings->mLayerIDsToIgnore.erase(it);
|
||||
}
|
||||
if(const auto it = AZStd::find(begin(settings->mLayerIDsToIgnore), end(settings->mLayerIDsToIgnore), Mesh::ATTRIB_POSITIONS); it != end(settings->mLayerIDsToIgnore))
|
||||
{
|
||||
settings->mLayerIDsToIgnore.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EMotionFXConfig.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/Endian.h>
|
||||
#include <EMotionFX/Source/BaseObject.h>
|
||||
#include <AzCore/Serialization/ObjectStream.h>
|
||||
@@ -82,8 +82,8 @@ namespace EMotionFX
|
||||
bool mLoadSimulatedObjects = true; /**< Set to false if you wish to disable loading of simulated objects. */
|
||||
bool mOptimizeForServer = false; /**< Set to true if you witsh to optimize this actor to be used on server. */
|
||||
uint32 mThreadIndex = 0;
|
||||
MCore::Array<uint32> mChunkIDsToIgnore; /**< Add chunk ID's to this array. Chunks with these ID's will not be processed. */
|
||||
MCore::Array<uint32> mLayerIDsToIgnore; /**< Add vertex attribute layer ID's to ignore. */
|
||||
AZStd::vector<uint32> mChunkIDsToIgnore; /**< Add chunk ID's to this array. Chunks with these ID's will not be processed. */
|
||||
AZStd::vector<uint32> mLayerIDsToIgnore; /**< Add vertex attribute layer ID's to ignore. */
|
||||
|
||||
/**
|
||||
* If the actor need to be optimized for server, will overwrite a few other actor settings.
|
||||
@@ -105,7 +105,7 @@ namespace EMotionFX
|
||||
bool mForceLoading = false; /**< Set to true in case you want to load the motion even if a motion with the given filename is already inside the motion manager. */
|
||||
bool mLoadMotionEvents = true; /**< Set to false if you wish to disable loading of motion events. */
|
||||
bool mUnitTypeConvert = true; /**< Set to false to disable automatic unit type conversion (between cm, meters, etc). On default this is enabled. */
|
||||
MCore::Array<uint32> mChunkIDsToIgnore; /**< Add the ID's of the chunks you wish to ignore. */
|
||||
AZStd::vector<uint32> mChunkIDsToIgnore; /**< Add the ID's of the chunks you wish to ignore. */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ namespace EMotionFX
|
||||
Motion* mMotion = nullptr;
|
||||
Importer::ActorSettings* mActorSettings = nullptr;
|
||||
Importer::MotionSettings* mMotionSettings = nullptr;
|
||||
MCore::Array<SharedData*>* mSharedData = nullptr;
|
||||
AZStd::vector<SharedData*>* mSharedData = nullptr;
|
||||
MCore::Endian::EEndianType mEndianType = MCore::Endian::ENDIAN_LITTLE;
|
||||
|
||||
NodeMap* mNodeMap = nullptr;
|
||||
@@ -312,7 +312,7 @@ namespace EMotionFX
|
||||
* @param type The shared data ID to search for.
|
||||
* @return A pointer to the shared data object, or nullptr when no shared data of this type has been found.
|
||||
*/
|
||||
static SharedData* FindSharedData(MCore::Array<SharedData*>* sharedDataArray, uint32 type);
|
||||
static SharedData* FindSharedData(AZStd::vector<SharedData*>* sharedDataArray, uint32 type);
|
||||
|
||||
/**
|
||||
* Enable or disable logging.
|
||||
@@ -355,7 +355,7 @@ namespace EMotionFX
|
||||
|
||||
|
||||
private:
|
||||
MCore::Array<ChunkProcessor*> mChunkProcessors; /**< The registered chunk processors. */
|
||||
AZStd::vector<ChunkProcessor*> mChunkProcessors; /**< The registered chunk processors. */
|
||||
bool mLoggingActive; /**< Contains if the importer should perform logging or not or not. */
|
||||
bool mLogDetails; /**< Contains if the importer should perform detail-logging or not. */
|
||||
|
||||
@@ -414,19 +414,19 @@ namespace EMotionFX
|
||||
* @param sharedData The array which holds the shared data objects.
|
||||
* @param data A pointer to your shared data object.
|
||||
*/
|
||||
static void AddSharedData(MCore::Array<SharedData*>& sharedData, SharedData* data);
|
||||
static void AddSharedData(AZStd::vector<SharedData*>& sharedData, SharedData* data);
|
||||
|
||||
/*
|
||||
* Precreate the standard shared data objects.
|
||||
* @param sharedData The shared data array to work on.
|
||||
*/
|
||||
static void PrepareSharedData(MCore::Array<SharedData*>& sharedData);
|
||||
static void PrepareSharedData(AZStd::vector<SharedData*>& sharedData);
|
||||
|
||||
/**
|
||||
* Reset all shared data objects.
|
||||
* Resetting these objects will clear/empty their internal data.
|
||||
*/
|
||||
static void ResetSharedData(MCore::Array<SharedData*>& sharedData);
|
||||
static void ResetSharedData(AZStd::vector<SharedData*>& sharedData);
|
||||
|
||||
/**
|
||||
* Find the chunk processor which has a given ID and version number.
|
||||
|
||||
@@ -41,22 +41,13 @@ namespace EMotionFX
|
||||
public:
|
||||
AZ_TYPE_INFO_LEGACY(EMotionFX::KeyTrackLinear, "{8C6EB52A-9720-467B-9D96-B4B967A113D1}", StorageType)
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
KeyTrackLinearDynamic();
|
||||
KeyTrackLinearDynamic() = default;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param nrKeys The number of keyframes which the keytrack contains (preallocates this amount of keyframes).
|
||||
*/
|
||||
KeyTrackLinearDynamic(uint32 nrKeys);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~KeyTrackLinearDynamic();
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,13 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// default constructor
|
||||
template <class ReturnType, class StorageType>
|
||||
KeyTrackLinearDynamic<ReturnType, StorageType>::KeyTrackLinearDynamic()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// extended constructor
|
||||
template <class ReturnType, class StorageType>
|
||||
KeyTrackLinearDynamic<ReturnType, StorageType>::KeyTrackLinearDynamic(uint32 nrKeys)
|
||||
@@ -21,13 +14,6 @@ KeyTrackLinearDynamic<ReturnType, StorageType>::KeyTrackLinearDynamic(uint32 nrK
|
||||
}
|
||||
|
||||
|
||||
// destructor
|
||||
template <class ReturnType, class StorageType>
|
||||
KeyTrackLinearDynamic<ReturnType, StorageType>::~KeyTrackLinearDynamic()
|
||||
{
|
||||
ClearKeys();
|
||||
}
|
||||
|
||||
template <class ReturnType, class StorageType>
|
||||
void KeyTrackLinearDynamic<ReturnType, StorageType>::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
|
||||
@@ -36,11 +36,6 @@ namespace EMotionFX
|
||||
mIndices = nullptr;
|
||||
mPolyVertexCounts = nullptr;
|
||||
mIsCollisionMesh = false;
|
||||
|
||||
// set memory categories of the arrays
|
||||
mSubMeshes.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_MESHES);
|
||||
mVertexAttributes.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_MESHES);
|
||||
mSharedVertexAttributes.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_MESHES);
|
||||
}
|
||||
|
||||
// allocation constructor
|
||||
@@ -54,11 +49,6 @@ namespace EMotionFX
|
||||
mPolyVertexCounts = nullptr;
|
||||
mIsCollisionMesh = isCollisionMesh;
|
||||
|
||||
// set memory categories of the arrays
|
||||
mSubMeshes.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_MESHES);
|
||||
mVertexAttributes.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_MESHES);
|
||||
mSharedVertexAttributes.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_MESHES);
|
||||
|
||||
// allocate the mesh data
|
||||
Allocate(numVerts, numIndices, numPolygons, numOrgVerts);
|
||||
}
|
||||
@@ -384,7 +374,7 @@ namespace EMotionFX
|
||||
// copy all original data over the output data
|
||||
void Mesh::ResetToOriginalData()
|
||||
{
|
||||
const uint32 numLayers = mVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
mVertexAttributes[i]->ResetToOriginalData();
|
||||
@@ -402,12 +392,12 @@ namespace EMotionFX
|
||||
RemoveAllVertexAttributeLayers();
|
||||
|
||||
// get rid of all sub meshes
|
||||
const uint32 numSubMeshes = mSubMeshes.GetLength();
|
||||
const uint32 numSubMeshes = mSubMeshes.size();
|
||||
for (uint32 i = 0; i < numSubMeshes; ++i)
|
||||
{
|
||||
mSubMeshes[i]->Destroy();
|
||||
}
|
||||
mSubMeshes.Clear();
|
||||
mSubMeshes.clear();
|
||||
|
||||
if (mIndices)
|
||||
{
|
||||
@@ -668,10 +658,10 @@ namespace EMotionFX
|
||||
|
||||
|
||||
// creates an array of pointers to bones used by this face
|
||||
void Mesh::GatherBonesForFace(uint32 startIndexOfFace, MCore::Array<Node*>& outBones, Actor* actor)
|
||||
void Mesh::GatherBonesForFace(uint32 startIndexOfFace, AZStd::vector<Node*>& outBones, Actor* actor)
|
||||
{
|
||||
// get rid of existing data
|
||||
outBones.Clear();
|
||||
outBones.clear();
|
||||
|
||||
// try to locate the skinning attribute information
|
||||
SkinningInfoVertexAttributeLayer* skinningLayer = (SkinningInfoVertexAttributeLayer*)FindSharedVertexAttributeLayer(SkinningInfoVertexAttributeLayer::TYPE_ID);
|
||||
@@ -703,9 +693,9 @@ namespace EMotionFX
|
||||
Node* bone = skeleton->GetNode(skinningLayer->GetInfluence(originalVertex, n)->GetNodeNr());
|
||||
|
||||
// if it isn't yet in the output array with bones, add it
|
||||
if (outBones.Find(bone) == MCORE_INVALIDINDEX32)
|
||||
if (AZStd::find(begin(outBones), end(outBones), bone) == end(outBones))
|
||||
{
|
||||
outBones.Add(bone);
|
||||
outBones.emplace_back(bone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -818,7 +808,7 @@ namespace EMotionFX
|
||||
void Mesh::RemoveSubMesh(uint32 nr, bool delFromMem)
|
||||
{
|
||||
SubMesh* subMesh = mSubMeshes[nr];
|
||||
mSubMeshes.Remove(nr);
|
||||
mSubMeshes.erase(AZStd::next(begin(mSubMeshes), nr));
|
||||
if (delFromMem)
|
||||
{
|
||||
subMesh->Destroy();
|
||||
@@ -829,7 +819,7 @@ namespace EMotionFX
|
||||
// insert a given submesh
|
||||
void Mesh::InsertSubMesh(uint32 insertIndex, SubMesh* subMesh)
|
||||
{
|
||||
mSubMeshes.Insert(insertIndex, subMesh);
|
||||
mSubMeshes.emplace(AZStd::next(begin(mSubMeshes), insertIndex), subMesh);
|
||||
}
|
||||
|
||||
|
||||
@@ -839,7 +829,7 @@ namespace EMotionFX
|
||||
uint32 numLayers = 0;
|
||||
|
||||
// check the types of all vertex attribute layers
|
||||
const uint32 numAttributes = mVertexAttributes.GetLength();
|
||||
const uint32 numAttributes = mVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numAttributes; ++i)
|
||||
{
|
||||
if (mVertexAttributes[i]->GetType() == type)
|
||||
@@ -862,21 +852,21 @@ namespace EMotionFX
|
||||
|
||||
VertexAttributeLayer* Mesh::GetSharedVertexAttributeLayer(uint32 layerNr)
|
||||
{
|
||||
MCORE_ASSERT(layerNr < mSharedVertexAttributes.GetLength());
|
||||
MCORE_ASSERT(layerNr < mSharedVertexAttributes.size());
|
||||
return mSharedVertexAttributes[layerNr];
|
||||
}
|
||||
|
||||
|
||||
void Mesh::AddSharedVertexAttributeLayer(VertexAttributeLayer* layer)
|
||||
{
|
||||
MCORE_ASSERT(mSharedVertexAttributes.Contains(layer) == false);
|
||||
mSharedVertexAttributes.Add(layer);
|
||||
MCORE_ASSERT(AZStd::find(begin(mSharedVertexAttributes), end(mSharedVertexAttributes), layer) == end(mSharedVertexAttributes));
|
||||
mSharedVertexAttributes.emplace_back(layer);
|
||||
}
|
||||
|
||||
|
||||
uint32 Mesh::GetNumSharedVertexAttributeLayers() const
|
||||
size_t Mesh::GetNumSharedVertexAttributeLayers() const
|
||||
{
|
||||
return mSharedVertexAttributes.GetLength();
|
||||
return mSharedVertexAttributes.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -885,7 +875,7 @@ namespace EMotionFX
|
||||
uint32 layerCounter = 0;
|
||||
|
||||
// check all vertex attributes of our first vertex, and find where the specific attribute is
|
||||
const uint32 numLayers = mSharedVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mSharedVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
VertexAttributeLayer* layer = mSharedVertexAttributes[i];
|
||||
@@ -922,10 +912,10 @@ namespace EMotionFX
|
||||
// delete all shared attribute layers
|
||||
void Mesh::RemoveAllSharedVertexAttributeLayers()
|
||||
{
|
||||
while (mSharedVertexAttributes.GetLength())
|
||||
while (mSharedVertexAttributes.size())
|
||||
{
|
||||
mSharedVertexAttributes.GetLast()->Destroy();
|
||||
mSharedVertexAttributes.RemoveLast();
|
||||
mSharedVertexAttributes.back()->Destroy();
|
||||
mSharedVertexAttributes.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,29 +923,29 @@ namespace EMotionFX
|
||||
// remove a layer by its index
|
||||
void Mesh::RemoveSharedVertexAttributeLayer(uint32 layerNr)
|
||||
{
|
||||
MCORE_ASSERT(layerNr < mSharedVertexAttributes.GetLength());
|
||||
MCORE_ASSERT(layerNr < mSharedVertexAttributes.size());
|
||||
mSharedVertexAttributes[layerNr]->Destroy();
|
||||
mSharedVertexAttributes.Remove(layerNr);
|
||||
mSharedVertexAttributes.erase(AZStd::next(begin(mSharedVertexAttributes), layerNr));
|
||||
}
|
||||
|
||||
|
||||
uint32 Mesh::GetNumVertexAttributeLayers() const
|
||||
size_t Mesh::GetNumVertexAttributeLayers() const
|
||||
{
|
||||
return mVertexAttributes.GetLength();
|
||||
return mVertexAttributes.size();
|
||||
}
|
||||
|
||||
|
||||
VertexAttributeLayer* Mesh::GetVertexAttributeLayer(uint32 layerNr)
|
||||
{
|
||||
MCORE_ASSERT(layerNr < mVertexAttributes.GetLength());
|
||||
MCORE_ASSERT(layerNr < mVertexAttributes.size());
|
||||
return mVertexAttributes[layerNr];
|
||||
}
|
||||
|
||||
|
||||
void Mesh::AddVertexAttributeLayer(VertexAttributeLayer* layer)
|
||||
{
|
||||
MCORE_ASSERT(mVertexAttributes.Contains(layer) == false);
|
||||
mVertexAttributes.Add(layer);
|
||||
MCORE_ASSERT(AZStd::find(begin(mVertexAttributes), end(mVertexAttributes), layer) == end(mVertexAttributes));
|
||||
mVertexAttributes.emplace_back(layer);
|
||||
}
|
||||
|
||||
|
||||
@@ -965,7 +955,7 @@ namespace EMotionFX
|
||||
uint32 layerCounter = 0;
|
||||
|
||||
// check all vertex attributes of our first vertex, and find where the specific attribute is
|
||||
const uint32 numLayers = mVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
VertexAttributeLayer* layer = mVertexAttributes[i];
|
||||
@@ -989,7 +979,7 @@ namespace EMotionFX
|
||||
uint32 Mesh::FindVertexAttributeLayerNumberByName(uint32 layerTypeID, const char* name) const
|
||||
{
|
||||
// check all vertex attributes of our first vertex, and find where the specific attribute is
|
||||
const uint32 numLayers = mVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
VertexAttributeLayer* layer = mVertexAttributes[i];
|
||||
@@ -1035,19 +1025,19 @@ namespace EMotionFX
|
||||
|
||||
void Mesh::RemoveAllVertexAttributeLayers()
|
||||
{
|
||||
while (mVertexAttributes.GetLength())
|
||||
while (mVertexAttributes.size())
|
||||
{
|
||||
mVertexAttributes.GetLast()->Destroy();
|
||||
mVertexAttributes.RemoveLast();
|
||||
mVertexAttributes.back()->Destroy();
|
||||
mVertexAttributes.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Mesh::RemoveVertexAttributeLayer(uint32 layerNr)
|
||||
{
|
||||
MCORE_ASSERT(layerNr < mVertexAttributes.GetLength());
|
||||
MCORE_ASSERT(layerNr < mVertexAttributes.size());
|
||||
mVertexAttributes[layerNr]->Destroy();
|
||||
mVertexAttributes.Remove(layerNr);
|
||||
mVertexAttributes.erase(AZStd::next(begin(mVertexAttributes), layerNr));
|
||||
}
|
||||
|
||||
|
||||
@@ -1064,24 +1054,24 @@ namespace EMotionFX
|
||||
|
||||
// copy the submesh data
|
||||
uint32 i;
|
||||
const uint32 numSubMeshes = mSubMeshes.GetLength();
|
||||
clone->mSubMeshes.Resize(numSubMeshes);
|
||||
const uint32 numSubMeshes = mSubMeshes.size();
|
||||
clone->mSubMeshes.resize(numSubMeshes);
|
||||
for (i = 0; i < numSubMeshes; ++i)
|
||||
{
|
||||
clone->mSubMeshes[i] = mSubMeshes[i]->Clone(clone);
|
||||
}
|
||||
|
||||
// clone the shared vertex attributes
|
||||
const uint32 numSharedAttributes = mSharedVertexAttributes.GetLength();
|
||||
clone->mSharedVertexAttributes.Resize(numSharedAttributes);
|
||||
const uint32 numSharedAttributes = mSharedVertexAttributes.size();
|
||||
clone->mSharedVertexAttributes.resize(numSharedAttributes);
|
||||
for (i = 0; i < numSharedAttributes; ++i)
|
||||
{
|
||||
clone->mSharedVertexAttributes[i] = mSharedVertexAttributes[i]->Clone();
|
||||
}
|
||||
|
||||
// clone the non-shared vertex attributes
|
||||
const uint32 numAttributes = mVertexAttributes.GetLength();
|
||||
clone->mVertexAttributes.Resize(numAttributes);
|
||||
const uint32 numAttributes = mVertexAttributes.size();
|
||||
clone->mVertexAttributes.resize(numAttributes);
|
||||
for (i = 0; i < numAttributes; ++i)
|
||||
{
|
||||
clone->mVertexAttributes[i] = mVertexAttributes[i]->Clone();
|
||||
@@ -1105,7 +1095,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// swap all vertex attribute layers
|
||||
const uint32 numLayers = mVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
mVertexAttributes[i]->SwapAttributes(vertexA, vertexB);
|
||||
@@ -1229,7 +1219,7 @@ namespace EMotionFX
|
||||
for (uint32 w = 0; w < numVertsToRemove; ++w)
|
||||
{
|
||||
// adjust all submesh start index offsets changed
|
||||
for (uint32 s = 0; s < mSubMeshes.GetLength();)
|
||||
for (uint32 s = 0; s < mSubMeshes.size();)
|
||||
{
|
||||
SubMesh* subMesh = mSubMeshes[s];
|
||||
|
||||
@@ -1249,7 +1239,7 @@ namespace EMotionFX
|
||||
// remove the submesh if it's empty
|
||||
if (subMesh->GetNumVertices() == 0 && removeEmptySubMeshes)
|
||||
{
|
||||
mSubMeshes.Remove(s);
|
||||
mSubMeshes.erase(AZStd::next(begin(mSubMeshes), s));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1283,7 +1273,7 @@ namespace EMotionFX
|
||||
uint32 numRemoved = 0;
|
||||
|
||||
// for all the submeshes
|
||||
for (uint32 i = 0; i < mSubMeshes.GetLength();)
|
||||
for (uint32 i = 0; i < mSubMeshes.size();)
|
||||
{
|
||||
SubMesh* subMesh = mSubMeshes[i];
|
||||
|
||||
@@ -1305,7 +1295,7 @@ namespace EMotionFX
|
||||
// remove or skip
|
||||
if (mustRemove)
|
||||
{
|
||||
mSubMeshes.Remove(i);
|
||||
mSubMeshes.erase(AZStd::next(begin(mSubMeshes), i));
|
||||
numRemoved++;
|
||||
}
|
||||
else
|
||||
@@ -1966,7 +1956,7 @@ namespace EMotionFX
|
||||
|
||||
void Mesh::ReserveVertexAttributeLayerSpace(uint32 numLayers)
|
||||
{
|
||||
mVertexAttributes.Reserve(numLayers);
|
||||
mVertexAttributes.reserve(numLayers);
|
||||
}
|
||||
|
||||
|
||||
@@ -2003,7 +1993,7 @@ namespace EMotionFX
|
||||
// find by name
|
||||
uint32 Mesh::FindVertexAttributeLayerIndexByName(const char* name) const
|
||||
{
|
||||
const uint32 numLayers = mVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
if (mVertexAttributes[i]->GetNameString() == name)
|
||||
@@ -2019,7 +2009,7 @@ namespace EMotionFX
|
||||
// find by name as string
|
||||
uint32 Mesh::FindVertexAttributeLayerIndexByNameString(const AZStd::string& name) const
|
||||
{
|
||||
const uint32 numLayers = mVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
if (mVertexAttributes[i]->GetNameString() == name)
|
||||
@@ -2035,7 +2025,7 @@ namespace EMotionFX
|
||||
// find by name ID
|
||||
uint32 Mesh::FindVertexAttributeLayerIndexByNameID(uint32 nameID) const
|
||||
{
|
||||
const uint32 numLayers = mVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
if (mVertexAttributes[i]->GetNameID() == nameID)
|
||||
@@ -2051,7 +2041,7 @@ namespace EMotionFX
|
||||
// find by name
|
||||
uint32 Mesh::FindSharedVertexAttributeLayerIndexByName(const char* name) const
|
||||
{
|
||||
const uint32 numLayers = mSharedVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mSharedVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
if (mSharedVertexAttributes[i]->GetNameString() == name)
|
||||
@@ -2067,7 +2057,7 @@ namespace EMotionFX
|
||||
// find by name as string
|
||||
uint32 Mesh::FindSharedVertexAttributeLayerIndexByNameString(const AZStd::string& name) const
|
||||
{
|
||||
const uint32 numLayers = mSharedVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mSharedVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
if (mSharedVertexAttributes[i]->GetNameString() == name)
|
||||
@@ -2083,7 +2073,7 @@ namespace EMotionFX
|
||||
// find by name ID
|
||||
uint32 Mesh::FindSharedVertexAttributeLayerIndexByNameID(uint32 nameID) const
|
||||
{
|
||||
const uint32 numLayers = mSharedVertexAttributes.GetLength();
|
||||
const uint32 numLayers = mSharedVertexAttributes.size();
|
||||
for (uint32 i = 0; i < numLayers; ++i)
|
||||
{
|
||||
if (mSharedVertexAttributes[i]->GetNameID() == nameID)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "Transform.h"
|
||||
|
||||
#include <MCore/Source/Vector.h>
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/Ray.h>
|
||||
#include <MCore/Source/Color.h>
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace EMotionFX
|
||||
* Get the number of sub meshes currently in the mesh.
|
||||
* @result The number of sub meshes.
|
||||
*/
|
||||
MCORE_INLINE uint32 GetNumSubMeshes() const;
|
||||
MCORE_INLINE size_t GetNumSubMeshes() const;
|
||||
|
||||
/**
|
||||
* Get a given SubMesh.
|
||||
@@ -257,7 +257,7 @@ namespace EMotionFX
|
||||
* Do not forget to use SetSubMesh() to initialize all submeshes!
|
||||
* @param numSubMeshes The number of submeshes to use.
|
||||
*/
|
||||
MCORE_INLINE void SetNumSubMeshes(uint32 numSubMeshes) { mSubMeshes.Resize(numSubMeshes); }
|
||||
MCORE_INLINE void SetNumSubMeshes(uint32 numSubMeshes) { mSubMeshes.resize(numSubMeshes); }
|
||||
|
||||
/**
|
||||
* Remove a given submesh from this mesh.
|
||||
@@ -293,7 +293,7 @@ namespace EMotionFX
|
||||
* This value is the same for all shared vertices.
|
||||
* @result The number of shared vertex attributes for every vertex.
|
||||
*/
|
||||
uint32 GetNumSharedVertexAttributeLayers() const;
|
||||
size_t GetNumSharedVertexAttributeLayers() const;
|
||||
|
||||
/**
|
||||
* Find and return the shared vertex attribute layer of a given type.
|
||||
@@ -338,7 +338,7 @@ namespace EMotionFX
|
||||
* This value is the same for all vertices.
|
||||
* @result The number of vertex attributes for every vertex.
|
||||
*/
|
||||
uint32 GetNumVertexAttributeLayers() const;
|
||||
size_t GetNumVertexAttributeLayers() const;
|
||||
|
||||
/**
|
||||
* Get the vertex attribute data of a given layer.
|
||||
@@ -447,7 +447,7 @@ namespace EMotionFX
|
||||
* @param outBones The array to store the pointers to the bones in. Any existing array contents will be cleared when it enters the method.
|
||||
* @param actor The actor to search the bones in.
|
||||
*/
|
||||
void GatherBonesForFace(uint32 startIndexOfFace, MCore::Array<Node*>& outBones, Actor* actor);
|
||||
void GatherBonesForFace(uint32 startIndexOfFace, AZStd::vector<Node*>& outBones, Actor* actor);
|
||||
|
||||
/**
|
||||
* Calculates the maximum number of bone influences for a given face.
|
||||
@@ -653,7 +653,7 @@ namespace EMotionFX
|
||||
|
||||
protected:
|
||||
|
||||
MCore::Array<SubMesh*> mSubMeshes; /**< The collection of sub meshes. */
|
||||
AZStd::vector<SubMesh*> mSubMeshes; /**< The collection of sub meshes. */
|
||||
uint32* mIndices; /**< The array of indices, which define the faces. */
|
||||
uint8* mPolyVertexCounts; /**< The number of vertices for each polygon, where the length of this array equals the number of polygons. */
|
||||
uint32 mNumPolygons; /**< The number of polygons in this mesh. */
|
||||
@@ -666,13 +666,13 @@ namespace EMotionFX
|
||||
* The array of shared vertex attribute layers.
|
||||
* The number of attributes in each shared layer will be equal to the value returned by Mesh::GetNumOrgVertices().
|
||||
*/
|
||||
MCore::Array< VertexAttributeLayer* > mSharedVertexAttributes;
|
||||
AZStd::vector< VertexAttributeLayer* > mSharedVertexAttributes;
|
||||
|
||||
/**
|
||||
* The array of non-shared vertex attribute layers.
|
||||
* The number of attributes in each shared layer will be equal to the value returned by Mesh::GetNumVertices().
|
||||
*/
|
||||
MCore::Array< VertexAttributeLayer* > mVertexAttributes;
|
||||
AZStd::vector< VertexAttributeLayer* > mVertexAttributes;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
|
||||
@@ -24,22 +24,22 @@ MCORE_INLINE uint32 Mesh::GetNumPolygons() const
|
||||
}
|
||||
|
||||
|
||||
MCORE_INLINE uint32 Mesh::GetNumSubMeshes() const
|
||||
MCORE_INLINE size_t Mesh::GetNumSubMeshes() const
|
||||
{
|
||||
return mSubMeshes.GetLength();
|
||||
return mSubMeshes.size();
|
||||
}
|
||||
|
||||
|
||||
MCORE_INLINE SubMesh* Mesh::GetSubMesh(uint32 nr) const
|
||||
{
|
||||
MCORE_ASSERT(nr < mSubMeshes.GetLength());
|
||||
MCORE_ASSERT(nr < mSubMeshes.size());
|
||||
return mSubMeshes[nr];
|
||||
}
|
||||
|
||||
|
||||
MCORE_INLINE void Mesh::AddSubMesh(SubMesh* subMesh)
|
||||
{
|
||||
mSubMeshes.Add(subMesh);
|
||||
mSubMeshes.emplace_back(subMesh);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,20 +22,19 @@ namespace EMotionFX
|
||||
: BaseObject()
|
||||
{
|
||||
mMesh = mesh;
|
||||
mDeformers.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_DEFORMERS);
|
||||
}
|
||||
|
||||
|
||||
// destructor
|
||||
MeshDeformerStack::~MeshDeformerStack()
|
||||
{
|
||||
const uint32 numDeformers = mDeformers.GetLength();
|
||||
const uint32 numDeformers = mDeformers.size();
|
||||
for (uint32 i = 0; i < numDeformers; ++i)
|
||||
{
|
||||
mDeformers[i]->Destroy();
|
||||
}
|
||||
|
||||
mDeformers.Clear();
|
||||
mDeformers.clear();
|
||||
|
||||
// reset
|
||||
mMesh = nullptr;
|
||||
@@ -60,7 +59,7 @@ namespace EMotionFX
|
||||
void MeshDeformerStack::Update(ActorInstance* actorInstance, Node* node, float timeDelta, bool forceUpdateDisabledDeformers)
|
||||
{
|
||||
// if we have deformers in the stack
|
||||
const uint32 numDeformers = mDeformers.GetLength();
|
||||
const uint32 numDeformers = mDeformers.size();
|
||||
if (numDeformers > 0)
|
||||
{
|
||||
bool firstEnabled = true;
|
||||
@@ -92,7 +91,7 @@ namespace EMotionFX
|
||||
{
|
||||
bool resetDone = false;
|
||||
// if we have deformers in the stack
|
||||
const uint32 numDeformers = mDeformers.GetLength();
|
||||
const uint32 numDeformers = mDeformers.size();
|
||||
// iterate through the deformers and update them
|
||||
for (uint32 i = 0; i < numDeformers; ++i)
|
||||
{
|
||||
@@ -118,7 +117,7 @@ namespace EMotionFX
|
||||
void MeshDeformerStack::ReinitializeDeformers(Actor* actor, Node* node, uint32 lodLevel)
|
||||
{
|
||||
// if we have deformers in the stack
|
||||
const uint32 numDeformers = mDeformers.GetLength();
|
||||
const uint32 numDeformers = mDeformers.size();
|
||||
|
||||
// iterate through the deformers and reinitialize them
|
||||
for (uint32 i = 0; i < numDeformers; ++i)
|
||||
@@ -131,21 +130,26 @@ namespace EMotionFX
|
||||
void MeshDeformerStack::AddDeformer(MeshDeformer* meshDeformer)
|
||||
{
|
||||
// add the object into the stack
|
||||
mDeformers.Add(meshDeformer);
|
||||
mDeformers.emplace_back(meshDeformer);
|
||||
}
|
||||
|
||||
|
||||
void MeshDeformerStack::InsertDeformer(uint32 pos, MeshDeformer* meshDeformer)
|
||||
{
|
||||
// add the object into the stack
|
||||
mDeformers.Insert(pos, meshDeformer);
|
||||
mDeformers.emplace(AZStd::next(begin(mDeformers), pos), meshDeformer);
|
||||
}
|
||||
|
||||
|
||||
bool MeshDeformerStack::RemoveDeformer(MeshDeformer* meshDeformer)
|
||||
{
|
||||
// delete the object
|
||||
return mDeformers.RemoveByValue(meshDeformer);
|
||||
if (const auto it = AZStd::find(begin(mDeformers), end(mDeformers), meshDeformer); it != end(mDeformers))
|
||||
{
|
||||
mDeformers.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +159,7 @@ namespace EMotionFX
|
||||
MeshDeformerStack* newStack = aznew MeshDeformerStack(mesh);
|
||||
|
||||
// clone all deformers
|
||||
const uint32 numDeformers = mDeformers.GetLength();
|
||||
const uint32 numDeformers = mDeformers.size();
|
||||
for (uint32 i = 0; i < numDeformers; ++i)
|
||||
{
|
||||
newStack->AddDeformer(mDeformers[i]->Clone(mesh));
|
||||
@@ -166,15 +170,15 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
|
||||
uint32 MeshDeformerStack::GetNumDeformers() const
|
||||
size_t MeshDeformerStack::GetNumDeformers() const
|
||||
{
|
||||
return mDeformers.GetLength();
|
||||
return mDeformers.size();
|
||||
}
|
||||
|
||||
|
||||
MeshDeformer* MeshDeformerStack::GetDeformer(uint32 nr) const
|
||||
{
|
||||
MCORE_ASSERT(nr < mDeformers.GetLength());
|
||||
MCORE_ASSERT(nr < mDeformers.size());
|
||||
return mDeformers[nr];
|
||||
}
|
||||
|
||||
@@ -183,7 +187,7 @@ namespace EMotionFX
|
||||
uint32 MeshDeformerStack::RemoveAllDeformersByType(uint32 deformerTypeID)
|
||||
{
|
||||
uint32 numRemoved = 0;
|
||||
for (uint32 a = 0; a < mDeformers.GetLength(); )
|
||||
for (uint32 a = 0; a < mDeformers.size(); )
|
||||
{
|
||||
MeshDeformer* deformer = mDeformers[a];
|
||||
if (deformer->GetType() == deformerTypeID)
|
||||
@@ -205,7 +209,7 @@ namespace EMotionFX
|
||||
// remove all the deformers
|
||||
void MeshDeformerStack::RemoveAllDeformers()
|
||||
{
|
||||
for (uint32 i = 0; i < mDeformers.GetLength(); ++i)
|
||||
for (uint32 i = 0; i < mDeformers.size(); ++i)
|
||||
{
|
||||
// retrieve the current deformer
|
||||
MeshDeformer* deformer = mDeformers[i];
|
||||
@@ -221,7 +225,7 @@ namespace EMotionFX
|
||||
uint32 MeshDeformerStack::EnableAllDeformersByType(uint32 deformerTypeID, bool enabled)
|
||||
{
|
||||
uint32 numChanged = 0;
|
||||
const uint32 numDeformers = mDeformers.GetLength();
|
||||
const uint32 numDeformers = mDeformers.size();
|
||||
for (uint32 a = 0; a < numDeformers; ++a)
|
||||
{
|
||||
MeshDeformer* deformer = mDeformers[a];
|
||||
@@ -239,7 +243,7 @@ namespace EMotionFX
|
||||
// check if the stack contains a deformer of a specified type
|
||||
bool MeshDeformerStack::CheckIfHasDeformerOfType(uint32 deformerTypeID) const
|
||||
{
|
||||
const uint32 numDeformers = mDeformers.GetLength();
|
||||
const uint32 numDeformers = mDeformers.size();
|
||||
for (uint32 a = 0; a < numDeformers; ++a)
|
||||
{
|
||||
if (mDeformers[a]->GetType() == deformerTypeID)
|
||||
@@ -258,7 +262,7 @@ namespace EMotionFX
|
||||
uint32 count = 0;
|
||||
|
||||
// for all deformers
|
||||
const uint32 numDeformers = mDeformers.GetLength();
|
||||
const uint32 numDeformers = mDeformers.size();
|
||||
for (uint32 a = 0; a < numDeformers; ++a)
|
||||
{
|
||||
// if this is a deformer of the type we search for
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "EMotionFXConfig.h"
|
||||
#include "MeshDeformer.h"
|
||||
#include "BaseObject.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -134,7 +134,7 @@ namespace EMotionFX
|
||||
* Get the number of deformers in the stack.
|
||||
* @result The number of deformers in the stack.
|
||||
*/
|
||||
uint32 GetNumDeformers() const;
|
||||
size_t GetNumDeformers() const;
|
||||
|
||||
/**
|
||||
* Get a given deformer.
|
||||
@@ -159,7 +159,7 @@ namespace EMotionFX
|
||||
MeshDeformer* FindDeformerByType(uint32 deformerTypeID, uint32 occurrence = 0) const;
|
||||
|
||||
private:
|
||||
MCore::Array<MeshDeformer*> mDeformers; /**< The stack of deformers. */
|
||||
AZStd::vector<MeshDeformer*> mDeformers; /**< The stack of deformers. */
|
||||
Mesh* mMesh; /**< Pointer to the mesh to which the modifier stack belongs to.*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace EMotionFX
|
||||
MorphMeshDeformer::MorphMeshDeformer(Mesh* mesh)
|
||||
: MeshDeformer(mesh)
|
||||
{
|
||||
mDeformPasses.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_DEFORMERS);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +63,8 @@ namespace EMotionFX
|
||||
MorphMeshDeformer* result = aznew MorphMeshDeformer(mesh);
|
||||
|
||||
// copy the deform passes
|
||||
result->mDeformPasses.Resize(mDeformPasses.GetLength());
|
||||
for (uint32 i = 0; i < mDeformPasses.GetLength(); ++i)
|
||||
result->mDeformPasses.resize(mDeformPasses.size());
|
||||
for (uint32 i = 0; i < mDeformPasses.size(); ++i)
|
||||
{
|
||||
DeformPass& pass = result->mDeformPasses[i];
|
||||
pass.mDeformDataNr = mDeformPasses[i].mDeformDataNr;
|
||||
@@ -89,7 +88,7 @@ namespace EMotionFX
|
||||
const uint32 lodLevel = actorInstance->GetLODLevel();
|
||||
|
||||
// apply all deform passes
|
||||
const uint32 numPasses = mDeformPasses.GetLength();
|
||||
const uint32 numPasses = mDeformPasses.size();
|
||||
for (uint32 i = 0; i < numPasses; ++i)
|
||||
{
|
||||
// find the morph target
|
||||
@@ -198,7 +197,7 @@ namespace EMotionFX
|
||||
void MorphMeshDeformer::Reinitialize(Actor* actor, Node* node, uint32 lodLevel)
|
||||
{
|
||||
// clear the deform passes, but don't free the currently allocated/reserved memory
|
||||
mDeformPasses.Clear(false);
|
||||
mDeformPasses.clear();
|
||||
|
||||
// get the morph setup
|
||||
MorphSetup* morphSetup = actor->GetMorphSetup(lodLevel);
|
||||
@@ -219,8 +218,8 @@ namespace EMotionFX
|
||||
if (deformData->mNodeIndex == node->GetNodeIndex())
|
||||
{
|
||||
// add an empty deform pass and fill it afterwards
|
||||
mDeformPasses.AddEmpty();
|
||||
const uint32 deformPassIndex = mDeformPasses.GetLength() - 1;
|
||||
mDeformPasses.emplace_back();
|
||||
const uint32 deformPassIndex = mDeformPasses.size() - 1;
|
||||
mDeformPasses[deformPassIndex].mDeformDataNr = j;
|
||||
mDeformPasses[deformPassIndex].mMorphTarget = morphTarget;
|
||||
}
|
||||
@@ -231,18 +230,18 @@ namespace EMotionFX
|
||||
|
||||
void MorphMeshDeformer::AddDeformPass(const DeformPass& deformPass)
|
||||
{
|
||||
mDeformPasses.Add(deformPass);
|
||||
mDeformPasses.emplace_back(deformPass);
|
||||
}
|
||||
|
||||
|
||||
uint32 MorphMeshDeformer::GetNumDeformPasses() const
|
||||
size_t MorphMeshDeformer::GetNumDeformPasses() const
|
||||
{
|
||||
return mDeformPasses.GetLength();
|
||||
return mDeformPasses.size();
|
||||
}
|
||||
|
||||
|
||||
void MorphMeshDeformer::ReserveDeformPasses(uint32 numPasses)
|
||||
{
|
||||
mDeformPasses.Reserve(numPasses);
|
||||
mDeformPasses.reserve(numPasses);
|
||||
}
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace EMotionFX
|
||||
* Get the number of deform passes.
|
||||
* @result The number of deform passes.
|
||||
*/
|
||||
uint32 GetNumDeformPasses() const;
|
||||
size_t GetNumDeformPasses() const;
|
||||
|
||||
/**
|
||||
* Pre-allocate space for the deform passes.
|
||||
@@ -132,7 +132,7 @@ namespace EMotionFX
|
||||
void ReserveDeformPasses(uint32 numPasses);
|
||||
|
||||
private:
|
||||
MCore::Array<DeformPass> mDeformPasses; /**< The deform passes. Each pass basically represents a morph target. */
|
||||
AZStd::vector<DeformPass> mDeformPasses; /**< The deform passes. Each pass basically represents a morph target. */
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "MorphSetup.h"
|
||||
#include "MorphTarget.h"
|
||||
#include <MCore/Source/StringConversions.h>
|
||||
#include <MCore/Source/FastMath.h>
|
||||
#include <EMotionFX/Source/Allocators.h>
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -17,14 +18,6 @@ namespace EMotionFX
|
||||
AZ_CLASS_ALLOCATOR_IMPL(MorphSetup, DeformerAllocator, 0)
|
||||
|
||||
|
||||
// constructor
|
||||
MorphSetup::MorphSetup()
|
||||
: BaseObject()
|
||||
{
|
||||
mMorphTargets.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_PMORPHTARGETS);
|
||||
}
|
||||
|
||||
|
||||
// destructor
|
||||
MorphSetup::~MorphSetup()
|
||||
{
|
||||
@@ -42,7 +35,7 @@ namespace EMotionFX
|
||||
// add a morph target
|
||||
void MorphSetup::AddMorphTarget(MorphTarget* morphTarget)
|
||||
{
|
||||
mMorphTargets.Add(morphTarget);
|
||||
mMorphTargets.emplace_back(morphTarget);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,14 +47,18 @@ namespace EMotionFX
|
||||
mMorphTargets[nr]->Destroy();
|
||||
}
|
||||
|
||||
mMorphTargets.Remove(nr);
|
||||
mMorphTargets.erase(AZStd::next(begin(mMorphTargets), nr));
|
||||
}
|
||||
|
||||
|
||||
// remove a morph target
|
||||
void MorphSetup::RemoveMorphTarget(MorphTarget* morphTarget, bool delFromMem)
|
||||
{
|
||||
mMorphTargets.RemoveByValue(morphTarget);
|
||||
const auto* foundMorphTarget = AZStd::find(begin(mMorphTargets), end(mMorphTargets), morphTarget);
|
||||
if (foundMorphTarget != end(mMorphTargets))
|
||||
{
|
||||
mMorphTargets.erase(foundMorphTarget);
|
||||
}
|
||||
|
||||
if (delFromMem)
|
||||
{
|
||||
@@ -73,13 +70,13 @@ namespace EMotionFX
|
||||
// remove all morph targets
|
||||
void MorphSetup::RemoveAllMorphTargets()
|
||||
{
|
||||
const uint32 numTargets = mMorphTargets.GetLength();
|
||||
const uint32 numTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numTargets; ++i)
|
||||
{
|
||||
mMorphTargets[i]->Destroy();
|
||||
}
|
||||
|
||||
mMorphTargets.Clear();
|
||||
mMorphTargets.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +84,7 @@ namespace EMotionFX
|
||||
MorphTarget* MorphSetup::FindMorphTargetByID(uint32 id) const
|
||||
{
|
||||
// linear search, and check IDs
|
||||
const uint32 numTargets = mMorphTargets.GetLength();
|
||||
const uint32 numTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numTargets; ++i)
|
||||
{
|
||||
if (mMorphTargets[i]->GetID() == id)
|
||||
@@ -105,7 +102,7 @@ namespace EMotionFX
|
||||
uint32 MorphSetup::FindMorphTargetNumberByID(uint32 id) const
|
||||
{
|
||||
// linear search, and check IDs
|
||||
const uint32 numTargets = mMorphTargets.GetLength();
|
||||
const uint32 numTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numTargets; ++i)
|
||||
{
|
||||
if (mMorphTargets[i]->GetID() == id)
|
||||
@@ -121,7 +118,7 @@ namespace EMotionFX
|
||||
|
||||
uint32 MorphSetup::FindMorphTargetIndexByName(const char* name) const
|
||||
{
|
||||
const uint32 numTargets = mMorphTargets.GetLength();
|
||||
const uint32 numTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numTargets; ++i)
|
||||
{
|
||||
if (mMorphTargets[i]->GetNameString() == name)
|
||||
@@ -136,7 +133,7 @@ namespace EMotionFX
|
||||
|
||||
uint32 MorphSetup::FindMorphTargetIndexByNameNoCase(const char* name) const
|
||||
{
|
||||
const uint32 numTargets = mMorphTargets.GetLength();
|
||||
const uint32 numTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numTargets; ++i)
|
||||
{
|
||||
if (AzFramework::StringFunc::Equal(mMorphTargets[i]->GetNameString().c_str(), name, false /* no case */))
|
||||
@@ -152,7 +149,7 @@ namespace EMotionFX
|
||||
// find a morph target by name (case sensitive)
|
||||
MorphTarget* MorphSetup::FindMorphTargetByName(const char* name) const
|
||||
{
|
||||
const uint32 numTargets = mMorphTargets.GetLength();
|
||||
const uint32 numTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numTargets; ++i)
|
||||
{
|
||||
if (mMorphTargets[i]->GetNameString() == name)
|
||||
@@ -168,7 +165,7 @@ namespace EMotionFX
|
||||
// find a morph target by name (not case sensitive)
|
||||
MorphTarget* MorphSetup::FindMorphTargetByNameNoCase(const char* name) const
|
||||
{
|
||||
const uint32 numTargets = mMorphTargets.GetLength();
|
||||
const uint32 numTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numTargets; ++i)
|
||||
{
|
||||
if (AzFramework::StringFunc::Equal(mMorphTargets[i]->GetNameString().c_str(), name, false /* no case */))
|
||||
@@ -188,7 +185,7 @@ namespace EMotionFX
|
||||
MorphSetup* clone = MorphSetup::Create();
|
||||
|
||||
// clone all morph targets
|
||||
const uint32 numMorphTargets = mMorphTargets.GetLength();
|
||||
const uint32 numMorphTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numMorphTargets; ++i)
|
||||
{
|
||||
clone->AddMorphTarget(mMorphTargets[i]->Clone());
|
||||
@@ -201,7 +198,7 @@ namespace EMotionFX
|
||||
|
||||
void MorphSetup::ReserveMorphTargets(uint32 numMorphTargets)
|
||||
{
|
||||
mMorphTargets.Reserve(numMorphTargets);
|
||||
mMorphTargets.reserve(numMorphTargets);
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +212,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// scale the morph targets
|
||||
const uint32 numMorphTargets = mMorphTargets.GetLength();
|
||||
const uint32 numMorphTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numMorphTargets; ++i)
|
||||
{
|
||||
mMorphTargets[i]->Scale(scaleFactor);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace EMotionFX
|
||||
* Get the number of morph targets inside this morph setup.
|
||||
* @result The number of morph targets.
|
||||
*/
|
||||
MCORE_INLINE uint32 GetNumMorphTargets() const { return mMorphTargets.GetLength(); }
|
||||
MCORE_INLINE size_t GetNumMorphTargets() const { return mMorphTargets.size(); }
|
||||
|
||||
/**
|
||||
* Get a given morph target.
|
||||
@@ -137,12 +137,12 @@ namespace EMotionFX
|
||||
|
||||
|
||||
protected:
|
||||
MCore::Array<MorphTarget*> mMorphTargets; /**< The collection of morph targets. */
|
||||
AZStd::vector<MorphTarget*> mMorphTargets; /**< The collection of morph targets. */
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
MorphSetup();
|
||||
MorphSetup() = default;
|
||||
|
||||
/**
|
||||
* The destructor. Automatically removes all morph targets from memory.
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace EMotionFX
|
||||
MorphSetupInstance::MorphSetupInstance()
|
||||
: BaseObject()
|
||||
{
|
||||
mMorphTargets.SetMemoryCategory(EMFX_MEMCATEGORY_GEOMETRY_PMORPHTARGETS);
|
||||
Init(nullptr);
|
||||
}
|
||||
|
||||
@@ -63,7 +62,7 @@ namespace EMotionFX
|
||||
|
||||
// allocate the number of morph targets
|
||||
const uint32 numMorphTargets = morphSetup->GetNumMorphTargets();
|
||||
mMorphTargets.Resize(numMorphTargets);
|
||||
mMorphTargets.resize(numMorphTargets);
|
||||
|
||||
// update the ID values
|
||||
for (uint32 i = 0; i < numMorphTargets; ++i)
|
||||
@@ -77,7 +76,7 @@ namespace EMotionFX
|
||||
uint32 MorphSetupInstance::FindMorphTargetIndexByID(uint32 id) const
|
||||
{
|
||||
// try to locate the morph target with the given ID
|
||||
const uint32 numTargets = mMorphTargets.GetLength();
|
||||
const uint32 numTargets = mMorphTargets.size();
|
||||
for (uint32 i = 0; i < numTargets; ++i)
|
||||
{
|
||||
if (mMorphTargets[i].GetID() == id)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// include the required headers
|
||||
#include "EMotionFXConfig.h"
|
||||
#include "BaseObject.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -123,7 +123,7 @@ namespace EMotionFX
|
||||
* This should always be equal to the number of morph targets in the highest detail.
|
||||
* @result The number of morph targets.
|
||||
*/
|
||||
MCORE_INLINE uint32 GetNumMorphTargets() const { return mMorphTargets.GetLength(); }
|
||||
MCORE_INLINE size_t GetNumMorphTargets() const { return mMorphTargets.size(); }
|
||||
|
||||
/**
|
||||
* Get a specific morph target.
|
||||
@@ -149,7 +149,7 @@ namespace EMotionFX
|
||||
MorphTarget* FindMorphTargetByID(uint32 id);
|
||||
|
||||
private:
|
||||
MCore::Array<MorphTarget> mMorphTargets; /**< The unique morph target information. */
|
||||
AZStd::vector<MorphTarget> mMorphTargets; /**< The unique morph target information. */
|
||||
|
||||
/**
|
||||
* The default constructor.
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Node.h"
|
||||
#include "MorphTarget.h"
|
||||
#include <MCore/Source/StringConversions.h>
|
||||
#include <MCore/Source/FastMath.h>
|
||||
#include <EMotionFX/Source/Allocators.h>
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -31,12 +32,6 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
|
||||
// destructor
|
||||
MorphTarget::~MorphTarget()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// convert the given phoneme name to a phoneme set
|
||||
MorphTarget::EPhonemeSet MorphTarget::FindPhonemeSet(const AZStd::string& phonemeName)
|
||||
{
|
||||
|
||||
@@ -286,10 +286,5 @@ namespace EMotionFX
|
||||
* @param name The unique name of the morph target.
|
||||
*/
|
||||
MorphTarget(const char* name);
|
||||
|
||||
/**
|
||||
* The destructor.
|
||||
*/
|
||||
virtual ~MorphTarget();
|
||||
};
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace EMotionFX
|
||||
const float normalizedWeight = CalcNormalizedWeight(newWeight); // convert in range of 0..1
|
||||
|
||||
// calculate the new transformations for all nodes of this morph target
|
||||
const uint32 numTransforms = mTransforms.GetLength();
|
||||
const uint32 numTransforms = mTransforms.size();
|
||||
for (uint32 i = 0; i < numTransforms; ++i)
|
||||
{
|
||||
// if this is the node that gets modified by this transform
|
||||
@@ -214,7 +214,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// check all transforms
|
||||
const uint32 numTransforms = mTransforms.GetLength();
|
||||
const uint32 numTransforms = mTransforms.size();
|
||||
for (uint32 i = 0; i < numTransforms; ++i)
|
||||
{
|
||||
if (mTransforms[i].mNodeIndex == nodeIndex)
|
||||
@@ -239,7 +239,7 @@ namespace EMotionFX
|
||||
Transform newTransform;
|
||||
|
||||
// calculate the new transformations for all nodes of this morph target
|
||||
const uint32 numTransforms = mTransforms.GetLength();
|
||||
const uint32 numTransforms = mTransforms.size();
|
||||
for (uint32 i = 0; i < numTransforms; ++i)
|
||||
{
|
||||
// try to find the node
|
||||
@@ -277,9 +277,9 @@ namespace EMotionFX
|
||||
}
|
||||
}
|
||||
|
||||
uint32 MorphTargetStandard::GetNumDeformDatas() const
|
||||
size_t MorphTargetStandard::GetNumDeformDatas() const
|
||||
{
|
||||
return static_cast<uint32>(mDeformDatas.size());
|
||||
return mDeformDatas.size();
|
||||
}
|
||||
|
||||
MorphTargetStandard::DeformData* MorphTargetStandard::GetDeformData(uint32 nr) const
|
||||
@@ -294,12 +294,13 @@ namespace EMotionFX
|
||||
|
||||
void MorphTargetStandard::AddTransformation(const Transformation& transform)
|
||||
{
|
||||
mTransforms.Add(transform);
|
||||
mTransforms.emplace_back(transform);
|
||||
}
|
||||
|
||||
uint32 MorphTargetStandard::GetNumTransformations() const
|
||||
// get the number of transformations in this morph target
|
||||
size_t MorphTargetStandard::GetNumTransformations() const
|
||||
{
|
||||
return mTransforms.GetLength();
|
||||
return mTransforms.size();
|
||||
}
|
||||
|
||||
MorphTargetStandard::Transformation& MorphTargetStandard::GetTransformation(uint32 nr)
|
||||
@@ -321,7 +322,7 @@ namespace EMotionFX
|
||||
|
||||
// now clone the deform datas
|
||||
clone->mDeformDatas.resize(mDeformDatas.size());
|
||||
for (size_t i = 0; i < mDeformDatas.size(); ++i)
|
||||
for (uint32 i = 0; i < mDeformDatas.size(); ++i)
|
||||
{
|
||||
clone->mDeformDatas[i] = mDeformDatas[i]->Clone();
|
||||
}
|
||||
@@ -404,7 +405,7 @@ namespace EMotionFX
|
||||
// pre-allocate memory for the transformations
|
||||
void MorphTargetStandard::ReserveTransformations(uint32 numTransforms)
|
||||
{
|
||||
mTransforms.Reserve(numTransforms);
|
||||
mTransforms.reserve(numTransforms);
|
||||
}
|
||||
|
||||
void MorphTargetStandard::RemoveDeformData(uint32 index, bool delFromMem)
|
||||
@@ -419,7 +420,7 @@ namespace EMotionFX
|
||||
|
||||
void MorphTargetStandard::RemoveTransformation(uint32 index)
|
||||
{
|
||||
mTransforms.Remove(index);
|
||||
mTransforms.erase(AZStd::next(begin(mTransforms), index));
|
||||
}
|
||||
|
||||
|
||||
@@ -433,7 +434,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// scale the transformations
|
||||
const uint32 numTransformations = mTransforms.GetLength();
|
||||
const uint32 numTransformations = mTransforms.size();
|
||||
for (uint32 i = 0; i < numTransformations; ++i)
|
||||
{
|
||||
Transformation& transform = mTransforms[i];
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace EMotionFX
|
||||
* Get the number of deform data objects.
|
||||
* @result The number of deform data objects.
|
||||
*/
|
||||
uint32 GetNumDeformDatas() const;
|
||||
size_t GetNumDeformDatas() const;
|
||||
|
||||
/**
|
||||
* Get a given deform data object.
|
||||
@@ -200,7 +200,7 @@ namespace EMotionFX
|
||||
* Get the number of transformations which are part of this bones morph target.
|
||||
* @result The number of tranformations.
|
||||
*/
|
||||
uint32 GetNumTransformations() const;
|
||||
size_t GetNumTransformations() const;
|
||||
|
||||
/**
|
||||
* Get a given transformation and it's corresponding node id to which the transformation belongs to.
|
||||
@@ -260,7 +260,7 @@ namespace EMotionFX
|
||||
void Scale(float scaleFactor) override;
|
||||
|
||||
private:
|
||||
MCore::Array<Transformation> mTransforms; /**< The relative transformations for the given nodes, in local space. The rotation however is absolute. */
|
||||
AZStd::vector<Transformation> mTransforms; /**< The relative transformations for the given nodes, in local space. The rotation however is absolute. */
|
||||
AZStd::vector<DeformData*> mDeformDatas; /**< The deformation data objects. */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,277 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
// include required headers
|
||||
#include "MotionGroup.h"
|
||||
#include "MotionInstance.h"
|
||||
#include "ActorInstance.h"
|
||||
#include "EMotionFXManager.h"
|
||||
#include "MotionInstancePool.h"
|
||||
#include "AnimGraphPose.h"
|
||||
#include <EMotionFX/Source/Allocators.h>
|
||||
|
||||
|
||||
namespace EMotionFX
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(MotionGroup, MotionAllocator, 0)
|
||||
|
||||
|
||||
// default constructor
|
||||
MotionGroup::MotionGroup()
|
||||
: BaseObject()
|
||||
{
|
||||
mParentMotionInstance = nullptr;
|
||||
}
|
||||
|
||||
|
||||
// extended constructor
|
||||
MotionGroup::MotionGroup(MotionInstance* parentMotionInstance)
|
||||
: BaseObject()
|
||||
{
|
||||
LinkToMotionInstance(parentMotionInstance);
|
||||
}
|
||||
|
||||
|
||||
// destructor
|
||||
MotionGroup::~MotionGroup()
|
||||
{
|
||||
RemoveAllMotionInstances();
|
||||
}
|
||||
|
||||
|
||||
// creation
|
||||
MotionGroup* MotionGroup::Create()
|
||||
{
|
||||
return aznew MotionGroup();
|
||||
}
|
||||
|
||||
|
||||
// creation
|
||||
MotionGroup* MotionGroup::Create(MotionInstance* parentMotionInstance)
|
||||
{
|
||||
return aznew MotionGroup(parentMotionInstance);
|
||||
}
|
||||
|
||||
|
||||
// link to a motion instance
|
||||
void MotionGroup::LinkToMotionInstance(MotionInstance* parentMotionInstance)
|
||||
{
|
||||
mParentMotionInstance = parentMotionInstance;
|
||||
}
|
||||
|
||||
|
||||
// add a motion to the group
|
||||
MotionInstance* MotionGroup::AddMotion(Motion* motion, PlayBackInfo* playInfo, uint32 startNodeIndex)
|
||||
{
|
||||
MCORE_ASSERT(mParentMotionInstance); // use LinkToMotionInstance before
|
||||
|
||||
// create the new motion instance
|
||||
MotionInstance* newInstance = GetMotionInstancePool().RequestNew(motion, mParentMotionInstance->GetActorInstance());
|
||||
|
||||
// initialize the motion instance settings
|
||||
if (playInfo == nullptr) // if no playinfo specified, use default playback settings
|
||||
{
|
||||
PlayBackInfo info;
|
||||
newInstance->InitFromPlayBackInfo(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
newInstance->InitFromPlayBackInfo(*playInfo);
|
||||
}
|
||||
|
||||
// add it to the motion instance array
|
||||
mMotionInstances.Add(newInstance);
|
||||
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
|
||||
// remove all motion instances from the group and from memory
|
||||
void MotionGroup::RemoveAllMotionInstances()
|
||||
{
|
||||
// remove all motion instances from memory
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
GetMotionInstancePool().Free(mMotionInstances[i]);
|
||||
}
|
||||
|
||||
mMotionInstances.Clear();
|
||||
}
|
||||
|
||||
|
||||
// remove a given motion by its motion instance
|
||||
void MotionGroup::RemoveMotionInstance(MotionInstance* instance)
|
||||
{
|
||||
if (mMotionInstances.RemoveByValue(instance))
|
||||
{
|
||||
GetMotionInstancePool().Free(instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove all motion instances using a given motion
|
||||
void MotionGroup::RemoveMotion(Motion* motion)
|
||||
{
|
||||
// for all the motion instances
|
||||
for (uint32 i = 0; i < mMotionInstances.GetLength();)
|
||||
{
|
||||
// if this motion instance uses the given motion
|
||||
if (mMotionInstances[i]->GetMotion() == motion)
|
||||
{
|
||||
// remove it from memory and from the array
|
||||
GetMotionInstancePool().Free(mMotionInstances[i]);
|
||||
mMotionInstances.Remove(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove a motion instance by its index
|
||||
void MotionGroup::RemoveMotionInstance(uint32 index)
|
||||
{
|
||||
MCORE_ASSERT(index < mMotionInstances.GetLength());
|
||||
|
||||
// remove it from memory and from the array
|
||||
GetMotionInstancePool().Free(mMotionInstances[index]);
|
||||
mMotionInstances.Remove(index);
|
||||
}
|
||||
|
||||
|
||||
// update the motion instances
|
||||
void MotionGroup::Update(float timePassed)
|
||||
{
|
||||
// update the motion instances
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
mMotionInstances[i]->Update(timePassed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// perform the blending and output it in the outPose buffer
|
||||
void MotionGroup::Output(const Pose* inPose, Pose* outPose)
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
// calculate the total weight
|
||||
float totalWeight = 0.0f;
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
for (i = 0; i < numInstances; ++i)
|
||||
{
|
||||
totalWeight += mMotionInstances[i]->GetWeight();
|
||||
}
|
||||
|
||||
// calculate the inverse of the total weight so that we can replace divides by multiplies, which is faster
|
||||
float invTotalWeight;
|
||||
if (totalWeight < 0.0001f)
|
||||
{
|
||||
invTotalWeight = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
invTotalWeight = 1.0f / totalWeight;
|
||||
}
|
||||
|
||||
const ActorInstance* actorInstance = inPose->GetActorInstance();
|
||||
const uint32 threadIndex = actorInstance->GetThreadIndex();
|
||||
AnimGraphPosePool& posePool = GetEMotionFX().GetThreadData(threadIndex)->GetPosePool();
|
||||
AnimGraphPose* groupAnimGraphPose = posePool.RequestPose(actorInstance);
|
||||
|
||||
// get the group blend pose and make sure it's big enough
|
||||
Pose* groupBlendPose = &groupAnimGraphPose->GetPose();//mParentMotionInstance->GetActorInstance()->GetActor()->GetGroupBlendPose();
|
||||
MCORE_ASSERT(groupBlendPose->GetNumTransforms() == inPose->GetNumTransforms());
|
||||
|
||||
// blend using the normalized weights
|
||||
for (i = 0; i < numInstances; ++i)
|
||||
{
|
||||
// calculate the normalized weight
|
||||
const float normalizedWeight = mMotionInstances[i]->GetWeight() * invTotalWeight;
|
||||
|
||||
// output the motion output into the group blend buffer
|
||||
mMotionInstances[i]->GetMotion()->Update(inPose, groupBlendPose, mMotionInstances[i]);
|
||||
|
||||
// if it's the first motion instance in the group
|
||||
if (i == 0)
|
||||
{
|
||||
// blend all transforms
|
||||
// TODO: use only enabled nodes
|
||||
const uint32 numTransforms = outPose->GetNumTransforms();
|
||||
for (uint32 t = 0; t < numTransforms; ++t)
|
||||
{
|
||||
Transform& transform = groupBlendPose->GetLocalSpaceTransformDirect(t);
|
||||
Transform& outTransform = outPose->GetLocalSpaceTransformDirect(t);
|
||||
transform.mRotation.Normalize();
|
||||
|
||||
EMFX_SCALECODE
|
||||
(
|
||||
//transform.mScaleRotation.Normalize();
|
||||
outTransform.mScale = transform.mScale * normalizedWeight;
|
||||
//outTransform.mScaleRotation = transform.mScaleRotation * normalizedWeight;
|
||||
)
|
||||
|
||||
outTransform.mPosition = transform.mPosition * normalizedWeight;
|
||||
outTransform.mRotation = transform.mRotation * normalizedWeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// blend all transforms
|
||||
// TODO: use only enabled nodes
|
||||
const uint32 numTransforms = outPose->GetNumTransforms();
|
||||
for (uint32 t = 0; t < numTransforms; ++t)
|
||||
{
|
||||
Transform& transform = groupBlendPose->GetLocalSpaceTransformDirect(t);
|
||||
Transform& outTransform = outPose->GetLocalSpaceTransformDirect(t);
|
||||
|
||||
outTransform.mPosition += transform.mPosition * normalizedWeight;
|
||||
|
||||
EMFX_SCALECODE
|
||||
(
|
||||
outTransform.mScale += transform.mScale * normalizedWeight;
|
||||
|
||||
// make sure we use the correct hemisphere
|
||||
//if (outTransform.mScaleRotation.Dot( transform.mScaleRotation ) < 0.0f)
|
||||
//transform.mScaleRotation = -transform.mScaleRotation;
|
||||
|
||||
//outTransform.mScaleRotation += transform.mScaleRotation * normalizedWeight;
|
||||
)
|
||||
|
||||
// make sure we use the correct hemisphere
|
||||
if (outTransform.mRotation.Dot(transform.mRotation) < 0.0f)
|
||||
{
|
||||
transform.mRotation = -transform.mRotation;
|
||||
}
|
||||
|
||||
outTransform.mRotation += transform.mRotation * normalizedWeight;
|
||||
}
|
||||
}
|
||||
} // for all motion instances in the group
|
||||
|
||||
// normalize the quaternions
|
||||
const uint32 numTransforms = outPose->GetNumTransforms();
|
||||
for (uint32 t = 0; t < numTransforms; ++t)
|
||||
{
|
||||
Transform& outTransform = outPose->GetLocalSpaceTransformDirect(t);
|
||||
outTransform.mRotation.Normalize();
|
||||
|
||||
//EMFX_SCALECODE
|
||||
//(
|
||||
//outTransform.mScaleRotation.Normalize();
|
||||
//)
|
||||
}
|
||||
|
||||
// free the pose
|
||||
posePool.FreePose(groupAnimGraphPose);
|
||||
}
|
||||
} // namespace EMotionFX
|
||||
@@ -819,7 +819,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// calculate a world space transformation for a given node by sampling the motion at a given time
|
||||
void MotionInstance::CalcGlobalTransform(const MCore::Array<AZ::u32>& hierarchyPath, float timeValue, Transform* outTransform) const
|
||||
void MotionInstance::CalcGlobalTransform(const AZStd::vector<AZ::u32>& hierarchyPath, float timeValue, Transform* outTransform) const
|
||||
{
|
||||
Actor* actor = m_actorInstance->GetActor();
|
||||
Skeleton* skeleton = actor->GetSkeleton();
|
||||
@@ -829,7 +829,7 @@ namespace EMotionFX
|
||||
outTransform->Identity();
|
||||
|
||||
// iterate from root towards the node (so backwards in the array)
|
||||
for (int32 i = hierarchyPath.GetLength() - 1; i >= 0; --i)
|
||||
for (int32 i = hierarchyPath.size() - 1; i >= 0; --i)
|
||||
{
|
||||
// get the current node index
|
||||
const AZ::u32 nodeIndex = hierarchyPath[i];
|
||||
|
||||
@@ -821,7 +821,7 @@ namespace EMotionFX
|
||||
|
||||
void CalcRelativeTransform(Node* rootNode, float curTime, float oldTime, Transform* outTransform) const;
|
||||
bool ExtractMotion(Transform& outTrajectoryDelta);
|
||||
void CalcGlobalTransform(const MCore::Array<AZ::u32>& hierarchyPath, float timeValue, Transform* outTransform) const;
|
||||
void CalcGlobalTransform(const AZStd::vector<AZ::u32>& hierarchyPath, float timeValue, Transform* outTransform) const;
|
||||
void ResetTimes();
|
||||
|
||||
AZ_DEPRECATED(void CalcNewTimeAfterUpdate(float timePassed, float* outNewTime) const, "MotionInstance::CalcNewTimeAfterUpdate has been deprecated, please use MotionInstance::CalcPlayStateAfterUpdate(timeDelta).m_currentTime instead.");
|
||||
|
||||
@@ -42,8 +42,6 @@ namespace EMotionFX
|
||||
// constructor
|
||||
MotionInstancePool::Pool::Pool()
|
||||
{
|
||||
mFreeList.SetMemoryCategory(EMFX_MEMCATEGORY_MOTIONINSTANCEPOOL);
|
||||
mSubPools.SetMemoryCategory(EMFX_MEMCATEGORY_MOTIONINSTANCEPOOL);
|
||||
mPoolType = POOLTYPE_DYNAMIC;
|
||||
mData = nullptr;
|
||||
mNumInstances = 0;
|
||||
@@ -59,7 +57,7 @@ namespace EMotionFX
|
||||
{
|
||||
MCore::Free(mData);
|
||||
mData = nullptr;
|
||||
mFreeList.Clear();
|
||||
mFreeList.clear();
|
||||
}
|
||||
else
|
||||
if (mPoolType == POOLTYPE_DYNAMIC)
|
||||
@@ -67,14 +65,14 @@ namespace EMotionFX
|
||||
MCORE_ASSERT(mData == nullptr);
|
||||
|
||||
// delete all subpools
|
||||
const uint32 numSubPools = mSubPools.GetLength();
|
||||
const uint32 numSubPools = mSubPools.size();
|
||||
for (uint32 s = 0; s < numSubPools; ++s)
|
||||
{
|
||||
delete mSubPools[s];
|
||||
}
|
||||
mSubPools.Clear();
|
||||
mSubPools.clear();
|
||||
|
||||
mFreeList.Clear();
|
||||
mFreeList.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,7 +140,7 @@ namespace EMotionFX
|
||||
if (poolType == POOLTYPE_STATIC)
|
||||
{
|
||||
mPool->mData = (uint8*)MCore::Allocate(numInitialInstances * sizeof(MotionInstance), EMFX_MEMCATEGORY_MOTIONINSTANCEPOOL);// alloc space
|
||||
mPool->mFreeList.ResizeFast(numInitialInstances);
|
||||
mPool->mFreeList.resize_no_construct(numInitialInstances);
|
||||
for (uint32 i = 0; i < numInitialInstances; ++i)
|
||||
{
|
||||
void* memLocation = (void*)(mPool->mData + i * sizeof(MotionInstance));
|
||||
@@ -153,20 +151,20 @@ namespace EMotionFX
|
||||
else // if we have a dynamic pool
|
||||
if (poolType == POOLTYPE_DYNAMIC)
|
||||
{
|
||||
mPool->mSubPools.Reserve(32);
|
||||
mPool->mSubPools.reserve(32);
|
||||
|
||||
SubPool* subPool = new SubPool();
|
||||
subPool->mData = (uint8*)MCore::Allocate(numInitialInstances * sizeof(MotionInstance), EMFX_MEMCATEGORY_MOTIONINSTANCEPOOL);// alloc space
|
||||
subPool->mNumInstances = numInitialInstances;
|
||||
|
||||
mPool->mFreeList.ResizeFast(numInitialInstances);
|
||||
mPool->mFreeList.resize_no_construct(numInitialInstances);
|
||||
for (uint32 i = 0; i < numInitialInstances; ++i)
|
||||
{
|
||||
mPool->mFreeList[i].mAddress = (void*)(subPool->mData + i * sizeof(MotionInstance));
|
||||
mPool->mFreeList[i].mSubPool = subPool;
|
||||
}
|
||||
|
||||
mPool->mSubPools.Add(subPool);
|
||||
mPool->mSubPools.emplace_back(subPool);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -186,9 +184,9 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// if there is are free items left
|
||||
if (mPool->mFreeList.GetLength() > 0)
|
||||
if (mPool->mFreeList.size() > 0)
|
||||
{
|
||||
const MemLocation& location = mPool->mFreeList.GetLast();
|
||||
const MemLocation& location = mPool->mFreeList.back();
|
||||
MotionInstance* result = MotionInstance::Create(location.mAddress, motion, actorInstance);
|
||||
|
||||
if (location.mSubPool)
|
||||
@@ -197,7 +195,7 @@ namespace EMotionFX
|
||||
}
|
||||
result->SetSubPool(location.mSubPool);
|
||||
|
||||
mPool->mFreeList.RemoveLast(); // remove it from the free list
|
||||
mPool->mFreeList.pop_back(); // remove it from the free list
|
||||
mPool->mNumUsedInstances++;
|
||||
return result;
|
||||
}
|
||||
@@ -212,14 +210,14 @@ namespace EMotionFX
|
||||
subPool->mData = (uint8*)MCore::Allocate(numInstances * sizeof(MotionInstance), EMFX_MEMCATEGORY_MOTIONINSTANCEPOOL);// alloc space
|
||||
subPool->mNumInstances = numInstances;
|
||||
|
||||
const uint32 startIndex = mPool->mFreeList.GetLength();
|
||||
const uint32 startIndex = mPool->mFreeList.size();
|
||||
//mPool->mFreeList.Reserve( numInstances * 2 );
|
||||
if (mPool->mFreeList.GetMaxLength() < mPool->mNumInstances)
|
||||
if (mPool->mFreeList.capacity() < mPool->mNumInstances)
|
||||
{
|
||||
mPool->mFreeList.Reserve(mPool->mNumInstances + mPool->mFreeList.GetMaxLength() / 2);
|
||||
mPool->mFreeList.reserve(mPool->mNumInstances + mPool->mFreeList.capacity() / 2);
|
||||
}
|
||||
|
||||
mPool->mFreeList.ResizeFast(startIndex + numInstances);
|
||||
mPool->mFreeList.resize_no_construct(startIndex + numInstances);
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
void* memAddress = (void*)(subPool->mData + i * sizeof(MotionInstance));
|
||||
@@ -227,16 +225,16 @@ namespace EMotionFX
|
||||
mPool->mFreeList[i + startIndex].mSubPool = subPool;
|
||||
}
|
||||
|
||||
mPool->mSubPools.Add(subPool);
|
||||
mPool->mSubPools.emplace_back(subPool);
|
||||
|
||||
const MemLocation& location = mPool->mFreeList.GetLast();
|
||||
const MemLocation& location = mPool->mFreeList.back();
|
||||
MotionInstance* result = MotionInstance::Create(location.mAddress, motion, actorInstance);
|
||||
if (location.mSubPool)
|
||||
{
|
||||
location.mSubPool->mNumInUse++;
|
||||
}
|
||||
result->SetSubPool(location.mSubPool);
|
||||
mPool->mFreeList.RemoveLast(); // remove it from the free list
|
||||
mPool->mFreeList.pop_back(); // remove it from the free list
|
||||
mPool->mNumUsedInstances++;
|
||||
return result;
|
||||
}
|
||||
@@ -276,9 +274,9 @@ namespace EMotionFX
|
||||
motionInstance->GetSubPool()->mNumInUse--;
|
||||
}
|
||||
|
||||
mPool->mFreeList.AddEmpty();
|
||||
mPool->mFreeList.GetLast().mAddress = motionInstance;
|
||||
mPool->mFreeList.GetLast().mSubPool = motionInstance->GetSubPool();
|
||||
mPool->mFreeList.emplace_back();
|
||||
mPool->mFreeList.back().mAddress = motionInstance;
|
||||
mPool->mFreeList.back().mSubPool = motionInstance->GetSubPool();
|
||||
mPool->mNumUsedInstances--;
|
||||
|
||||
motionInstance->DecreaseReferenceCount();
|
||||
@@ -292,7 +290,7 @@ namespace EMotionFX
|
||||
Lock();
|
||||
MCore::LogInfo("EMotionFX::MotionInstancePool::LogMemoryStats() - Logging motion instance pool info");
|
||||
|
||||
const uint32 numFree = mPool->mFreeList.GetLength();
|
||||
const uint32 numFree = mPool->mFreeList.size();
|
||||
uint32 numUsed = mPool->mNumUsedInstances;
|
||||
uint32 memUsage = 0;
|
||||
uint32 usedMemUsage = 0;
|
||||
@@ -320,12 +318,12 @@ namespace EMotionFX
|
||||
totalUsedInstancesMemUsage += usedMemUsage;
|
||||
totalMemUsage += memUsage;
|
||||
totalMemUsage += sizeof(Pool);
|
||||
totalMemUsage += mPool->mFreeList.CalcMemoryUsage(false);
|
||||
totalMemUsage += mPool->mFreeList.capacity() * sizeof(decltype(mPool->mFreeList)::value_type);
|
||||
|
||||
MCore::LogInfo("Pool:");
|
||||
if (mPool->mPoolType == POOLTYPE_DYNAMIC)
|
||||
{
|
||||
MCore::LogInfo(" - Num SubPools: %d", mPool->mSubPools.GetLength());
|
||||
MCore::LogInfo(" - Num SubPools: %d", mPool->mSubPools.size());
|
||||
}
|
||||
MCore::LogInfo(" - Num Instances: %d", mPool->mNumInstances);
|
||||
MCore::LogInfo(" - Num Free: %d", numFree);
|
||||
@@ -377,17 +375,17 @@ namespace EMotionFX
|
||||
{
|
||||
Lock();
|
||||
|
||||
for (uint32 i = 0; i < mPool->mSubPools.GetLength(); )
|
||||
for (uint32 i = 0; i < mPool->mSubPools.size(); )
|
||||
{
|
||||
SubPool* subPool = mPool->mSubPools[i];
|
||||
if (subPool->mNumInUse == 0)
|
||||
{
|
||||
// remove all free allocations
|
||||
for (uint32 a = 0; a < mPool->mFreeList.GetLength(); )
|
||||
for (uint32 a = 0; a < mPool->mFreeList.size(); )
|
||||
{
|
||||
if (mPool->mFreeList[a].mSubPool == subPool)
|
||||
{
|
||||
mPool->mFreeList.Remove(a);
|
||||
mPool->mFreeList.erase(AZStd::next(begin(mPool->mFreeList), a));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -396,7 +394,7 @@ namespace EMotionFX
|
||||
}
|
||||
mPool->mNumInstances -= subPool->mNumInstances;
|
||||
|
||||
mPool->mSubPools.Remove(i);
|
||||
mPool->mSubPools.erase(AZStd::next(begin(mPool->mSubPools), i));
|
||||
delete subPool;
|
||||
}
|
||||
else
|
||||
@@ -405,11 +403,11 @@ namespace EMotionFX
|
||||
}
|
||||
}
|
||||
|
||||
mPool->mSubPools.Shrink();
|
||||
mPool->mSubPools.shrink_to_fit();
|
||||
//mPool->mFreeList.Shrink();
|
||||
if ((mPool->mFreeList.GetMaxLength() - mPool->mFreeList.GetLength()) > 4096)
|
||||
if ((mPool->mFreeList.capacity() - mPool->mFreeList.size()) > 4096)
|
||||
{
|
||||
mPool->mFreeList.ReserveExact(mPool->mFreeList.GetLength() + 4096);
|
||||
mPool->mFreeList.reserve(mPool->mFreeList.size() + 4096);
|
||||
}
|
||||
|
||||
Unlock();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// include the required headers
|
||||
#include "EMotionFXConfig.h"
|
||||
#include "BaseObject.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/MultiThreadManager.h>
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ namespace EMotionFX
|
||||
uint32 mNumInstances;
|
||||
uint32 mNumUsedInstances;
|
||||
uint32 mSubPoolSize;
|
||||
MCore::Array<MemLocation> mFreeList;
|
||||
MCore::Array<SubPool*> mSubPools;
|
||||
AZStd::vector<MemLocation> mFreeList;
|
||||
AZStd::vector<SubPool*> mSubPools;
|
||||
EPoolType mPoolType;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ namespace EMotionFX
|
||||
MotionLayerSystem::MotionLayerSystem(ActorInstance* actorInstance)
|
||||
: MotionSystem(actorInstance)
|
||||
{
|
||||
mLayerPasses.SetMemoryCategory(EMFX_MEMCATEGORY_MOTIONS_MOTIONSYSTEMS);
|
||||
|
||||
// set the motion based actor repositioning layer pass
|
||||
mRepositioningPass = RepositioningLayerPass::Create(this);
|
||||
}
|
||||
@@ -50,7 +48,7 @@ namespace EMotionFX
|
||||
void MotionLayerSystem::RemoveAllLayerPasses(bool delFromMem)
|
||||
{
|
||||
// delete all layer passes
|
||||
const uint32 numLayerPasses = mLayerPasses.GetLength();
|
||||
const uint32 numLayerPasses = mLayerPasses.size();
|
||||
for (uint32 i = 0; i < numLayerPasses; ++i)
|
||||
{
|
||||
if (delFromMem)
|
||||
@@ -59,7 +57,7 @@ namespace EMotionFX
|
||||
}
|
||||
}
|
||||
|
||||
mLayerPasses.Clear();
|
||||
mLayerPasses.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,23 +65,23 @@ namespace EMotionFX
|
||||
void MotionLayerSystem::StartMotion(MotionInstance* motion, PlayBackInfo* info)
|
||||
{
|
||||
// check if we have any motions playing already
|
||||
const uint32 numMotionInstances = mMotionInstances.GetLength();
|
||||
const uint32 numMotionInstances = mMotionInstances.size();
|
||||
if (numMotionInstances > 0)
|
||||
{
|
||||
// find the right location in the motion instance array to insert this motion instance
|
||||
uint32 insertPos = FindInsertPos(motion->GetPriorityLevel());
|
||||
if (insertPos != MCORE_INVALIDINDEX32)
|
||||
{
|
||||
mMotionInstances.Insert(insertPos, motion);
|
||||
mMotionInstances.emplace(AZStd::next(begin(mMotionInstances), insertPos), motion);
|
||||
}
|
||||
else
|
||||
{
|
||||
mMotionInstances.Add(motion);
|
||||
mMotionInstances.emplace_back(motion);
|
||||
}
|
||||
}
|
||||
else // no motions are playing, so just add it
|
||||
{
|
||||
mMotionInstances.Add(motion);
|
||||
mMotionInstances.emplace_back(motion);
|
||||
}
|
||||
|
||||
// trigger an event
|
||||
@@ -101,7 +99,7 @@ namespace EMotionFX
|
||||
// find the location where to insert a new motion with a given priority
|
||||
uint32 MotionLayerSystem::FindInsertPos(uint32 priorityLevel) const
|
||||
{
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
const uint32 numInstances = mMotionInstances.size();
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
if (mMotionInstances[i]->GetPriorityLevel() <= priorityLevel)
|
||||
@@ -127,7 +125,7 @@ namespace EMotionFX
|
||||
mMotionQueue->Update();
|
||||
|
||||
// process all layer passes
|
||||
const uint32 numPasses = mLayerPasses.GetLength();
|
||||
const uint32 numPasses = mLayerPasses.size();
|
||||
for (uint32 i = 0; i < numPasses; ++i)
|
||||
{
|
||||
mLayerPasses[i]->Process();
|
||||
@@ -153,7 +151,7 @@ namespace EMotionFX
|
||||
// update the motion tree
|
||||
void MotionLayerSystem::UpdateMotionTree()
|
||||
{
|
||||
for (uint32 i = 0; i < mMotionInstances.GetLength(); ++i)
|
||||
for (uint32 i = 0; i < mMotionInstances.size(); ++i)
|
||||
{
|
||||
MotionInstance* source = mMotionInstances[i];
|
||||
|
||||
@@ -235,7 +233,7 @@ namespace EMotionFX
|
||||
if (source->GetCanOverwrite())
|
||||
{
|
||||
// remove all motions that got overwritten by the current one
|
||||
const uint32 numToRemove = mMotionInstances.GetLength() - (i + 1);
|
||||
const uint32 numToRemove = mMotionInstances.size() - (i + 1);
|
||||
for (uint32 a = 0; a < numToRemove; ++a)
|
||||
{
|
||||
RemoveMotionInstance(mMotionInstances[i + 1]);
|
||||
@@ -253,7 +251,7 @@ namespace EMotionFX
|
||||
uint32 numRemoved = 0;
|
||||
|
||||
// start from the bottom up
|
||||
for (uint32 i = mMotionInstances.GetLength() - 1; i != MCORE_INVALIDINDEX32;)
|
||||
for (uint32 i = mMotionInstances.size() - 1; i != MCORE_INVALIDINDEX32;)
|
||||
{
|
||||
MotionInstance* curInstance = mMotionInstances[i];
|
||||
|
||||
@@ -276,7 +274,7 @@ namespace EMotionFX
|
||||
MotionInstance* MotionLayerSystem::FindFirstNonMixingMotionInstance() const
|
||||
{
|
||||
// if there aren't any motion instances, return nullptr
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
const uint32 numInstances = mMotionInstances.size();
|
||||
if (numInstances == 0)
|
||||
{
|
||||
return nullptr;
|
||||
@@ -306,7 +304,7 @@ namespace EMotionFX
|
||||
|
||||
Pose* tempActorPose = &tempAnimGraphPose->GetPose();
|
||||
|
||||
const uint32 numMotionInstances = mMotionInstances.GetLength();
|
||||
const uint32 numMotionInstances = mMotionInstances.size();
|
||||
if (numMotionInstances > 0)
|
||||
{
|
||||
if (numMotionInstances > 1)
|
||||
@@ -396,14 +394,14 @@ namespace EMotionFX
|
||||
// add a new pass
|
||||
void MotionLayerSystem::AddLayerPass(LayerPass* newPass)
|
||||
{
|
||||
mLayerPasses.Add(newPass);
|
||||
mLayerPasses.emplace_back(newPass);
|
||||
}
|
||||
|
||||
|
||||
// get the number of layer passes
|
||||
uint32 MotionLayerSystem::GetNumLayerPasses() const
|
||||
size_t MotionLayerSystem::GetNumLayerPasses() const
|
||||
{
|
||||
return mLayerPasses.GetLength();
|
||||
return mLayerPasses.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -415,14 +413,17 @@ namespace EMotionFX
|
||||
mLayerPasses[nr]->Destroy();
|
||||
}
|
||||
|
||||
mLayerPasses.Remove(nr);
|
||||
mLayerPasses.erase(AZStd::next(begin(mLayerPasses), nr));
|
||||
}
|
||||
|
||||
|
||||
// remove a given pass
|
||||
void MotionLayerSystem::RemoveLayerPass(LayerPass* pass, bool delFromMem)
|
||||
{
|
||||
mLayerPasses.RemoveByValue(pass);
|
||||
if (const auto it = AZStd::find(begin(mLayerPasses), end(mLayerPasses), pass); it != end(mLayerPasses))
|
||||
{
|
||||
mLayerPasses.erase(it);
|
||||
}
|
||||
|
||||
if (delFromMem)
|
||||
{
|
||||
@@ -434,7 +435,7 @@ namespace EMotionFX
|
||||
// insert a layer pass at a given position
|
||||
void MotionLayerSystem::InsertLayerPass(uint32 insertPos, LayerPass* pass)
|
||||
{
|
||||
mLayerPasses.Insert(insertPos, pass);
|
||||
mLayerPasses.emplace(AZStd::next(begin(mLayerPasses), insertPos), pass);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace EMotionFX
|
||||
* Get the number of layer passes currently added to this motion layer system.
|
||||
* @result The number of layer passes.
|
||||
*/
|
||||
uint32 GetNumLayerPasses() const;
|
||||
size_t GetNumLayerPasses() const;
|
||||
|
||||
/**
|
||||
* Remove a given layer pass by index.
|
||||
@@ -179,7 +179,7 @@ namespace EMotionFX
|
||||
|
||||
|
||||
private:
|
||||
MCore::Array<LayerPass*> mLayerPasses; /**< The layer passes. */
|
||||
AZStd::vector<LayerPass*> mLayerPasses; /**< The layer passes. */
|
||||
RepositioningLayerPass* mRepositioningPass; /**< The motion based actor repositioning layer pass. */
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <EMotionFX/Source/MotionSet.h>
|
||||
#include <EMotionFX/Source/MotionSystem.h>
|
||||
#include <EMotionFX/Source/MotionData/MotionDataFactory.h>
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/MultiThreadManager.h>
|
||||
|
||||
|
||||
@@ -42,11 +42,8 @@ namespace EMotionFX
|
||||
MotionManager::MotionManager()
|
||||
: BaseObject()
|
||||
{
|
||||
mMotions.SetMemoryCategory(EMFX_MEMCATEGORY_MOTIONS_MOTIONMANAGER);
|
||||
mMotionSets.SetMemoryCategory(EMFX_MEMCATEGORY_MOTIONS_MOTIONMANAGER);
|
||||
|
||||
// reserve space for 400 motions
|
||||
mMotions.Reserve(400);
|
||||
mMotions.reserve(400);
|
||||
|
||||
m_motionDataFactory = aznew MotionDataFactory();
|
||||
}
|
||||
@@ -69,13 +66,13 @@ namespace EMotionFX
|
||||
if (delFromMemory)
|
||||
{
|
||||
// destroy all motion sets, they will internally call RemoveMotionSetWithoutLock(this) in their destructor
|
||||
while (mMotionSets.GetLength() > 0)
|
||||
while (mMotionSets.size() > 0)
|
||||
{
|
||||
delete mMotionSets[0];
|
||||
}
|
||||
|
||||
// destroy all motions, they will internally call RemoveMotionWithoutLock(this) in their destructor
|
||||
while (mMotions.GetLength() > 0)
|
||||
while (mMotions.size() > 0)
|
||||
{
|
||||
mMotions[0]->Destroy();
|
||||
}
|
||||
@@ -84,12 +81,12 @@ namespace EMotionFX
|
||||
{
|
||||
// wait with execution until we can set the lock
|
||||
mSetLock.Lock();
|
||||
mMotionSets.Clear();
|
||||
mMotionSets.clear();
|
||||
mSetLock.Unlock();
|
||||
|
||||
// clear the arrays without destroying the memory of the entries
|
||||
mLock.Lock();
|
||||
mMotions.Clear();
|
||||
mMotions.clear();
|
||||
mLock.Unlock();
|
||||
}
|
||||
}
|
||||
@@ -99,7 +96,7 @@ namespace EMotionFX
|
||||
Motion* MotionManager::FindMotionByName(const char* motionName, bool isTool) const
|
||||
{
|
||||
// get the number of motions and iterate through them
|
||||
const uint32 numMotions = mMotions.GetLength();
|
||||
const uint32 numMotions = mMotions.size();
|
||||
for (uint32 i = 0; i < numMotions; ++i)
|
||||
{
|
||||
if (mMotions[i]->GetIsOwnedByRuntime() == isTool)
|
||||
@@ -122,7 +119,7 @@ namespace EMotionFX
|
||||
Motion* MotionManager::FindMotionByFileName(const char* fileName, bool isTool) const
|
||||
{
|
||||
// get the number of motions and iterate through them
|
||||
const uint32 numMotions = mMotions.GetLength();
|
||||
const uint32 numMotions = mMotions.size();
|
||||
for (uint32 i = 0; i < numMotions; ++i)
|
||||
{
|
||||
if (mMotions[i]->GetIsOwnedByRuntime() == isTool)
|
||||
@@ -145,7 +142,7 @@ namespace EMotionFX
|
||||
MotionSet* MotionManager::FindMotionSetByFileName(const char* fileName, bool isTool) const
|
||||
{
|
||||
// get the number of motion sets and iterate through them
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (uint32 i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
MotionSet* motionSet = mMotionSets[i];
|
||||
@@ -169,7 +166,7 @@ namespace EMotionFX
|
||||
MotionSet* MotionManager::FindMotionSetByName(const char* name, bool isOwnedByRuntime) const
|
||||
{
|
||||
// get the number of motion sets and iterate through them
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (uint32 i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
MotionSet* motionSet = mMotionSets[i];
|
||||
@@ -192,7 +189,7 @@ namespace EMotionFX
|
||||
uint32 MotionManager::FindMotionIndexByName(const char* motionName, bool isTool) const
|
||||
{
|
||||
// get the number of motions and iterate through them
|
||||
const uint32 numMotions = mMotions.GetLength();
|
||||
const uint32 numMotions = mMotions.size();
|
||||
for (uint32 i = 0; i < numMotions; ++i)
|
||||
{
|
||||
if (mMotions[i]->GetIsOwnedByRuntime() == isTool)
|
||||
@@ -215,7 +212,7 @@ namespace EMotionFX
|
||||
uint32 MotionManager::FindMotionSetIndexByName(const char* name, bool isTool) const
|
||||
{
|
||||
// get the number of motions and iterate through them
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (uint32 i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
MotionSet* motionSet = mMotionSets[i];
|
||||
@@ -240,7 +237,7 @@ namespace EMotionFX
|
||||
uint32 MotionManager::FindMotionIndexByID(uint32 id) const
|
||||
{
|
||||
// get the number of motions and iterate through them
|
||||
const uint32 numMotions = mMotions.GetLength();
|
||||
const uint32 numMotions = mMotions.size();
|
||||
for (uint32 i = 0; i < numMotions; ++i)
|
||||
{
|
||||
if (mMotions[i]->GetID() == id)
|
||||
@@ -257,7 +254,7 @@ namespace EMotionFX
|
||||
uint32 MotionManager::FindMotionSetIndexByID(uint32 id) const
|
||||
{
|
||||
// get the number of motion sets and iterate through them
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (uint32 i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
// compare the motion names
|
||||
@@ -275,7 +272,7 @@ namespace EMotionFX
|
||||
Motion* MotionManager::FindMotionByID(uint32 id) const
|
||||
{
|
||||
// get the number of motions and iterate through them
|
||||
const uint32 numMotions = mMotions.GetLength();
|
||||
const uint32 numMotions = mMotions.size();
|
||||
for (uint32 i = 0; i < numMotions; ++i)
|
||||
{
|
||||
if (mMotions[i]->GetID() == id)
|
||||
@@ -292,7 +289,7 @@ namespace EMotionFX
|
||||
MotionSet* MotionManager::FindMotionSetByID(uint32 id) const
|
||||
{
|
||||
// get the number of motion sets and iterate through them
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (uint32 i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
if (mMotionSets[i]->GetID() == id)
|
||||
@@ -309,7 +306,7 @@ namespace EMotionFX
|
||||
uint32 MotionManager::FindMotionSetIndex(MotionSet* motionSet) const
|
||||
{
|
||||
// get the number of motion sets and iterate through them
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (uint32 i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
if (mMotionSets[i] == motionSet)
|
||||
@@ -326,7 +323,7 @@ namespace EMotionFX
|
||||
uint32 MotionManager::FindMotionIndex(Motion* motion) const
|
||||
{
|
||||
// get the number of motions and iterate through them
|
||||
const uint32 numMotions = mMotions.GetLength();
|
||||
const uint32 numMotions = mMotions.size();
|
||||
for (uint32 i = 0; i < numMotions; ++i)
|
||||
{
|
||||
// compare the motions
|
||||
@@ -345,7 +342,7 @@ namespace EMotionFX
|
||||
{
|
||||
// wait with execution until we can set the lock
|
||||
mLock.Lock();
|
||||
mMotions.Add(motion);
|
||||
mMotions.emplace_back(motion);
|
||||
mLock.Unlock();
|
||||
}
|
||||
|
||||
@@ -386,7 +383,7 @@ namespace EMotionFX
|
||||
uint32 MotionManager::FindMotionIndexByFileName(const char* fileName, bool isTool) const
|
||||
{
|
||||
// get the number of motions and iterate through them
|
||||
const uint32 numMotions = mMotions.GetLength();
|
||||
const uint32 numMotions = mMotions.size();
|
||||
for (uint32 i = 0; i < numMotions; ++i)
|
||||
{
|
||||
if (mMotions[i]->GetIsOwnedByRuntime() == isTool)
|
||||
@@ -494,7 +491,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// Reset all motion entries in the motion sets of the current motion.
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
MotionSet* motionSet = mMotionSets[i];
|
||||
@@ -525,11 +522,11 @@ namespace EMotionFX
|
||||
// which unregisters the motion from the motion manager
|
||||
motion->SetAutoUnregister(false);
|
||||
motion->Destroy();
|
||||
mMotions.Remove(index); // only remove the motion from the motion manager without destroying its memory
|
||||
mMotions.erase(AZStd::next(begin(mMotions), index)); // only remove the motion from the motion manager without destroying its memory
|
||||
}
|
||||
else
|
||||
{
|
||||
mMotions.Remove(index); // only remove the motion from the motion manager without destroying its memory
|
||||
mMotions.erase(AZStd::next(begin(mMotions), index)); // only remove the motion from the motion manager without destroying its memory
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -540,7 +537,7 @@ namespace EMotionFX
|
||||
void MotionManager::AddMotionSet(MotionSet* motionSet)
|
||||
{
|
||||
MCore::LockGuard lock(mLock);
|
||||
mMotionSets.Add(motionSet);
|
||||
mMotionSets.emplace_back(motionSet);
|
||||
}
|
||||
|
||||
|
||||
@@ -578,7 +575,7 @@ namespace EMotionFX
|
||||
delete motionSet;
|
||||
}
|
||||
|
||||
mMotionSets.Remove(index);
|
||||
mMotionSets.erase(AZStd::next(begin(mMotionSets), index));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -606,7 +603,7 @@ namespace EMotionFX
|
||||
uint32 result = 0;
|
||||
|
||||
// get the number of motion sets and iterate through them
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (uint32 i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
// sum up the root motion sets
|
||||
@@ -626,7 +623,7 @@ namespace EMotionFX
|
||||
uint32 currentIndex = 0;
|
||||
|
||||
// get the number of motion sets and iterate through them
|
||||
const uint32 numMotionSets = mMotionSets.GetLength();
|
||||
const uint32 numMotionSets = mMotionSets.size();
|
||||
for (uint32 i = 0; i < numMotionSets; ++i)
|
||||
{
|
||||
// get the current motion set
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/Config.h>
|
||||
#include <MCore/Source/MultiThreadManager.h>
|
||||
#include <EMotionFX/Source/BaseObject.h>
|
||||
@@ -50,7 +50,7 @@ namespace EMotionFX
|
||||
* Get the number of motions in the motion manager.
|
||||
* @return The number of registered motions.
|
||||
*/
|
||||
MCORE_INLINE uint32 GetNumMotions() const { return mMotions.GetLength(); }
|
||||
MCORE_INLINE size_t GetNumMotions() const { return mMotions.size(); }
|
||||
|
||||
/**
|
||||
* Remove the motion with the given name from the motion manager.
|
||||
@@ -160,7 +160,7 @@ namespace EMotionFX
|
||||
* Get the number of motion sets in the motion manager.
|
||||
* @return The number of registered motion sets.
|
||||
*/
|
||||
MCORE_INLINE uint32 GetNumMotionSets() const { return mMotionSets.GetLength(); }
|
||||
MCORE_INLINE size_t GetNumMotionSets() const { return mMotionSets.size(); }
|
||||
|
||||
/**
|
||||
* Calculate the number of root motion sets.
|
||||
@@ -233,8 +233,8 @@ namespace EMotionFX
|
||||
const MotionDataFactory& GetMotionDataFactory() const;
|
||||
|
||||
private:
|
||||
MCore::Array<Motion*> mMotions; /**< The array of motions. */
|
||||
MCore::Array<MotionSet*> mMotionSets; /**< The array of motion sets. */
|
||||
AZStd::vector<Motion*> mMotions; /**< The array of motions. */
|
||||
AZStd::vector<MotionSet*> mMotionSets; /**< The array of motion sets. */
|
||||
MCore::Mutex mLock; /**< Motion lock. */
|
||||
MCore::Mutex mSetLock; /**< The motion set multithread lock. */
|
||||
MotionDataFactory* m_motionDataFactory = nullptr; /**< The motion data factory. */
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace EMotionFX
|
||||
{
|
||||
MCORE_ASSERT(actorInstance && motionSystem);
|
||||
|
||||
mEntries.SetMemoryCategory(EMFX_MEMCATEGORY_MOTIONS_MISC);
|
||||
mActorInstance = actorInstance;
|
||||
mMotionSystem = motionSystem;
|
||||
}
|
||||
@@ -54,7 +53,7 @@ namespace EMotionFX
|
||||
GetMotionInstancePool().Free(mEntries[nr].mMotion);
|
||||
}
|
||||
|
||||
mEntries.Remove(nr);
|
||||
mEntries.erase(AZStd::next(begin(mEntries), nr));
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +167,7 @@ namespace EMotionFX
|
||||
|
||||
void MotionQueue::ClearAllEntries()
|
||||
{
|
||||
while (mEntries.GetLength())
|
||||
while (mEntries.size())
|
||||
{
|
||||
RemoveEntry(0);
|
||||
}
|
||||
@@ -177,26 +176,26 @@ namespace EMotionFX
|
||||
|
||||
void MotionQueue::AddEntry(const MotionQueue::QueueEntry& motion)
|
||||
{
|
||||
mEntries.Add(motion);
|
||||
mEntries.emplace_back(motion);
|
||||
}
|
||||
|
||||
|
||||
uint32 MotionQueue::GetNumEntries() const
|
||||
size_t MotionQueue::GetNumEntries() const
|
||||
{
|
||||
return mEntries.GetLength();
|
||||
return mEntries.size();
|
||||
}
|
||||
|
||||
|
||||
MotionQueue::QueueEntry& MotionQueue::GetFirstEntry()
|
||||
{
|
||||
MCORE_ASSERT(mEntries.GetLength() > 0);
|
||||
MCORE_ASSERT(mEntries.size() > 0);
|
||||
return mEntries[0];
|
||||
}
|
||||
|
||||
|
||||
void MotionQueue::RemoveFirstEntry()
|
||||
{
|
||||
mEntries.RemoveFirst();
|
||||
mEntries.erase(mEntries.begin());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "EMotionFXConfig.h"
|
||||
#include "BaseObject.h"
|
||||
#include "PlayBackInfo.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -79,7 +79,7 @@ namespace EMotionFX
|
||||
* Get the number of entries currently in the queue.
|
||||
* @result The number of entries currently scheduled in the queue.
|
||||
*/
|
||||
uint32 GetNumEntries() const;
|
||||
size_t GetNumEntries() const;
|
||||
|
||||
/**
|
||||
* Get the first entry.
|
||||
@@ -133,7 +133,7 @@ namespace EMotionFX
|
||||
void PlayNextMotion();
|
||||
|
||||
private:
|
||||
MCore::Array<QueueEntry> mEntries; /**< The motion queue entries. */
|
||||
AZStd::vector<QueueEntry> mEntries; /**< The motion queue entries. */
|
||||
MotionSystem* mMotionSystem; /**< Motion system access pointer. */
|
||||
ActorInstance* mActorInstance; /**< The actor instance where this queue works on. */
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace EMotionFX
|
||||
{
|
||||
MCORE_ASSERT(actorInstance);
|
||||
|
||||
mMotionInstances.SetMemoryCategory(EMFX_MEMCATEGORY_MOTIONS_MOTIONSYSTEMS);
|
||||
mActorInstance = actorInstance;
|
||||
mMotionQueue = nullptr;
|
||||
|
||||
@@ -46,11 +45,11 @@ namespace EMotionFX
|
||||
GetEventManager().OnDeleteMotionSystem(this);
|
||||
|
||||
// delete the motion infos
|
||||
while (mMotionInstances.GetLength())
|
||||
while (mMotionInstances.size())
|
||||
{
|
||||
//delete mMotionInstances.GetLast();
|
||||
GetMotionInstancePool().Free(mMotionInstances.GetLast());
|
||||
mMotionInstances.RemoveLast();
|
||||
GetMotionInstancePool().Free(mMotionInstances.back());
|
||||
mMotionInstances.pop_back();
|
||||
}
|
||||
|
||||
// get rid of the motion queue
|
||||
@@ -138,7 +137,14 @@ namespace EMotionFX
|
||||
bool MotionSystem::RemoveMotionInstance(MotionInstance* instance)
|
||||
{
|
||||
// remove the motion instance from the actor
|
||||
const bool isSuccess = mMotionInstances.RemoveByValue(instance);
|
||||
const bool isSuccess = [this, instance] {
|
||||
if(const auto it = AZStd::find(begin(mMotionInstances), end(mMotionInstances), instance); it != end(mMotionInstances))
|
||||
{
|
||||
mMotionInstances.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
|
||||
// delete the motion instance from memory
|
||||
if (isSuccess)
|
||||
@@ -167,7 +173,7 @@ namespace EMotionFX
|
||||
// stop all the motions that are currently playing
|
||||
void MotionSystem::StopAllMotions()
|
||||
{
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
const uint32 numInstances = mMotionInstances.size();
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
mMotionInstances[i]->Stop();
|
||||
@@ -178,7 +184,7 @@ namespace EMotionFX
|
||||
// stop all motion instances of a given motion
|
||||
void MotionSystem::StopAllMotions(Motion* motion)
|
||||
{
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
const uint32 numInstances = mMotionInstances.size();
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
if (mMotionInstances[i]->GetMotion()->GetID() == motion->GetID())
|
||||
@@ -190,16 +196,16 @@ namespace EMotionFX
|
||||
|
||||
|
||||
// remove the given motion
|
||||
void MotionSystem::RemoveMotion(uint32 nr, bool deleteMem)
|
||||
void MotionSystem::RemoveMotion(size_t nr, bool deleteMem)
|
||||
{
|
||||
MCORE_ASSERT(nr < mMotionInstances.GetLength());
|
||||
MCORE_ASSERT(nr < mMotionInstances.size());
|
||||
|
||||
if (deleteMem)
|
||||
{
|
||||
GetEMotionFX().GetMotionInstancePool()->Free(mMotionInstances[nr]);
|
||||
}
|
||||
|
||||
mMotionInstances.Remove(nr);
|
||||
mMotionInstances.erase(AZStd::next(begin(mMotionInstances), nr));
|
||||
}
|
||||
|
||||
|
||||
@@ -208,15 +214,15 @@ namespace EMotionFX
|
||||
{
|
||||
MCORE_ASSERT(motion);
|
||||
|
||||
uint32 nr = mMotionInstances.Find(motion);
|
||||
MCORE_ASSERT(nr != MCORE_INVALIDINDEX32);
|
||||
const auto it = AZStd::find(begin(mMotionInstances), end(mMotionInstances), motion);
|
||||
MCORE_ASSERT(it != end(mMotionInstances));
|
||||
|
||||
if (nr == MCORE_INVALIDINDEX32)
|
||||
if (it == end(mMotionInstances))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveMotion(nr, delMem);
|
||||
RemoveMotion(AZStd::distance(begin(mMotionInstances), it), delMem);
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +230,7 @@ namespace EMotionFX
|
||||
void MotionSystem::UpdateMotionInstances(float timePassed)
|
||||
{
|
||||
// update all the motion infos
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
const uint32 numInstances = mMotionInstances.size();
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
mMotionInstances[i]->Update(timePassed);
|
||||
@@ -242,7 +248,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// for all motion instances currently playing in this actor
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
const uint32 numInstances = mMotionInstances.size();
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
// check if this one is the one we are searching for, if so, return that it is still valid
|
||||
@@ -269,7 +275,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// for all motion instances currently playing in this actor
|
||||
const uint32 numInstances = mMotionInstances.GetLength();
|
||||
const uint32 numInstances = mMotionInstances.size();
|
||||
for (uint32 i = 0; i < numInstances; ++i)
|
||||
{
|
||||
const MotionInstance* motionInstance = mMotionInstances[i];
|
||||
@@ -294,15 +300,15 @@ namespace EMotionFX
|
||||
// return given motion instance
|
||||
MotionInstance* MotionSystem::GetMotionInstance(uint32 nr) const
|
||||
{
|
||||
MCORE_ASSERT(nr < mMotionInstances.GetLength());
|
||||
MCORE_ASSERT(nr < mMotionInstances.size());
|
||||
return mMotionInstances[nr];
|
||||
}
|
||||
|
||||
|
||||
// return number of motion instances
|
||||
uint32 MotionSystem::GetNumMotionInstances() const
|
||||
size_t MotionSystem::GetNumMotionInstances() const
|
||||
{
|
||||
return mMotionInstances.GetLength();
|
||||
return mMotionInstances.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -350,12 +356,12 @@ namespace EMotionFX
|
||||
|
||||
void MotionSystem::AddMotionInstance(MotionInstance* instance)
|
||||
{
|
||||
mMotionInstances.Add(instance);
|
||||
mMotionInstances.emplace_back(instance);
|
||||
}
|
||||
|
||||
|
||||
bool MotionSystem::GetIsPlaying() const
|
||||
{
|
||||
return (mMotionInstances.GetLength() > 0);
|
||||
return (mMotionInstances.size() > 0);
|
||||
}
|
||||
} // namespace EMotionFX
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// include the required headers
|
||||
#include "EMotionFXConfig.h"
|
||||
#include "BaseObject.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -76,7 +76,7 @@ namespace EMotionFX
|
||||
* @param nr The motion to remove.
|
||||
* @param deleteMem If true the allocated memory of the motion will be deleted.
|
||||
*/
|
||||
void RemoveMotion(uint32 nr, bool deleteMem = true);
|
||||
void RemoveMotion(size_t nr, bool deleteMem = true);
|
||||
|
||||
/**
|
||||
* Remove a given motion.
|
||||
@@ -122,7 +122,7 @@ namespace EMotionFX
|
||||
* @result The number of active motion instances inside this actor.
|
||||
* @see IsValidMotionInstance
|
||||
*/
|
||||
uint32 GetNumMotionInstances() const;
|
||||
size_t GetNumMotionInstances() const;
|
||||
|
||||
/**
|
||||
* Checks if a given motion instance is still valid.
|
||||
@@ -215,7 +215,7 @@ namespace EMotionFX
|
||||
|
||||
|
||||
protected:
|
||||
MCore::Array<MotionInstance*> mMotionInstances; /**< The collection of motion instances. */
|
||||
AZStd::vector<MotionInstance*> mMotionInstances; /**< The collection of motion instances. */
|
||||
ActorInstance* mActorInstance; /**< The actor instance where this motion system belongs to. */
|
||||
MotionQueue* mMotionQueue; /**< The motion queue. */
|
||||
|
||||
|
||||
@@ -30,9 +30,8 @@ namespace EMotionFX
|
||||
MultiThreadScheduler::MultiThreadScheduler()
|
||||
: ActorUpdateScheduler()
|
||||
{
|
||||
mSteps.SetMemoryCategory(EMFX_MEMCATEGORY_UPDATESCHEDULERS);
|
||||
mCleanTimer = 0.0f; // time passed since last schedule cleanup, in seconds
|
||||
mSteps.Reserve(1000);
|
||||
mSteps.reserve(1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +52,7 @@ namespace EMotionFX
|
||||
void MultiThreadScheduler::Clear()
|
||||
{
|
||||
Lock();
|
||||
mSteps.Clear();
|
||||
mSteps.clear();
|
||||
Unlock();
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ namespace EMotionFX
|
||||
void MultiThreadScheduler::Print()
|
||||
{
|
||||
// for all steps
|
||||
const uint32 numSteps = mSteps.GetLength();
|
||||
const uint32 numSteps = mSteps.size();
|
||||
for (uint32 i = 0; i < numSteps; ++i)
|
||||
{
|
||||
AZ_Printf("EMotionFX", "STEP %.3d - %d", i, mSteps[i].mActorInstances.size());
|
||||
@@ -92,7 +91,7 @@ namespace EMotionFX
|
||||
void MultiThreadScheduler::RemoveEmptySteps()
|
||||
{
|
||||
// process all steps
|
||||
for (uint32 s = 0; s < mSteps.GetLength(); )
|
||||
for (uint32 s = 0; s < mSteps.size(); )
|
||||
{
|
||||
// if the step isn't empty
|
||||
if (mSteps[s].mActorInstances.size() > 0)
|
||||
@@ -101,7 +100,7 @@ namespace EMotionFX
|
||||
}
|
||||
else // otherwise remove it
|
||||
{
|
||||
mSteps.Remove(s);
|
||||
mSteps.erase(AZStd::next(begin(mSteps), s));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +111,7 @@ namespace EMotionFX
|
||||
{
|
||||
MCore::LockGuardRecursive guard(mMutex);
|
||||
|
||||
uint32 numSteps = mSteps.GetLength();
|
||||
uint32 numSteps = mSteps.size();
|
||||
if (numSteps == 0)
|
||||
{
|
||||
return;
|
||||
@@ -124,7 +123,7 @@ namespace EMotionFX
|
||||
{
|
||||
mCleanTimer = 0.0f;
|
||||
RemoveEmptySteps();
|
||||
numSteps = mSteps.GetLength();
|
||||
numSteps = mSteps.size();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
@@ -216,7 +215,7 @@ namespace EMotionFX
|
||||
bool MultiThreadScheduler::FindNextFreeItem(ActorInstance* actorInstance, uint32 startStep, uint32* outStepNr)
|
||||
{
|
||||
// try out all steps
|
||||
const uint32 numSteps = mSteps.GetLength();
|
||||
const uint32 numSteps = mSteps.size();
|
||||
for (uint32 s = startStep; s < numSteps; ++s)
|
||||
{
|
||||
// if there is a conflicting dependency, skip this step
|
||||
@@ -236,7 +235,7 @@ namespace EMotionFX
|
||||
|
||||
bool MultiThreadScheduler::HasActorInstanceInSteps(const ActorInstance* actorInstance) const
|
||||
{
|
||||
const uint32 numSteps = mSteps.GetLength();
|
||||
const uint32 numSteps = mSteps.size();
|
||||
for (uint32 s = 0; s < numSteps; ++s)
|
||||
{
|
||||
const ScheduleStep& step = mSteps[s];
|
||||
@@ -258,9 +257,9 @@ namespace EMotionFX
|
||||
uint32 outStep = startStep;
|
||||
if (!FindNextFreeItem(instance, startStep, &outStep))
|
||||
{
|
||||
mSteps.Reserve(10);
|
||||
mSteps.AddEmpty();
|
||||
outStep = mSteps.GetLength() - 1;
|
||||
mSteps.reserve(10);
|
||||
mSteps.emplace_back();
|
||||
outStep = mSteps.size() - 1;
|
||||
}
|
||||
|
||||
// pre-allocate step size
|
||||
@@ -269,9 +268,9 @@ namespace EMotionFX
|
||||
mSteps[outStep].mActorInstances.reserve(mSteps[outStep].mActorInstances.size() + 10);
|
||||
}
|
||||
|
||||
if (mSteps[outStep].mDependencies.GetLength() % 5 == 0)
|
||||
if (mSteps[outStep].mDependencies.size() % 5 == 0)
|
||||
{
|
||||
mSteps[outStep].mDependencies.Reserve(mSteps[outStep].mDependencies.GetLength() + 5);
|
||||
mSteps[outStep].mDependencies.reserve(mSteps[outStep].mDependencies.size() + 5);
|
||||
}
|
||||
|
||||
// add the actor instance and its dependencies
|
||||
@@ -298,7 +297,7 @@ namespace EMotionFX
|
||||
MCore::LockGuardRecursive guard(mMutex);
|
||||
|
||||
// for all scheduler steps, starting from the specified start step number
|
||||
const uint32 numSteps = mSteps.GetLength();
|
||||
const uint32 numSteps = mSteps.size();
|
||||
for (uint32 s = startStep; s < numSteps; ++s)
|
||||
{
|
||||
ScheduleStep& step = mSteps[s];
|
||||
@@ -312,7 +311,7 @@ namespace EMotionFX
|
||||
if (step.mActorInstances.size() < numActorInstancesPreRemove)
|
||||
{
|
||||
// clear the dependencies (but don't delete the memory)
|
||||
step.mDependencies.Clear(false);
|
||||
step.mDependencies.clear();
|
||||
|
||||
// calculate the new dependencies for this step
|
||||
for (ActorInstance* stepActorInstance : step.mActorInstances)
|
||||
|
||||
@@ -50,16 +50,8 @@ namespace EMotionFX
|
||||
*/
|
||||
struct EMFX_API ScheduleStep
|
||||
{
|
||||
MCore::Array<Actor::Dependency> mDependencies; /**< The dependencies of this scheduler step. No actor instances with the same dependencies are allowed to be added to this step. */
|
||||
AZStd::vector<Actor::Dependency> mDependencies; /**< The dependencies of this scheduler step. No actor instances with the same dependencies are allowed to be added to this step. */
|
||||
AZStd::vector<ActorInstance*> mActorInstances; /**< The actor instances used inside this step. Each array entry will execute in another thread. */
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
ScheduleStep()
|
||||
{
|
||||
mDependencies.SetMemoryCategory(EMFX_MEMCATEGORY_UPDATESCHEDULERS);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -128,10 +120,10 @@ namespace EMotionFX
|
||||
void Unlock();
|
||||
|
||||
const ScheduleStep& GetScheduleStep(uint32 index) const { return mSteps[index]; }
|
||||
uint32 GetNumScheduleSteps() const { return mSteps.GetLength(); }
|
||||
size_t GetNumScheduleSteps() const { return mSteps.size(); }
|
||||
|
||||
protected:
|
||||
MCore::Array< ScheduleStep > mSteps; /**< An array of update steps, that together form the schedule. */
|
||||
AZStd::vector< ScheduleStep > mSteps; /**< An array of update steps, that together form the schedule. */
|
||||
float mCleanTimer; /**< The time passed since the last automatic call to the Optimize method. */
|
||||
MCore::MutexRecursive mMutex;
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@ namespace EMotionFX
|
||||
Node::Node(const char* name, Skeleton* skeleton)
|
||||
: BaseObject()
|
||||
{
|
||||
// set the array memory categories
|
||||
mAttributes.SetMemoryCategory(EMFX_MEMCATEGORY_NODES);
|
||||
mChildIndices.SetMemoryCategory(EMFX_MEMCATEGORY_NODES);
|
||||
|
||||
mParentIndex = MCORE_INVALIDINDEX32;
|
||||
mNodeIndex = MCORE_INVALIDINDEX32; // hasn't been set yet
|
||||
mSkeletalLODs = 0xFFFFFFFF; // set all bits of the integer to 1, which enables this node in all LOD levels on default
|
||||
@@ -45,10 +41,6 @@ namespace EMotionFX
|
||||
Node::Node(uint32 nameID, Skeleton* skeleton)
|
||||
: BaseObject()
|
||||
{
|
||||
// set the array memory categories
|
||||
mAttributes.SetMemoryCategory(EMFX_MEMCATEGORY_NODES);
|
||||
mChildIndices.SetMemoryCategory(EMFX_MEMCATEGORY_NODES);
|
||||
|
||||
mParentIndex = MCORE_INVALIDINDEX32;
|
||||
mNodeIndex = MCORE_INVALIDINDEX32; // hasn't been set yet
|
||||
mSkeletalLODs = 0xFFFFFFFF;// set all bits of the integer to 1, which enables this node in all LOD levels on default
|
||||
@@ -167,8 +159,8 @@ namespace EMotionFX
|
||||
result->mSemanticNameID = mSemanticNameID;
|
||||
|
||||
// copy the node attributes
|
||||
result->mAttributes.Reserve(mAttributes.GetLength());
|
||||
for (uint32 i = 0; i < mAttributes.GetLength(); i++)
|
||||
result->mAttributes.reserve(mAttributes.size());
|
||||
for (uint32 i = 0; i < mAttributes.size(); i++)
|
||||
{
|
||||
result->AddAttribute(mAttributes[i]->Clone());
|
||||
}
|
||||
@@ -181,10 +173,10 @@ namespace EMotionFX
|
||||
// removes all attributes
|
||||
void Node::RemoveAllAttributes()
|
||||
{
|
||||
while (mAttributes.GetLength())
|
||||
while (mAttributes.size())
|
||||
{
|
||||
mAttributes.GetLast()->Destroy();
|
||||
mAttributes.RemoveLast();
|
||||
mAttributes.back()->Destroy();
|
||||
mAttributes.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +205,7 @@ namespace EMotionFX
|
||||
numNodes++;
|
||||
|
||||
// recurse down the hierarchy
|
||||
const uint32 numChildNodes = mChildIndices.GetLength();
|
||||
const uint32 numChildNodes = mChildIndices.size();
|
||||
for (uint32 i = 0; i < numChildNodes; ++i)
|
||||
{
|
||||
mSkeleton->GetNode(mChildIndices[i])->RecursiveCountChildNodes(numNodes);
|
||||
@@ -405,20 +397,20 @@ namespace EMotionFX
|
||||
|
||||
void Node::AddAttribute(NodeAttribute* attribute)
|
||||
{
|
||||
mAttributes.Add(attribute);
|
||||
mAttributes.emplace_back(attribute);
|
||||
}
|
||||
|
||||
|
||||
uint32 Node::GetNumAttributes() const
|
||||
size_t Node::GetNumAttributes() const
|
||||
{
|
||||
return mAttributes.GetLength();
|
||||
return mAttributes.size();
|
||||
}
|
||||
|
||||
|
||||
NodeAttribute* Node::GetAttribute(uint32 attributeNr)
|
||||
{
|
||||
// make sure we are in range
|
||||
MCORE_ASSERT(attributeNr < mAttributes.GetLength());
|
||||
MCORE_ASSERT(attributeNr < mAttributes.size());
|
||||
|
||||
// return the attribute
|
||||
return mAttributes[attributeNr];
|
||||
@@ -428,7 +420,7 @@ namespace EMotionFX
|
||||
uint32 Node::FindAttributeNumber(uint32 attributeTypeID) const
|
||||
{
|
||||
// check all attributes, and find where the specific attribute is
|
||||
const uint32 numAttributes = mAttributes.GetLength();
|
||||
const uint32 numAttributes = mAttributes.size();
|
||||
for (uint32 i = 0; i < numAttributes; ++i)
|
||||
{
|
||||
if (mAttributes[i]->GetType() == attributeTypeID)
|
||||
@@ -445,7 +437,7 @@ namespace EMotionFX
|
||||
NodeAttribute* Node::GetAttributeByType(uint32 attributeType)
|
||||
{
|
||||
// check all attributes
|
||||
const uint32 numAttributes = mAttributes.GetLength();
|
||||
const uint32 numAttributes = mAttributes.size();
|
||||
for (uint32 i = 0; i < numAttributes; ++i)
|
||||
{
|
||||
if (mAttributes[i]->GetType() == attributeType)
|
||||
@@ -462,13 +454,13 @@ namespace EMotionFX
|
||||
// remove the given attribute
|
||||
void Node::RemoveAttribute(uint32 index)
|
||||
{
|
||||
mAttributes.Remove(index);
|
||||
mAttributes.erase(AZStd::next(begin(mAttributes), index));
|
||||
}
|
||||
|
||||
|
||||
void Node::AddChild(uint32 nodeIndex)
|
||||
{
|
||||
mChildIndices.AddExact(nodeIndex);
|
||||
mChildIndices.emplace_back(nodeIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -480,31 +472,34 @@ namespace EMotionFX
|
||||
|
||||
void Node::SetNumChildNodes(uint32 numChildNodes)
|
||||
{
|
||||
mChildIndices.Resize(numChildNodes);
|
||||
mChildIndices.resize(numChildNodes);
|
||||
}
|
||||
|
||||
|
||||
void Node::PreAllocNumChildNodes(uint32 numChildNodes)
|
||||
{
|
||||
mChildIndices.Reserve(numChildNodes);
|
||||
mChildIndices.reserve(numChildNodes);
|
||||
}
|
||||
|
||||
|
||||
void Node::RemoveChild(uint32 nodeIndex)
|
||||
{
|
||||
mChildIndices.RemoveByValue(nodeIndex);
|
||||
if (const auto it = AZStd::find(begin(mChildIndices), end(mChildIndices), nodeIndex); it != end(mChildIndices))
|
||||
{
|
||||
mChildIndices.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Node::RemoveAllChildNodes()
|
||||
{
|
||||
mChildIndices.Clear();
|
||||
mChildIndices.clear();
|
||||
}
|
||||
|
||||
|
||||
bool Node::GetHasChildNodes() const
|
||||
{
|
||||
return (mChildIndices.GetLength() > 0);
|
||||
return (mChildIndices.size() > 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include "EMotionFXConfig.h"
|
||||
#include "BaseObject.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
namespace EMotionFX
|
||||
@@ -168,7 +168,7 @@ namespace EMotionFX
|
||||
* Get the number of child nodes attached to this node.
|
||||
* @result The number of child nodes.
|
||||
*/
|
||||
MCORE_INLINE uint32 GetNumChildNodes() const { return mChildIndices.GetLength(); }
|
||||
MCORE_INLINE size_t GetNumChildNodes() const { return mChildIndices.size(); }
|
||||
|
||||
/**
|
||||
* Get the number of child nodes down the hierarchy of this node.
|
||||
@@ -189,7 +189,7 @@ namespace EMotionFX
|
||||
* @param nodeIndex The node to check whether it is a child or not.
|
||||
* @result True if the given node is a child, false if not.
|
||||
*/
|
||||
MCORE_INLINE bool CheckIfIsChildNode(uint32 nodeIndex) const { return (mChildIndices.Find(nodeIndex) != MCORE_INVALIDINDEX32); }
|
||||
MCORE_INLINE bool CheckIfIsChildNode(uint32 nodeIndex) const { return (AZStd::find(begin(mChildIndices), end(mChildIndices), nodeIndex) != end(mChildIndices)); }
|
||||
|
||||
/**
|
||||
* Add a child to this node.
|
||||
@@ -262,7 +262,7 @@ namespace EMotionFX
|
||||
* Get the number of node attributes.
|
||||
* @result The number of node attributes for this node.
|
||||
*/
|
||||
uint32 GetNumAttributes() const;
|
||||
size_t GetNumAttributes() const;
|
||||
|
||||
/**
|
||||
* Get a given node attribute.
|
||||
@@ -421,8 +421,8 @@ namespace EMotionFX
|
||||
uint32 mNameID; /**< The ID, which is generated from the name. You can use this for fast compares between nodes. */
|
||||
uint32 mSemanticNameID; /**< The semantic name ID, for example "LeftHand" or "RightFoot" or so, this can be used for retargeting. */
|
||||
Skeleton* mSkeleton; /**< The skeleton where this node belongs to. */
|
||||
MCore::Array<uint32> mChildIndices; /**< The indices that point to the child nodes. */
|
||||
MCore::Array<NodeAttribute*> mAttributes; /**< The node attributes. */
|
||||
AZStd::vector<uint32> mChildIndices; /**< The indices that point to the child nodes. */
|
||||
AZStd::vector<NodeAttribute*> mAttributes; /**< The node attributes. */
|
||||
uint8 mNodeFlags; /**< The node flags are used to store boolean attributes of the node as single bits. */
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,14 +41,14 @@ namespace EMotionFX
|
||||
// preallocate space
|
||||
void NodeMap::Reserve(uint32 numEntries)
|
||||
{
|
||||
mEntries.Reserve(numEntries);
|
||||
mEntries.reserve(numEntries);
|
||||
}
|
||||
|
||||
|
||||
// resize the entries array
|
||||
void NodeMap::Resize(uint32 numEntries)
|
||||
{
|
||||
mEntries.Resize(numEntries);
|
||||
mEntries.resize(numEntries);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,15 +101,15 @@ namespace EMotionFX
|
||||
void NodeMap::AddEntry(const char* firstName, const char* secondName)
|
||||
{
|
||||
MCORE_ASSERT(GetHasEntry(firstName) == false); // prevent duplicates
|
||||
mEntries.AddEmpty();
|
||||
SetEntry(mEntries.GetLength() - 1, firstName, secondName);
|
||||
mEntries.emplace_back();
|
||||
SetEntry(mEntries.size() - 1, firstName, secondName);
|
||||
}
|
||||
|
||||
|
||||
// remove a given entry by its index
|
||||
void NodeMap::RemoveEntryByIndex(uint32 entryIndex)
|
||||
{
|
||||
mEntries.Remove(entryIndex);
|
||||
mEntries.erase(AZStd::next(begin(mEntries), entryIndex));
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace EMotionFX
|
||||
return;
|
||||
}
|
||||
|
||||
mEntries.Remove(entryIndex);
|
||||
mEntries.erase(AZStd::next(begin(mEntries), entryIndex));
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace EMotionFX
|
||||
return;
|
||||
}
|
||||
|
||||
mEntries.Remove(entryIndex);
|
||||
mEntries.erase(AZStd::next(begin(mEntries), entryIndex));
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace EMotionFX
|
||||
uint32 numBytes = sizeof(FileFormat::NodeMapChunk);
|
||||
|
||||
// for all entries
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
numBytes += CalcFileStringSize(GetFirstNameString(i));
|
||||
@@ -265,7 +265,7 @@ namespace EMotionFX
|
||||
|
||||
// the main info
|
||||
FileFormat::NodeMapChunk nodeMapChunk{};
|
||||
nodeMapChunk.mNumEntries = mEntries.GetLength();
|
||||
nodeMapChunk.mNumEntries = mEntries.size();
|
||||
MCore::Endian::ConvertUnsignedInt32To(&nodeMapChunk.mNumEntries, targetEndianType);
|
||||
if (f.Write(&nodeMapChunk, sizeof(FileFormat::NodeMapChunk)) == 0)
|
||||
{
|
||||
@@ -282,7 +282,7 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
// for all entries
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
if (WriteFileString(&f, GetFirstNameString(i), targetEndianType) == false)
|
||||
@@ -320,9 +320,9 @@ namespace EMotionFX
|
||||
|
||||
|
||||
// get the number of entries
|
||||
uint32 NodeMap::GetNumEntries() const
|
||||
size_t NodeMap::GetNumEntries() const
|
||||
{
|
||||
return mEntries.GetLength();
|
||||
return mEntries.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace EMotionFX
|
||||
// find an entry index by its name
|
||||
uint32 NodeMap::FindEntryIndexByName(const char* firstName) const
|
||||
{
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
const AZStd::string& firstNameEntry = GetFirstName(i);
|
||||
@@ -381,7 +381,7 @@ namespace EMotionFX
|
||||
// find an entry index by its name ID
|
||||
uint32 NodeMap::FindEntryIndexByNameID(uint32 firstNameID) const
|
||||
{
|
||||
const uint32 numEntries = mEntries.GetLength();
|
||||
const uint32 numEntries = mEntries.size();
|
||||
for (uint32 i = 0; i < numEntries; ++i)
|
||||
{
|
||||
if (mEntries[i].mFirstNameID == firstNameID)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// include required files
|
||||
#include "EMotionFXConfig.h"
|
||||
#include "BaseObject.h"
|
||||
#include <MCore/Source/Array.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <MCore/Source/StringIdPool.h>
|
||||
#include <MCore/Source/Endian.h>
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace EMotionFX
|
||||
void Resize(uint32 numEntries);
|
||||
|
||||
// get data
|
||||
uint32 GetNumEntries() const;
|
||||
size_t GetNumEntries() const;
|
||||
const char* GetFirstName(uint32 entryIndex) const;
|
||||
const char* GetSecondName(uint32 entryIndex) const;
|
||||
const AZStd::string& GetFirstNameString(uint32 entryIndex) const;
|
||||
@@ -88,7 +88,7 @@ namespace EMotionFX
|
||||
bool Save(const char* fileName, MCore::Endian::EEndianType targetEndianType) const;
|
||||
|
||||
private:
|
||||
MCore::Array<MapEntry> mEntries; /**< The array of entries. */
|
||||
AZStd::vector<MapEntry> mEntries; /**< The array of entries. */
|
||||
AZStd::string mFileName; /**< The filename. */
|
||||
Actor* mSourceActor; /**< The source actor. */
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user