pafuhana1213 / KawaiiPhysics

KawaiiPhysics : Simple fake Physics for UnrealEngine4 & 5
MIT License
1.92k stars 287 forks source link

Reset bone location and rotation may cause trouble when switching between skeleton LODs #44

Closed ZP-Z closed 2 years ago

ZP-Z commented 2 years ago
//@struct FKawaiiPhysicsModifyBone
void UpdatePoseTranform(const FBoneContainer& BoneContainer, FCSPose<FCompactPose>& Pose)
{
    auto CompactPoseIndex = BoneRef.GetCompactPoseIndex(BoneContainer);
    if (CompactPoseIndex < 0)
    {
        PoseLocation = FVector::ZeroVector;
        PoseRotation = FQuat::Identity;
        PoseScale = FVector::OneVector;
        return;
    }

    auto ComponentSpaceTransform = Pose.GetComponentSpaceTransform(CompactPoseIndex);
    PoseLocation = ComponentSpaceTransform.GetLocation();
    PoseRotation = ComponentSpaceTransform.GetRotation();
    PoseScale = ComponentSpaceTransform.GetScale3D();
}

Bone motion is too large when switching LOD. When CompactPoseIndex < 0, maybe just keeping the information saved before works well.

pafuhana1213 commented 2 years ago

Hi, I can't see the issue in sample, but your point sounds good. So I have added new flag to avoid reset transform. https://github.com/pafuhana1213/KawaiiPhysics/commit/20c1ec0e9a9ffe27e55de485ed5be01b79365476

I'm happy if this change help you. thanks!