vault backup: 2023-11-07 11:33:46

This commit is contained in:
BlueRose 2023-11-07 11:33:46 +08:00
parent b7c9fabdf5
commit 79f6187d8a

View File

@ -38,10 +38,10 @@ rating: ⭐
重定向数据会直接修改TargetSkeleton的Pose数据。Root与FK重定向执行完之后会调用UpdateGlobalTransformsBelowBone()更新后续骨骼的WorldSpace Transform。
## RunRootRetarget()
FRootRetargeter::EncodePose():
FRootRetargeter::EncodePose()
取得输入的根骨骼Transform数据并给`FRootSource Source`赋值。
FRootRetargeter::DecodePose():
FRootRetargeter::DecodePose()
```c++
FVector Position;
{
@ -67,30 +67,36 @@ FVector Position;
FQuat Rotation;
{
// calc offset between initial source/target root rotations
// 计算Source的旋转偏差值
const FQuat RotationDelta = Source.CurrentRotation * Source.InitialRotation.Inverse();
// add retarget pose delta to the current source rotation
// 将偏移加到Target上
const FQuat RetargetedRotation = RotationDelta * Target.InitialRotation;
// add static rotation offset
// 将RetargetSetting上的旋转偏差值加上。
Rotation = RetargetedRotation * Settings.RotationOffset.Quaternion();
// blend with alpha
Rotation = FQuat::FastLerp(Target.InitialRotation, Rotation, Settings.RotationAlpha);
Rotation.Normalize();
// record the delta created by all the modifications made to the root rotation
// 记录Target的旋转偏差值
Target.RootRotationDelta = RetargetedRotation * Target.InitialRotation.Inverse();
}
// apply to target
// 将数据应用到根骨骼上
FTransform& TargetRootTransform = OutTargetGlobalPose[Target.BoneIndex];
TargetRootTransform.SetTranslation(Position);
TargetRootTransform.SetRotation(Rotation);
```
## RunFKRetarget()
FChainEncoderFK::EncodePose():
从骨骼链拷贝全局输入到CurrentGlobalTransforms
遍历所有骨骼链并执行FChainEncoderFK::EncodePose()与FChainDecoderFK::DecodePose()。
FChainDecoderFK::DecodePose():
FChainEncoderFK::EncodePose()
1. 遍历所有骨骼链根据骨骼链Index得到BoneIndex之后将对应骨骼的WorldSpace Transform赋予到对应骨骼链Index的CurrentGlobalTransforms中。
2. Resize CurrentLocalTransforms其长度与SourceBoneIndices相同。
3. FillTransformsWithLocalSpaceOfChain()
1. 遍历所有骨骼链取得对应骨骼的Index以及父骨骼Index。跳过根骨骼
2. 计算相对Transform后放入对应ChainIndex的OutLocalTransforms中。
4. 根据ChainParentBoneIndex将父骨骼Transform赋予给ChainParentCurrentGlobalTransform。
FChainDecoderFK::DecodePose()