mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[ue4] Fixed up bone driver, only does position at the moment
This commit is contained in:
parent
84766e3a99
commit
ba70ec17b4
Binary file not shown.
BIN
spine-ue4/Content/SpineBoy/Hover_Blueprint.uasset
Normal file
BIN
spine-ue4/Content/SpineBoy/Hover_Blueprint.uasset
Normal file
Binary file not shown.
@ -13,7 +13,7 @@ void USpineBoneDriverComponent::BeginPlay () {
|
||||
|
||||
void USpineBoneDriverComponent::BeforeUpdateWorldTransform(USpineSkeletonComponent* skeleton) {
|
||||
AActor* owner = GetOwner();
|
||||
if (owner) {
|
||||
if (owner && skeleton == lastBoundComponent) {
|
||||
skeleton->SetBoneWorldPosition(BoneName, owner->GetActorLocation() );
|
||||
}
|
||||
}
|
||||
@ -25,7 +25,8 @@ void USpineBoneDriverComponent::TickComponent (float DeltaTime, ELevelTick TickT
|
||||
USpineSkeletonComponent* skeleton = static_cast<USpineSkeletonComponent*>(Target->GetComponentByClass(USpineSkeletonComponent::StaticClass()));
|
||||
if (skeleton != lastBoundComponent) {
|
||||
// if (lastBoundComponent) lastBoundComponent->BeforeUpdateWorldTransform.RemoveAll(this);
|
||||
skeleton->BeforeUpdateWorldTransform.AddDynamic(this, &USpineBoneDriverComponent::BeforeUpdateWorldTransform);
|
||||
if (!skeleton->BeforeUpdateWorldTransform.GetAllObjects().Contains(this))
|
||||
skeleton->BeforeUpdateWorldTransform.AddDynamic(this, &USpineBoneDriverComponent::BeforeUpdateWorldTransform);
|
||||
lastBoundComponent = skeleton;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,9 +73,13 @@ void USpineSkeletonComponent::SetBoneWorldPosition (const FString& BoneName, con
|
||||
}
|
||||
|
||||
baseTransform = baseTransform.Inverse();
|
||||
FVector localPosition = baseTransform.TransformVector(position);
|
||||
FVector localPosition = baseTransform.TransformPosition(position);
|
||||
float localX = 0, localY = 0;
|
||||
spBone_worldToLocal(bone, localPosition.X, localPosition.Z, &localX, &localY);
|
||||
if (bone->parent) {
|
||||
spBone_worldToLocal(bone->parent, localPosition.X, localPosition.Z, &localX, &localY);
|
||||
} else {
|
||||
spBone_worldToLocal(bone, localPosition.X, localPosition.Z, &localX, &localY);
|
||||
}
|
||||
bone->x = localX;
|
||||
bone->y = localY;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user