[ue] Add ResetPhysicsConstraints() to SpineSkeletonComponent and SpineWidget, closes #2615

This commit is contained in:
Mario Zechner 2024-08-30 13:39:15 +02:00
parent 4038bc9ba1
commit c85000b5f8
6 changed files with 67 additions and 0 deletions

View File

@ -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

View File

@ -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<PhysicsConstraint *> &constraints = skeleton->getPhysicsConstraints();
for (int i = 0, n = (int) constraints.size(); i < n; i++) {
constraints[i]->reset();
}
}
}
void USpineSkeletonComponent::BeginPlay() {
Super::BeginPlay();
}

View File

@ -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<PhysicsConstraint *> &constraints = skeleton->getPhysicsConstraints();
for (int i = 0, n = (int) constraints.size(); i < n; i++) {
constraints[i]->reset();
}
}
}

View File

@ -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;

View File

@ -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;