Optimize memory allocation when reading animated model pose by cloth
This commit is contained in:
@@ -140,6 +140,13 @@ void AnimatedModel::GetCurrentPose(Array<Matrix>& nodesTransformation, bool worl
|
||||
}
|
||||
}
|
||||
|
||||
void AnimatedModel::GetCurrentPose(Span<Matrix>& nodesTransformation) const
|
||||
{
|
||||
if (GraphInstance.NodesPose.IsEmpty())
|
||||
const_cast<AnimatedModel*>(this)->PreInitSkinningData(); // Ensure to have valid nodes pose to return
|
||||
nodesTransformation = ToSpan(GraphInstance.NodesPose);
|
||||
}
|
||||
|
||||
void AnimatedModel::SetCurrentPose(const Array<Matrix>& nodesTransformation, bool worldSpace)
|
||||
{
|
||||
if (GraphInstance.NodesPose.IsEmpty())
|
||||
|
||||
@@ -213,6 +213,12 @@ public:
|
||||
/// <param name="worldSpace">True if convert matrices into world-space, otherwise returned values will be in local-space of the actor.</param>
|
||||
API_FUNCTION() void GetCurrentPose(API_PARAM(Out) Array<Matrix>& nodesTransformation, bool worldSpace = false) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the per-node final transformations (skeleton pose).
|
||||
/// </summary>
|
||||
/// <param name="nodesTransformation">The output per-node final transformation matrices.</param>
|
||||
void GetCurrentPose(Span<Matrix>& nodesTransformation) const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the per-node final transformations (skeleton pose).
|
||||
/// </summary>
|
||||
|
||||
@@ -815,8 +815,7 @@ bool Cloth::OnPreUpdate()
|
||||
Array<Float4> particlesSkinned;
|
||||
particlesSkinned.Set(particles.Get(), particles.Length());
|
||||
|
||||
// TODO: optimize memory allocs (eg. get pose as Span<Matrix> for readonly)
|
||||
Array<Matrix> pose;
|
||||
Span<Matrix> pose;
|
||||
animatedModel->GetCurrentPose(pose);
|
||||
const SkeletonData& skeleton = animatedModel->SkinnedModel->Skeleton;
|
||||
const SkeletonBone* bones = skeleton.Bones.Get();
|
||||
@@ -999,8 +998,7 @@ void Cloth::RunClothDeformer(const MeshBase* mesh, MeshDeformationData& deformat
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: optimize memory allocs (eg. get pose as Span<Matrix> for readonly)
|
||||
Array<Matrix> pose;
|
||||
Span<Matrix> pose;
|
||||
animatedModel->GetCurrentPose(pose);
|
||||
const SkeletonData& skeleton = animatedModel->SkinnedModel->Skeleton;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user