diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp index cb41df4c0..ac21f0ab7 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp @@ -1144,7 +1144,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) { TransformConstraintData *constraint = skeletonData->findTransformConstraint(constraintMap->_name); int constraintIndex = skeletonData->_transformConstraints.indexOf(constraint); TransformConstraintTimeline *timeline = new (__FILE__, __LINE__) TransformConstraintTimeline( - constraintMap->_size, constraintMap->_size << 2, constraintIndex); + constraintMap->_size, constraintMap->_size * 6, constraintIndex); float time = Json::getFloat(keyMap, "time", 0); float mixRotate = Json::getFloat(keyMap, "mixRotate", 1); diff --git a/spine-sfml/cpp/example/testbed.cpp b/spine-sfml/cpp/example/testbed.cpp index 080e509d2..a883ba146 100644 --- a/spine-sfml/cpp/example/testbed.cpp +++ b/spine-sfml/cpp/example/testbed.cpp @@ -33,27 +33,78 @@ using namespace spine; +class NullTextureLoader : public TextureLoader { +public: + virtual void load(AtlasPage &page, const String &path) {} + + virtual void unload(void *texture) {} +}; + +class NullAttachmentLoader : public AttachmentLoader { + virtual RegionAttachment *newRegionAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence) { + return new (__FILE__, __LINE__) RegionAttachment(name); + } + + virtual MeshAttachment *newMeshAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence) { + return new (__FILE__, __LINE__) MeshAttachment(name); + } + + virtual BoundingBoxAttachment *newBoundingBoxAttachment(Skin &skin, const String &name) { + return new (__FILE__, __LINE__) BoundingBoxAttachment(name); + } + + virtual PathAttachment *newPathAttachment(Skin &skin, const String &name) { + return new (__FILE__, __LINE__) PathAttachment(name); + } + + virtual PointAttachment *newPointAttachment(Skin &skin, const String &name) { + return new (__FILE__, __LINE__) PointAttachment(name); + } + + virtual ClippingAttachment *newClippingAttachment(Skin &skin, const String &name) { + return new (__FILE__, __LINE__) ClippingAttachment(name); + } + + virtual void configureAttachment(Attachment *attachment) { + } +}; + int main(void) { - String atlasFile("data/spineboy-pma.atlas"); - String skeletonFile("data/spineboy-pro.skel"); + String atlasFile(""); + String skeletonFile("/Users/badlogic/Downloads/catsanddogs2.json"); + String animation = ""; + float scale = 0.6f; SFMLTextureLoader textureLoader; - Atlas *atlas = new Atlas(atlasFile, &textureLoader); + NullAttachmentLoader nullLoader; + Atlas *atlas = atlasFile.length() == 0 ? nullptr : new Atlas(atlasFile, &textureLoader); SkeletonData *skeletonData = nullptr; - if (strncmp(skeletonFile.buffer(), ".skel", skeletonFile.length()) > 0) { - SkeletonBinary binary(atlas); - binary.setScale(scale); - skeletonData = binary.readSkeletonDataFile(skeletonFile); + if (strnstr(skeletonFile.buffer(), ".skel", skeletonFile.length()) != nullptr) { + SkeletonBinary *binary = nullptr; + if (atlas) { + binary = new SkeletonBinary(atlas); + } else { + binary = new SkeletonBinary(&nullLoader); + } + binary->setScale(scale); + skeletonData = binary->readSkeletonDataFile(skeletonFile); + delete binary; } else { - SkeletonJson json(atlas); - json.setScale(scale); - skeletonData = json.readSkeletonDataFile(skeletonFile); + SkeletonJson *json = nullptr; + if (atlas) { + json = new SkeletonJson(atlas); + } else { + json = new SkeletonJson(&nullLoader); + } + json->setScale(scale); + skeletonData = json->readSkeletonDataFile(skeletonFile); + delete json; } AnimationStateData stateData(skeletonData); SkeletonDrawable drawable(skeletonData, &stateData); drawable.skeleton->setPosition(320, 590); - drawable.state->setAnimation(0, "walk", true); + if (animation.length() > 0) drawable.state->setAnimation(0, animation, true); sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - testbed"); window.setFramerateLimit(60); diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineAtlasAsset.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineAtlasAsset.cpp index d80d1e11a..c1759eed7 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineAtlasAsset.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineAtlasAsset.cpp @@ -58,13 +58,13 @@ void USpineAtlasAsset::Serialize(FArchive &Ar) { importData = NewObject(this, TEXT("AssetImportData")); } -void USpineAtlasAsset::PostLoadAssetRegistryTags(const FAssetData& InAssetData, - TArray& OutTagsAndValuesToUpdate) const { +void USpineAtlasAsset::PostLoadAssetRegistryTags(const FAssetData &InAssetData, + TArray &OutTagsAndValuesToUpdate) const { // FIXME: this is a massive hack. It will set the PackageFlags of the FAssetData // in the AssetRegistry to PKG_FilterEditorOnly so the content browser displays it. // This is necessary in UE 5.3 due to a regression in ContentBrowserAssetDataCore::IsPrimaryAsset // See https://github.com/EsotericSoftware/spine-runtimes/issues/2368 - FAssetData& MutableAssetData = const_cast(InAssetData); + FAssetData &MutableAssetData = const_cast(InAssetData); // MutableAssetData.PackageFlags = EPackageFlags::PKG_FilterEditorOnly; UObject::PostLoadAssetRegistryTags(MutableAssetData, OutTagsAndValuesToUpdate); } diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp index d95094bb9..55e87afab 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp @@ -81,13 +81,13 @@ void USpineSkeletonDataAsset::Serialize(FArchive &Ar) { } -void USpineSkeletonDataAsset::PostLoadAssetRegistryTags(const FAssetData& InAssetData, - // FIXME: this is a massive hack. It will set the PackageFlags of the FAssetData - // in the AssetRegistry to PKG_FilterEditorOnly so the content browser displays it. - // This is necessary in UE 5.3 due to a regression in ContentBrowserAssetDataCore::IsPrimaryAsset - // See https://github.com/EsotericSoftware/spine-runtimes/issues/2368 - TArray& OutTagsAndValuesToUpdate) const { - FAssetData& MutableAssetData = const_cast(InAssetData); +void USpineSkeletonDataAsset::PostLoadAssetRegistryTags(const FAssetData &InAssetData, + // FIXME: this is a massive hack. It will set the PackageFlags of the FAssetData + // in the AssetRegistry to PKG_FilterEditorOnly so the content browser displays it. + // This is necessary in UE 5.3 due to a regression in ContentBrowserAssetDataCore::IsPrimaryAsset + // See https://github.com/EsotericSoftware/spine-runtimes/issues/2368 + TArray &OutTagsAndValuesToUpdate) const { + FAssetData &MutableAssetData = const_cast(InAssetData); // MutableAssetData.PackageFlags = EPackageFlags::PKG_FilterEditorOnly; UObject::PostLoadAssetRegistryTags(MutableAssetData, OutTagsAndValuesToUpdate); } diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineAtlasAsset.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineAtlasAsset.h index b6a22a808..8b0500ac9 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineAtlasAsset.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineAtlasAsset.h @@ -71,6 +71,6 @@ protected: virtual void PostInitProperties() override; virtual void Serialize(FArchive &Ar) override; - virtual void PostLoadAssetRegistryTags(const FAssetData& InAssetData, TArray& OutTagsAndValuesToUpdate) const override; + virtual void PostLoadAssetRegistryTags(const FAssetData &InAssetData, TArray &OutTagsAndValuesToUpdate) const override; #endif }; diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonDataAsset.h b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonDataAsset.h index 407c521e9..af9ade5b0 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonDataAsset.h +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonDataAsset.h @@ -116,7 +116,7 @@ protected: virtual void PostInitProperties() override; virtual void GetAssetRegistryTags(TArray &OutTags) const override; virtual void Serialize(FArchive &Ar) override; - virtual void PostLoadAssetRegistryTags(const FAssetData& InAssetData, TArray& OutTagsAndValuesToUpdate) const override; + virtual void PostLoadAssetRegistryTags(const FAssetData &InAssetData, TArray &OutTagsAndValuesToUpdate) const override; #endif void LoadInfo();