Prechádzať zdrojové kódy

[ue4] Need to temporarily disable queue draining of animation state when setting or adding new animations. Closes #1037

badlogic 7 rokov pred
rodič
commit
33a00182ff

+ 10 - 0
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp

@@ -150,10 +150,18 @@ float USpineSkeletonAnimationComponent::GetTimeScale() {
 	return 1;
 }
 
+// we need to disable the queue when setting or adding animations, see #1037
+extern "C" {
+	void _spAnimationState_disableQueue(spAnimationState* state);
+	void _spAnimationState_enableQueue(spAnimationState* state);
+}
+
 UTrackEntry* USpineSkeletonAnimationComponent::SetAnimation (int trackIndex, FString animationName, bool loop) {
 	CheckState();
 	if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
+		_spAnimationState_disableQueue(state);
 		spTrackEntry* entry = spAnimationState_setAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0);
+		_spAnimationState_enableQueue(state);
 		UTrackEntry* uEntry = NewObject<UTrackEntry>();
 		uEntry->SetTrackEntry(entry);
 		trackEntries.Add(uEntry);
@@ -165,7 +173,9 @@ UTrackEntry* USpineSkeletonAnimationComponent::SetAnimation (int trackIndex, FSt
 UTrackEntry* USpineSkeletonAnimationComponent::AddAnimation (int trackIndex, FString animationName, bool loop, float delay) {
 	CheckState();
 	if (state && spSkeletonData_findAnimation(skeleton->data, TCHAR_TO_UTF8(*animationName))) {
+		_spAnimationState_disableQueue(state);
 		spTrackEntry* entry = spAnimationState_addAnimationByName(state, trackIndex, TCHAR_TO_UTF8(*animationName), loop ? 1 : 0, delay);		
+		_spAnimationState_enableQueue(state);
 		UTrackEntry* uEntry = NewObject<UTrackEntry>();
 		uEntry->SetTrackEntry(entry);
 		trackEntries.Add(uEntry);