try a component transform
This commit is contained in:
@@ -151,7 +151,7 @@ void FSGVirtualHandAnimInstanceProxy::PreEvaluateAnimation(UAnimInstance* InAnim
|
||||
continue;
|
||||
}
|
||||
|
||||
FRotator JointRotation = FingerJointRotations[JointIndex];
|
||||
FRotator JointRotation{FingerJointRotations[JointIndex]};
|
||||
|
||||
FName BoneName(Hand->IsRight()
|
||||
? GetRightHandBoneName(FingerIndex, JointIndex)
|
||||
@@ -164,7 +164,7 @@ void FSGVirtualHandAnimInstanceProxy::PreEvaluateAnimation(UAnimInstance* InAnim
|
||||
|
||||
bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
|
||||
{
|
||||
const USkeletalMeshComponent* HandMeshComponent = GetSkelMeshComponent();
|
||||
USkeletalMeshComponent* HandMeshComponent = GetSkelMeshComponent();
|
||||
if (!IsValid(HandMeshComponent))
|
||||
{
|
||||
return FAnimInstanceProxy::Evaluate(Output);
|
||||
@@ -196,15 +196,18 @@ bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
|
||||
FName BoneName(Bone.Key);
|
||||
FRotator BoneRotation(Bone.Value);
|
||||
|
||||
const int32 BoneIndex = GetRequiredBones().GetPoseBoneIndexForBoneName(BoneName);
|
||||
ensureAlwaysMsgf(BoneIndex != INDEX_NONE, TEXT("Invalid BoneIndex!"));
|
||||
|
||||
FBoneReference BoneReference;
|
||||
BoneReference.BoneName = BoneName;
|
||||
BoneReference.BoneIndex = GetRequiredBones().GetPoseBoneIndexForBoneName(BoneName);
|
||||
BoneReference.BoneName = MoveTemp(BoneName);
|
||||
BoneReference.BoneIndex = BoneIndex;
|
||||
BoneReference.bUseSkeletonIndex = true;
|
||||
|
||||
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);
|
||||
|
||||
if (BoneController.IsValidToEvaluate(HandSkeleton, PoseContext.Pose.GetPose().GetBoneContainer()))
|
||||
@@ -212,9 +215,20 @@ bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
|
||||
TArray<FBoneTransform> BoneTransforms;
|
||||
BoneController.EvaluateSkeletalControl_AnyThread(PoseContext, BoneTransforms);
|
||||
|
||||
if (BoneTransforms.Num() > 0)
|
||||
const TArray<FBoneTransform>::SizeType BoneTransformsNum = BoneTransforms.Num();
|
||||
if (BoneTransformsNum > 0)
|
||||
{
|
||||
PoseContext.Pose.LocalBlendCSBoneTransforms(BoneTransforms, 1.0f);
|
||||
const FCompactPoseBoneIndex PoseBoneIndex{static_cast<FCompactPoseBoneIndex>(BoneIndex)};
|
||||
const FTransform BoneTransformBefore{PoseContext.Pose.GetComponentSpaceTransform(PoseBoneIndex)};
|
||||
PoseContext.Pose.SetComponentSpaceTransform(PoseBoneIndex, BoneTransforms[0].Transform);
|
||||
const FTransform BoneTransformAfter{PoseContext.Pose.GetComponentSpaceTransform(PoseBoneIndex)};
|
||||
|
||||
SGLOG("BoneController.Rotation", BoneController.Rotation);
|
||||
SGLOG("BoneTransforms[0].Transform.GetRotation()", BoneTransforms[0].Transform.GetRotation().Rotator());
|
||||
SGLOG("BoneTransformBefore.Rotation", BoneTransformBefore.Rotator());
|
||||
SGLOG("BoneTransformAfter.Rotation", BoneTransformAfter.Rotator());
|
||||
|
||||
HandMeshComponent->MarkRenderStateDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user