apply the transform to the output pose

This commit is contained in:
Mamadou Babaei
2023-02-24 01:49:03 +01:00
parent d20f6d719b
commit c301011e28
@@ -152,11 +152,17 @@ void FSGVirtualHandAnimInstanceProxy::PreEvaluateAnimation(UAnimInstance* InAnim
}
FRotator JointRotation{FingerJointRotations[JointIndex]};
/*const FRotator JointRotation{FingerJointRotations[JointIndex]};
const FQuat JointQuat{JointRotation.Quaternion()};
const FRotator ReferenceRotation{Hand->GetActorRotation()};
const FQuat ReferenceQuat{ReferenceRotation.Quaternion()};
FRotator BoneRotation{ReferenceQuat * JointQuat};*/
FName BoneName(Hand->IsRight()
? GetRightHandBoneName(FingerIndex, JointIndex)
: GetLeftHandBoneName(FingerIndex, JointIndex));
//BoneMap.Emplace(MoveTemp(BoneName), MoveTemp(BoneRotation));
BoneMap.Emplace(MoveTemp(BoneName), MoveTemp(JointRotation));
}
}
@@ -207,6 +213,7 @@ bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
FAnimNode_ModifyBone BoneController;
BoneController.BoneToModify = MoveTemp(BoneReference);
BoneController.RotationMode = EBoneModificationMode::BMM_Replace;
//BoneController.RotationSpace = EBoneControlSpace::BCS_WorldSpace;
BoneController.RotationSpace = EBoneControlSpace::BCS_ComponentSpace;
BoneController.Rotation = MoveTemp(BoneRotation);
@@ -218,9 +225,12 @@ bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
const TArray<FBoneTransform>::SizeType BoneTransformsNum = BoneTransforms.Num();
if (BoneTransformsNum > 0)
{
const FCompactPoseBoneIndex PoseBoneIndex{static_cast<FCompactPoseBoneIndex>(BoneIndex)};
const FCompactPoseBoneIndex PoseBoneIndex{
BoneController.BoneToModify.GetCompactPoseIndex(
PoseContext.Pose.GetPose().GetBoneContainer())
};
const FTransform BoneTransformBefore{PoseContext.Pose.GetComponentSpaceTransform(PoseBoneIndex)};
PoseContext.Pose.SetComponentSpaceTransform(PoseBoneIndex, BoneTransforms[0].Transform);
PoseContext.Pose.LocalBlendCSBoneTransforms(BoneTransforms, 1.0f);
const FTransform BoneTransformAfter{PoseContext.Pose.GetComponentSpaceTransform(PoseBoneIndex)};
SGLOG("BoneController.Rotation", BoneController.Rotation);
@@ -228,6 +238,10 @@ bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
SGLOG("BoneTransformBefore.Rotation", BoneTransformBefore.Rotator());
SGLOG("BoneTransformAfter.Rotation", BoneTransformAfter.Rotator());
// Output.Pose[PoseBoneIndex].SetRotation(
// PoseContext.Pose.GetComponentSpaceTransform(PoseBoneIndex).GetRotation());
PoseContext.Pose.ConvertComponentPosesToLocalPoses(PoseContext.Pose, Output.Pose);
HandMeshComponent->MarkRenderStateDirty();
}
}