Skip to content

Commit

Permalink
Fix Issue : Kawaii physics does not work with control rig. #56
Browse files Browse the repository at this point in the history
Fix Issue : PlanarLimits does not work if set driving bone none.
  • Loading branch information
pafuhana@hotmail.co.jp authored and pafuhana@hotmail.co.jp committed May 27, 2023
1 parent aff5328 commit d6ef1ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ void FAnimNode_KawaiiPhysics::Initialize_AnyThread(const FAnimationInitializeCon

ApplyLimitsDataAsset(RequiredBones);

InitializeBoneReferences(RequiredBones);

ModifyBones.Empty();

// For Avoiding Zero Divide in the first frame
Expand Down Expand Up @@ -508,7 +506,13 @@ void FAnimNode_KawaiiPhysics::UpdatePlanerLimits(TArray<FPlanarLimit>& Limits, F
}
else
{
Planar.bEnable = false;
Planar.Location = Planar.OffsetLocation;
Planar.Rotation = Planar.OffsetRotation.Quaternion();
Planar.Rotation.Normalize();
Planar.Plane = FPlane(Planar.Location, Planar.Rotation.GetUpVector());

// Maybe the DrivingBone is set to empty for the floor, so keep Enable
// Planar.bEnable = false;
}
}
}
Expand Down Expand Up @@ -807,10 +811,6 @@ void FAnimNode_KawaiiPhysics::AdjustByPlanerCollision(FKawaiiPhysicsModifyBone&
{
for (auto& Planar : Limits)
{
if(!Planar.bEnable)
{
continue;
}
FVector PointOnPlane = FVector::PointPlaneProject(Bone.Location, Planar.Plane);
const float DistSquared = (Bone.Location - PointOnPlane).SizeSquared();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ void FKawaiiPhysicsEditMode::RenderPlanerLimit(FPrimitiveDrawInterface* PDI)
for (int32 i = 0; i < RuntimeNode->PlanarLimits.Num(); i++)
{
auto& Plane = RuntimeNode->PlanarLimits[i];
if(!Plane.bEnable)
{
continue;
}

FTransform PlaneTransform = FTransform(Plane.Rotation, Plane.Location);
PlaneTransform.NormalizeRotation();

Expand All @@ -232,11 +227,6 @@ void FKawaiiPhysicsEditMode::RenderPlanerLimit(FPrimitiveDrawInterface* PDI)
for (int32 i = 0; i < RuntimeNode->PlanarLimitsData.Num(); i++)
{
auto& Plane = RuntimeNode->PlanarLimitsData[i];
if(!Plane.bEnable)
{
continue;
}

FTransform PlaneTransform = FTransform(Plane.Rotation, Plane.Location);
PlaneTransform.NormalizeRotation();

Expand Down

0 comments on commit d6ef1ed

Please sign in to comment.