diff --git a/CHANGELOG.md b/CHANGELOG.md index daa028312..acac4b6ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,7 @@ - **Breaking**: Starting with Unreal Engine 5.3 imported `.skel`/`.json` and `.atlas` files in the same folder must NOT have a common prefix. E.g. `skeleton.json` and `skeleton.atlas` will not work. Make sure to rename at least one of the two files so there is no prefix collision, e.g. `skeleton-data.json` and `skeleton.atlas`. - Added compatibility with UE 5.3 - Added more example maps +- Added blueprint-callable methods `PhysicsTranslate()`, `PhysicsRotate()` and `ResetPhysicsConstraints()` (which will reset all physics constraints in the skeleton) to `SpineSkeletonComponent` and `SpineWidget`. ### Godot diff --git a/spine-flutter/lib/assets/libspine_flutter.wasm b/spine-flutter/lib/assets/libspine_flutter.wasm index cffc6246b..89b0c594a 100755 Binary files a/spine-flutter/lib/assets/libspine_flutter.wasm and b/spine-flutter/lib/assets/libspine_flutter.wasm differ diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp index 58aabe0d9..a48e786d3 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonComponent.cpp @@ -287,6 +287,30 @@ float USpineSkeletonComponent::GetAnimationDuration(FString AnimationName) { return 0; } +void USpineSkeletonComponent::PhysicsTranslate(float x, float y) { + CheckState(); + if (skeleton) { + skeleton->physicsTranslate(x, y); + } +} + +void USpineSkeletonComponent::PhysicsRotate(float x, float y, float degrees) { + CheckState(); + if (skeleton) { + skeleton->physicsRotate(x, y, degrees); + } +} + +void USpineSkeletonComponent::ResetPhysicsConstraints() { + CheckState(); + if (skeleton) { + Vector &constraints = skeleton->getPhysicsConstraints(); + for (int i = 0, n = (int) constraints.size(); i < n; i++) { + constraints[i]->reset(); + } + } +} + void USpineSkeletonComponent::BeginPlay() { Super::BeginPlay(); } diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp index dcdaac900..a6034adf4 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp @@ -524,3 +524,27 @@ void USpineWidget::ClearTrack(int trackIndex) { state->clearTrack(trackIndex); } } + +void USpineWidget::PhysicsTranslate(float x, float y) { + CheckState(); + if (skeleton) { + skeleton->physicsTranslate(x, y); + } +} + +void USpineWidget::PhysicsRotate(float x, float y, float degrees) { + CheckState(); + if (skeleton) { + skeleton->physicsRotate(x, y, degrees); + } +} + +void USpineWidget::ResetPhysicsConstraints() { + CheckState(); + if (skeleton) { + Vector &constraints = skeleton->getPhysicsConstraints(); + for (int i = 0, n = (int) constraints.size(); i < n; i++) { + constraints[i]->reset(); + } + } +} \ No newline at end of file diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h index c040110ce..94dcf9eef 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonComponent.h @@ -127,6 +127,15 @@ public: UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") float GetAnimationDuration(FString AnimationName); + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + void PhysicsTranslate(float x, float y); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + void PhysicsRotate(float x, float y, float degrees); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + void ResetPhysicsConstraints(); + UPROPERTY(BlueprintAssignable, Category = "Components|Spine|Skeleton") FSpineBeforeUpdateWorldTransformDelegate BeforeUpdateWorldTransform; diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineWidget.h b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineWidget.h index c02339638..0019a6eea 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineWidget.h +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineWidget.h @@ -153,6 +153,15 @@ public: UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") float GetAnimationDuration(FString AnimationName); + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + void PhysicsTranslate(float x, float y); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + void PhysicsRotate(float x, float y, float degrees); + + UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") + void ResetPhysicsConstraints(); + UPROPERTY(BlueprintAssignable, Category = "Components|Spine|Skeleton") FSpineWidgetBeforeUpdateWorldTransformDelegate BeforeUpdateWorldTransform;