From b33e13f985560c4827e1b1faa543fff4e42d2563 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 10 Sep 2025 12:45:17 +0200 Subject: [PATCH] [ue] Port to new spine-cpp API --- .../SpinePlugin/Private/SSpineWidget.cpp | 49 ++++++------ .../SpineSkeletonAnimationComponent.cpp | 8 +- .../Private/SpineSkeletonComponent.cpp | 18 ++--- .../Private/SpineSkeletonDataAsset.cpp | 10 +-- .../SpineSkeletonRendererComponent.cpp | 14 ++-- .../SpinePlugin/Private/SpineWidget.cpp | 78 +++++++++---------- 6 files changed, 88 insertions(+), 89 deletions(-) diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SSpineWidget.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SSpineWidget.cpp index 5bead80a8..7f4c0d283 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SSpineWidget.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SSpineWidget.cpp @@ -81,11 +81,10 @@ void SSpineWidget::SetData(USpineWidget *Widget) { this->widget = Widget; if (widget && widget->skeleton && widget->Atlas) { Skeleton *skeleton = widget->skeleton; - skeleton->setToSetupPose(); + skeleton->setupPose(); skeleton->updateWorldTransform(Physics_None); - Vector scratchBuffer; float x, y, w, h; - skeleton->getBounds(x, y, w, h, scratchBuffer); + skeleton->getBounds(x, y, w, h); boundsMin.X = x; boundsMin.Y = y; boundsSize.X = w; @@ -271,13 +270,13 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList &OutDrawEle UMaterialInstanceDynamic *lastMaterial = nullptr; SkeletonClipping &clipper = widget->clipper; - Vector &worldVertices = widget->worldVertices; + Array &worldVertices = widget->worldVertices; float depthOffset = 0; unsigned short quadIndices[] = {0, 1, 2, 0, 2, 3}; for (int i = 0; i < (int) Skeleton->getSlots().size(); ++i) { - Vector *attachmentVertices = &worldVertices; + Array *attachmentVertices = &worldVertices; unsigned short *attachmentIndices = nullptr; int numVertices; int numIndices; @@ -292,7 +291,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList &OutDrawEle continue; } - Attachment *attachment = slot->getAttachment(); + Attachment *attachment = slot->getAppliedPose().getAttachment(); if (!attachment) { clipper.clipEnd(*slot); continue; @@ -317,7 +316,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList &OutDrawEle MeshAttachment *mesh = (MeshAttachment *) attachment; attachmentColor.set(mesh->getColor()); attachmentVertices->setSize(mesh->getWorldVerticesLength(), 0); - mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), attachmentVertices->buffer(), 0, 2); + mesh->computeWorldVertices(*Skeleton, *slot, 0, mesh->getWorldVerticesLength(), attachmentVertices->buffer(), 0, 2); attachmentAtlasRegion = (AtlasRegion *) mesh->getRegion(); attachmentIndices = mesh->getTriangles().buffer(); attachmentUvs = mesh->getUVs().buffer(); @@ -325,7 +324,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList &OutDrawEle numIndices = mesh->getTriangles().size(); } else /* clipping */ { ClippingAttachment *clip = (ClippingAttachment *) attachment; - clipper.clipStart(*slot, clip); + clipper.clipStart(*Skeleton, *slot, clip); continue; } @@ -335,39 +334,39 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList &OutDrawEle UMaterialInstanceDynamic *material = nullptr; switch (slot->getData().getBlendMode()) { case BlendMode_Normal: - if (!widget->pageToNormalBlendMaterial.Contains(attachmentAtlasRegion->page)) { + if (!widget->pageToNormalBlendMaterial.Contains(attachmentAtlasRegion->getPage())) { clipper.clipEnd(*slot); continue; } - material = widget->pageToNormalBlendMaterial[attachmentAtlasRegion->page]; + material = widget->pageToNormalBlendMaterial[attachmentAtlasRegion->getPage()]; break; case BlendMode_Additive: - if (!widget->pageToAdditiveBlendMaterial.Contains(attachmentAtlasRegion->page)) { + if (!widget->pageToAdditiveBlendMaterial.Contains(attachmentAtlasRegion->getPage())) { clipper.clipEnd(*slot); continue; } - material = widget->pageToAdditiveBlendMaterial[attachmentAtlasRegion->page]; + material = widget->pageToAdditiveBlendMaterial[attachmentAtlasRegion->getPage()]; break; case BlendMode_Multiply: - if (!widget->pageToMultiplyBlendMaterial.Contains(attachmentAtlasRegion->page)) { + if (!widget->pageToMultiplyBlendMaterial.Contains(attachmentAtlasRegion->getPage())) { clipper.clipEnd(*slot); continue; } - material = widget->pageToMultiplyBlendMaterial[attachmentAtlasRegion->page]; + material = widget->pageToMultiplyBlendMaterial[attachmentAtlasRegion->getPage()]; break; case BlendMode_Screen: - if (!widget->pageToScreenBlendMaterial.Contains(attachmentAtlasRegion->page)) { + if (!widget->pageToScreenBlendMaterial.Contains(attachmentAtlasRegion->getPage())) { clipper.clipEnd(*slot); continue; } - material = widget->pageToScreenBlendMaterial[attachmentAtlasRegion->page]; + material = widget->pageToScreenBlendMaterial[attachmentAtlasRegion->getPage()]; break; default: - if (!widget->pageToNormalBlendMaterial.Contains(attachmentAtlasRegion->page)) { + if (!widget->pageToNormalBlendMaterial.Contains(attachmentAtlasRegion->getPage())) { clipper.clipEnd(*slot); continue; } - material = widget->pageToNormalBlendMaterial[attachmentAtlasRegion->page]; + material = widget->pageToNormalBlendMaterial[attachmentAtlasRegion->getPage()]; } if (clipper.isClipping()) { @@ -389,14 +388,14 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList &OutDrawEle idx = 0; } - uint8 r = static_cast(Skeleton->getColor().r * slot->getColor().r * attachmentColor.r * 255); - uint8 g = static_cast(Skeleton->getColor().g * slot->getColor().g * attachmentColor.g * 255); - uint8 b = static_cast(Skeleton->getColor().b * slot->getColor().b * attachmentColor.b * 255); - uint8 a = static_cast(Skeleton->getColor().a * slot->getColor().a * attachmentColor.a * 255); + uint8 r = static_cast(Skeleton->getColor().r * slot->getAppliedPose().getColor().r * attachmentColor.r * 255); + uint8 g = static_cast(Skeleton->getColor().g * slot->getAppliedPose().getColor().g * attachmentColor.g * 255); + uint8 b = static_cast(Skeleton->getColor().b * slot->getAppliedPose().getColor().b * attachmentColor.b * 255); + uint8 a = static_cast(Skeleton->getColor().a * slot->getAppliedPose().getColor().a * attachmentColor.a * 255); - float dr = slot->hasDarkColor() ? slot->getDarkColor().r : 0.0f; - float dg = slot->hasDarkColor() ? slot->getDarkColor().g : 0.0f; - float db = slot->hasDarkColor() ? slot->getDarkColor().b : 0.0f; + float dr = slot->getAppliedPose().hasDarkColor() ? slot->getAppliedPose().getDarkColor().r : 0.0f; + float dg = slot->getAppliedPose().hasDarkColor() ? slot->getAppliedPose().getDarkColor().g : 0.0f; + float db = slot->getAppliedPose().hasDarkColor() ? slot->getAppliedPose().getDarkColor().b : 0.0f; float *verticesPtr = attachmentVertices->buffer(); for (int j = 0; j < numVertices << 1; j += 2) { diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp index 316ef2d99..ec283db16 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp @@ -156,7 +156,7 @@ void USpineSkeletonAnimationComponent::CheckState() { AnimationStateData *stateData = SkeletonData->GetAnimationStateData(Atlas->GetAtlas()); state = new (__FILE__, __LINE__) AnimationState(*stateData); state->setRendererObject((void *) this); - state->setListener(callback); + state->setListener(callback, nullptr); trackEntries.Empty(); } } @@ -227,7 +227,7 @@ UTrackEntry *USpineSkeletonAnimationComponent::SetAnimation(int trackIndex, FStr CheckState(); if (state && skeleton->getData().findAnimation(TCHAR_TO_UTF8(*animationName))) { state->disableQueue(); - TrackEntry &entry = &state->setAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop); + TrackEntry &entry = state->setAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop); state->enableQueue(); UTrackEntry *uEntry = NewObject(); uEntry->SetTrackEntry(&entry); @@ -239,7 +239,7 @@ UTrackEntry *USpineSkeletonAnimationComponent::SetAnimation(int trackIndex, FStr UTrackEntry *USpineSkeletonAnimationComponent::AddAnimation(int trackIndex, FString animationName, bool loop, float delay) { CheckState(); - if (state && skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*animationName))) { + if (state && skeleton->getData().findAnimation(TCHAR_TO_UTF8(*animationName))) { state->disableQueue(); TrackEntry &entry = state->addAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop, delay); state->enableQueue(); @@ -268,7 +268,7 @@ UTrackEntry *USpineSkeletonAnimationComponent::AddEmptyAnimation(int trackIndex, if (state) { TrackEntry &entry = state->addEmptyAnimation(trackIndex, mixDuration, delay); UTrackEntry *uEntry = NewObject(); - uEntry->SetTrackEntry(entry); + uEntry->SetTrackEntry(&entry); trackEntries.Add(uEntry); return uEntry; } else diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp index da9a7b41e..5602c8a7f 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp @@ -194,7 +194,7 @@ void USpineSkeletonComponent::SetupPoseBones() { void USpineSkeletonComponent::SetupPoseSlots() { CheckState(); - if (skeleton) skeleton->SetupPoseSlots(); + if (skeleton) skeleton->setupPoseSlots(); } void USpineSkeletonComponent::SetScaleX(float scaleX) { @@ -231,7 +231,7 @@ void USpineSkeletonComponent::GetBones(TArray &Bones) { bool USpineSkeletonComponent::HasBone(const FString BoneName) { CheckState(); if (skeleton) { - return skeleton->getData()->findBone(TCHAR_TO_UTF8(*BoneName)) != nullptr; + return skeleton->getData().findBone(TCHAR_TO_UTF8(*BoneName)) != nullptr; } return false; } @@ -248,7 +248,7 @@ void USpineSkeletonComponent::GetSlots(TArray &Slots) { bool USpineSkeletonComponent::HasSlot(const FString SlotName) { CheckState(); if (skeleton) { - return skeleton->getData()->findSlot(TCHAR_TO_UTF8(*SlotName)) != nullptr; + return skeleton->getData().findSlot(TCHAR_TO_UTF8(*SlotName)) != nullptr; } return false; } @@ -258,7 +258,7 @@ void USpineSkeletonComponent::SetSlotColor(const FString SlotName, const FColor if (skeleton) { Slot *slot = skeleton->findSlot(TCHAR_TO_UTF8(*SlotName)); if (slot) { - slot->getColor().set(color.R / 255.f, color.G / 255.f, color.B / 255.f, color.A / 255.f); + slot->getPose().getColor().set(color.R / 255.f, color.G / 255.f, color.B / 255.f, color.A / 255.f); } } } @@ -275,7 +275,7 @@ void USpineSkeletonComponent::GetAnimations(TArray &Animations) { bool USpineSkeletonComponent::HasAnimation(FString AnimationName) { CheckState(); if (skeleton) { - return skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*AnimationName)) != nullptr; + return skeleton->getData().findAnimation(TCHAR_TO_UTF8(*AnimationName)) != nullptr; } return false; } @@ -309,9 +309,9 @@ void USpineSkeletonComponent::PhysicsRotate(float x, float y, float degrees) { void USpineSkeletonComponent::ResetPhysicsConstraints() { CheckState(); if (skeleton) { - Vector &constraints = skeleton->getPhysicsConstraints(); + Array &constraints = skeleton->getPhysicsConstraints(); for (int i = 0, n = (int) constraints.size(); i < n; i++) { - constraints[i]->reset(); + constraints[i]->reset(*skeleton); } } } @@ -346,7 +346,7 @@ void USpineSkeletonComponent::CheckState() { if (lastSpineAtlas != atlas) { needsUpdate = true; } - if (skeleton && skeleton->getData() != SkeletonData->GetSkeletonData(atlas)) { + if (skeleton && &skeleton->getData() != SkeletonData->GetSkeletonData(atlas)) { needsUpdate = true; } } @@ -357,7 +357,7 @@ void USpineSkeletonComponent::CheckState() { if (Atlas && SkeletonData) { spine::SkeletonData *data = SkeletonData->GetSkeletonData(Atlas->GetAtlas()); - skeleton = new (__FILE__, __LINE__) Skeleton(data); + skeleton = new (__FILE__, __LINE__) Skeleton(*data); } lastAtlas = Atlas; diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp index 503f1d808..b07f710e7 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp @@ -230,7 +230,7 @@ void USpineSkeletonDataAsset::LoadInfo() { NullAttachmentLoader loader; SkeletonData *skeletonData = nullptr; if (skeletonDataFileName.GetPlainNameString().Contains(TEXT(".json"))) { - SkeletonJson *json = new (__FILE__, __LINE__) SkeletonJson(&loader); + SkeletonJson *json = new (__FILE__, __LINE__) SkeletonJson(loader); if (checkJson((const char *) rawData.GetData())) skeletonData = json->readSkeletonData((const char *) rawData.GetData()); if (!skeletonData) { FMessageDialog::Debugf(FText::FromString(FString("Couldn't load skeleton data and/or atlas. Please ensure the " @@ -242,7 +242,7 @@ void USpineSkeletonDataAsset::LoadInfo() { } delete json; } else { - SkeletonBinary *binary = new (__FILE__, __LINE__) SkeletonBinary(&loader); + SkeletonBinary *binary = new (__FILE__, __LINE__) SkeletonBinary(loader); if (checkBinary((const char *) rawData.GetData(), (int) rawData.Num())) skeletonData = binary->readSkeletonData((const unsigned char *) rawData.GetData(), (int) rawData.Num()); if (!skeletonData) { @@ -283,7 +283,7 @@ SkeletonData *USpineSkeletonDataAsset::GetSkeletonData(Atlas *Atlas) { if (!skeletonData) { int dataLen = rawData.Num(); if (skeletonDataFileName.GetPlainNameString().Contains(TEXT(".json"))) { - SkeletonJson *json = new (__FILE__, __LINE__) SkeletonJson(Atlas); + SkeletonJson *json = new (__FILE__, __LINE__) SkeletonJson(*Atlas); if (checkJson((const char *) rawData.GetData())) skeletonData = json->readSkeletonData((const char *) rawData.GetData()); if (!skeletonData) { #if WITH_EDITORONLY_DATA @@ -297,7 +297,7 @@ SkeletonData *USpineSkeletonDataAsset::GetSkeletonData(Atlas *Atlas) { } delete json; } else { - SkeletonBinary *binary = new (__FILE__, __LINE__) SkeletonBinary(Atlas); + SkeletonBinary *binary = new (__FILE__, __LINE__) SkeletonBinary(*Atlas); if (checkBinary((const char *) rawData.GetData(), (int) rawData.Num())) skeletonData = binary->readSkeletonData((const unsigned char *) rawData.GetData(), (int) rawData.Num()); if (!skeletonData) { @@ -314,7 +314,7 @@ SkeletonData *USpineSkeletonDataAsset::GetSkeletonData(Atlas *Atlas) { } if (skeletonData) { - animationStateData = new (__FILE__, __LINE__) AnimationStateData(skeletonData); + animationStateData = new (__FILE__, __LINE__) AnimationStateData(*skeletonData); SetMixes(animationStateData); atlasToNativeData.Add(Atlas, {skeletonData, animationStateData}); } diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp index 3010518ee..55a58c70f 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp @@ -197,9 +197,9 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon float *attachmentUvs = nullptr; Slot *slot = Skeleton->getDrawOrder()[i]; - Attachment *attachment = slot->getPose().getAttachment(); + Attachment *attachment = slot->getAppliedPose().getAttachment(); - if (slot->getPose().getColor().a == 0 || !slot->getBone().isActive()) { + if (slot->getAppliedPose().getColor().a == 0 || !slot->getBone().isActive()) { clipper.clipEnd(*slot); continue; } @@ -271,7 +271,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon // to the correct skeleton data yet, we won't find any regions. // ignore regions for which we can't find a material UMaterialInstanceDynamic *material = nullptr; - int foundPageIndex = (int) (intptr_t) attachmentAtlasRegion->getPageIndex(); + int foundPageIndex = attachmentAtlasRegion->getPage() ? attachmentAtlasRegion->getPage()->index : -1; if (foundPageIndex == -1) { clipper.clipEnd(*slot); continue; @@ -316,10 +316,10 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon SetMaterial(meshSection, material); - uint8 r = static_cast(Skeleton->getColor().r * slot->getPose().getColor().r * attachmentColor.r * 255); - uint8 g = static_cast(Skeleton->getColor().g * slot->getPose().getColor().g * attachmentColor.g * 255); - uint8 b = static_cast(Skeleton->getColor().b * slot->getPose().getColor().b * attachmentColor.b * 255); - uint8 a = static_cast(Skeleton->getColor().a * slot->getPose().getColor().a * attachmentColor.a * 255); + uint8 r = static_cast(Skeleton->getColor().r * slot->getAppliedPose().getColor().r * attachmentColor.r * 255); + uint8 g = static_cast(Skeleton->getColor().g * slot->getAppliedPose().getColor().g * attachmentColor.g * 255); + uint8 b = static_cast(Skeleton->getColor().b * slot->getAppliedPose().getColor().b * attachmentColor.b * 255); + uint8 a = static_cast(Skeleton->getColor().a * slot->getAppliedPose().getColor().a * attachmentColor.a * 255); float *verticesPtr = attachmentVertices->buffer(); for (int j = 0; j < numVertices << 1; j += 2) { diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp index 6ee92cf23..129675eae 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp @@ -36,7 +36,7 @@ using namespace spine; -void callbackWidget(AnimationState *state, spine::EventType type, TrackEntry *entry, Event *event) { +void callbackWidget(AnimationState *state, spine::EventType type, TrackEntry *entry, Event *event, void *userData) { USpineWidget *component = (USpineWidget *) state->getRendererObject(); if (entry->getRendererObject()) { @@ -157,7 +157,7 @@ void USpineWidget::CheckState() { if (lastSpineAtlas != atlas) { needsUpdate = true; } - if (skeleton && skeleton->getData() != SkeletonData->GetSkeletonData(atlas)) { + if (skeleton && &skeleton->getData() != SkeletonData->GetSkeletonData(atlas)) { needsUpdate = true; } } @@ -169,13 +169,13 @@ void USpineWidget::CheckState() { if (Atlas && SkeletonData) { spine::SkeletonData *data = SkeletonData->GetSkeletonData(Atlas->GetAtlas()); if (data) { - skeleton = new (__FILE__, __LINE__) Skeleton(data); + skeleton = new (__FILE__, __LINE__) Skeleton(*data); AnimationStateData *stateData = SkeletonData->GetAnimationStateData(Atlas->GetAtlas()); - state = new (__FILE__, __LINE__) AnimationState(stateData); + state = new (__FILE__, __LINE__) AnimationState(*stateData); state->setRendererObject((void *) this); - state->setListener(callbackWidget); + state->setListener(callbackWidget, nullptr); trackEntries.Empty(); - skeleton->setToSetupPose(); + skeleton->setupPose(); skeleton->updateWorldTransform(Physics_Update); slateWidget->SetData(this); } @@ -214,7 +214,7 @@ void USpineWidget::FinishDestroy() { bool USpineWidget::SetSkin(const FString skinName) { CheckState(); if (skeleton) { - spine::Skin *skin = skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName)); + spine::Skin *skin = skeleton->getData().findSkin(TCHAR_TO_UTF8(*skinName)); if (!skin) return false; skeleton->setSkin(skin); bSkinInitialized = true; @@ -228,12 +228,12 @@ bool USpineWidget::SetSkins(UPARAM(ref) TArray &SkinNames) { if (skeleton) { spine::Skin *newSkin = new spine::Skin("__spine-ue3_custom_skin"); for (auto &skinName : SkinNames) { - spine::Skin *skin = skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName)); + spine::Skin *skin = skeleton->getData().findSkin(TCHAR_TO_UTF8(*skinName)); if (!skin) { delete newSkin; return false; } - newSkin->addSkin(skin); + newSkin->addSkin(*skin); } skeleton->setSkin(newSkin); bSkinInitialized = true; @@ -249,8 +249,8 @@ bool USpineWidget::SetSkins(UPARAM(ref) TArray &SkinNames) { void USpineWidget::GetSkins(TArray &Skins) { CheckState(); if (skeleton) { - for (size_t i = 0, n = skeleton->getData()->getSkins().size(); i < n; i++) { - Skins.Add(skeleton->getData()->getSkins()[i]->getName().buffer()); + for (size_t i = 0, n = skeleton->getData().getSkins().size(); i < n; i++) { + Skins.Add(skeleton->getData().getSkins()[i]->getName().buffer()); } } } @@ -258,7 +258,7 @@ void USpineWidget::GetSkins(TArray &Skins) { bool USpineWidget::HasSkin(const FString skinName) { CheckState(); if (skeleton) { - return skeleton->getData()->findSkin(TCHAR_TO_UTF8(*skinName)) != nullptr; + return skeleton->getData().findSkin(TCHAR_TO_UTF8(*skinName)) != nullptr; } return false; } @@ -286,17 +286,17 @@ void USpineWidget::UpdateWorldTransform() { void USpineWidget::SetToSetupPose() { CheckState(); - if (skeleton) skeleton->setToSetupPose(); + if (skeleton) skeleton->setupPose(); } void USpineWidget::SetBonesToSetupPose() { CheckState(); - if (skeleton) skeleton->setBonesToSetupPose(); + if (skeleton) skeleton->setupPoseBones(); } void USpineWidget::SetSlotsToSetupPose() { CheckState(); - if (skeleton) skeleton->setSlotsToSetupPose(); + if (skeleton) skeleton->setupPoseSlots(); } void USpineWidget::SetScaleX(float scaleX) { @@ -333,7 +333,7 @@ void USpineWidget::GetBones(TArray &Bones) { bool USpineWidget::HasBone(const FString BoneName) { CheckState(); if (skeleton) { - return skeleton->getData()->findBone(TCHAR_TO_UTF8(*BoneName)) != nullptr; + return skeleton->getData().findBone(TCHAR_TO_UTF8(*BoneName)) != nullptr; } return false; } @@ -346,9 +346,9 @@ FTransform USpineWidget::GetBoneTransform(const FString &BoneName) { FMatrix localTransform; localTransform.SetIdentity(); - localTransform.SetAxis(2, FVector(bone->getA(), 0, bone->getC())); - localTransform.SetAxis(0, FVector(bone->getB(), 0, bone->getD())); - localTransform.SetOrigin(FVector(bone->getWorldX(), 0, bone->getWorldY())); + localTransform.SetAxis(2, FVector(bone->getAppliedPose().getA(), 0, bone->getAppliedPose().getC())); + localTransform.SetAxis(0, FVector(bone->getAppliedPose().getB(), 0, bone->getAppliedPose().getD())); + localTransform.SetOrigin(FVector(bone->getAppliedPose().getWorldX(), 0, bone->getAppliedPose().getWorldY())); FTransform result; result.SetFromMatrix(localTransform); @@ -369,7 +369,7 @@ void USpineWidget::GetSlots(TArray &Slots) { bool USpineWidget::HasSlot(const FString SlotName) { CheckState(); if (skeleton) { - return skeleton->getData()->findSlot(TCHAR_TO_UTF8(*SlotName)) != nullptr; + return skeleton->getData().findSlot(TCHAR_TO_UTF8(*SlotName)) != nullptr; } return false; } @@ -379,7 +379,7 @@ void USpineWidget::SetSlotColor(const FString SlotName, const FColor SlotColor) if (skeleton) { spine::Slot *slot = skeleton->findSlot(TCHAR_TO_UTF8(*SlotName)); if (slot) { - slot->getColor().set(SlotColor.R / 255.f, SlotColor.G / 255.f, SlotColor.B / 255.f, SlotColor.A / 255.f); + slot->getPose().getColor().set(SlotColor.R / 255.f, SlotColor.G / 255.f, SlotColor.B / 255.f, SlotColor.A / 255.f); } } } @@ -387,8 +387,8 @@ void USpineWidget::SetSlotColor(const FString SlotName, const FColor SlotColor) void USpineWidget::GetAnimations(TArray &Animations) { CheckState(); if (skeleton) { - for (size_t i = 0, n = skeleton->getData()->getAnimations().size(); i < n; i++) { - Animations.Add(skeleton->getData()->getAnimations()[i]->getName().buffer()); + for (size_t i = 0, n = skeleton->getData().getAnimations().size(); i < n; i++) { + Animations.Add(skeleton->getData().getAnimations()[i]->getName().buffer()); } } } @@ -396,7 +396,7 @@ void USpineWidget::GetAnimations(TArray &Animations) { bool USpineWidget::HasAnimation(FString AnimationName) { CheckState(); if (skeleton) { - return skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*AnimationName)) != nullptr; + return skeleton->getData().findAnimation(TCHAR_TO_UTF8(*AnimationName)) != nullptr; } return false; } @@ -404,7 +404,7 @@ bool USpineWidget::HasAnimation(FString AnimationName) { float USpineWidget::GetAnimationDuration(FString AnimationName) { CheckState(); if (skeleton) { - spine::Animation *animation = skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*AnimationName)); + spine::Animation *animation = skeleton->getData().findAnimation(TCHAR_TO_UTF8(*AnimationName)); if (animation == nullptr) return 0; else @@ -421,9 +421,9 @@ void USpineWidget::SetPlaybackTime(float InPlaybackTime, bool bCallDelegates) { CheckState(); if (state && state->getCurrent(0)) { - spine::Animation *CurrentAnimation = state->getCurrent(0)->getAnimation(); + spine::Animation &CurrentAnimation = state->getCurrent(0)->getAnimation(); const float CurrentTime = state->getCurrent(0)->getTrackTime(); - InPlaybackTime = FMath::Clamp(InPlaybackTime, 0.0f, CurrentAnimation->getDuration()); + InPlaybackTime = FMath::Clamp(InPlaybackTime, 0.0f, CurrentAnimation.getDuration()); const float DeltaTime = InPlaybackTime - CurrentTime; state->update(DeltaTime); state->apply(*skeleton); @@ -452,12 +452,12 @@ float USpineWidget::GetTimeScale() { UTrackEntry *USpineWidget::SetAnimation(int trackIndex, FString animationName, bool loop) { CheckState(); - if (state && skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*animationName))) { + if (state && skeleton->getData().findAnimation(TCHAR_TO_UTF8(*animationName))) { state->disableQueue(); - TrackEntry *entry = state->setAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop); + TrackEntry &entry = state->setAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop); state->enableQueue(); UTrackEntry *uEntry = NewObject(); - uEntry->SetTrackEntry(entry); + uEntry->SetTrackEntry(&entry); trackEntries.Add(uEntry); return uEntry; } else @@ -466,12 +466,12 @@ UTrackEntry *USpineWidget::SetAnimation(int trackIndex, FString animationName, b UTrackEntry *USpineWidget::AddAnimation(int trackIndex, FString animationName, bool loop, float delay) { CheckState(); - if (state && skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*animationName))) { + if (state && skeleton->getData().findAnimation(TCHAR_TO_UTF8(*animationName))) { state->disableQueue(); - TrackEntry *entry = state->addAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop, delay); + TrackEntry &entry = state->addAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop, delay); state->enableQueue(); UTrackEntry *uEntry = NewObject(); - uEntry->SetTrackEntry(entry); + uEntry->SetTrackEntry(&entry); trackEntries.Add(uEntry); return uEntry; } else @@ -481,9 +481,9 @@ UTrackEntry *USpineWidget::AddAnimation(int trackIndex, FString animationName, b UTrackEntry *USpineWidget::SetEmptyAnimation(int trackIndex, float mixDuration) { CheckState(); if (state) { - TrackEntry *entry = state->setEmptyAnimation(trackIndex, mixDuration); + TrackEntry &entry = state->setEmptyAnimation(trackIndex, mixDuration); UTrackEntry *uEntry = NewObject(); - uEntry->SetTrackEntry(entry); + uEntry->SetTrackEntry(&entry); trackEntries.Add(uEntry); return uEntry; } else @@ -493,9 +493,9 @@ UTrackEntry *USpineWidget::SetEmptyAnimation(int trackIndex, float mixDuration) UTrackEntry *USpineWidget::AddEmptyAnimation(int trackIndex, float mixDuration, float delay) { CheckState(); if (state) { - TrackEntry *entry = state->addEmptyAnimation(trackIndex, mixDuration, delay); + TrackEntry &entry = state->addEmptyAnimation(trackIndex, mixDuration, delay); UTrackEntry *uEntry = NewObject(); - uEntry->SetTrackEntry(entry); + uEntry->SetTrackEntry(&entry); trackEntries.Add(uEntry); return uEntry; } else @@ -549,9 +549,9 @@ void USpineWidget::PhysicsRotate(float x, float y, float degrees) { void USpineWidget::ResetPhysicsConstraints() { CheckState(); if (skeleton) { - Vector &constraints = skeleton->getPhysicsConstraints(); + Array &constraints = skeleton->getPhysicsConstraints(); for (int i = 0, n = (int) constraints.size(); i < n; i++) { - constraints[i]->reset(); + constraints[i]->reset(*skeleton); } } }