Jelajahi Sumber

[c][cpp] Fix AnimationState::clearNext()

badlogic 4 tahun lalu
induk
melakukan
30702a3bff

+ 1 - 0
.gitignore

@@ -143,3 +143,4 @@ spine-ue4/SpineUE4.VC.VC.opendb
 .gradle/
 .gradle/
 *.iml
 *.iml
 */out/
 */out/
+cmake-build-debug-visual-studio

+ 1 - 1
CMakeLists.txt

@@ -33,5 +33,5 @@ if((${SPINE_COCOS2D_X}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-cocos2dx"
 	add_subdirectory(spine-cocos2dx)
 	add_subdirectory(spine-cocos2dx)
 endif()
 endif()
 
 
-add_subdirectory(spine-c/spine-c-unit-tests)
+# add_subdirectory(spine-c/spine-c-unit-tests)
 add_subdirectory(spine-cpp/spine-cpp-unit-tests)
 add_subdirectory(spine-cpp/spine-cpp-unit-tests)

+ 2 - 0
spine-c/spine-c-unit-tests/CMakeLists.txt

@@ -3,7 +3,9 @@ project(spine_unit_test)
 
 
 set(CMAKE_INSTALL_PREFIX "./")
 set(CMAKE_INSTALL_PREFIX "./")
 set(CMAKE_VERBOSE_MAKEFILE ON)
 set(CMAKE_VERBOSE_MAKEFILE ON)
+if(MSVC)
 set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-rtti -DKANJI_MEMTRACE -DUSE_CPP11_MUTEX")
 set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-rtti -DKANJI_MEMTRACE -DUSE_CPP11_MUTEX")
+endif()
 
 
 
 
 #########################################################
 #########################################################

+ 2 - 0
spine-c/spine-c/include/spine/AnimationState.h

@@ -143,6 +143,8 @@ SP_API float spTrackEntry_getAnimationTime(spTrackEntry *entry);
 
 
 SP_API float spTrackEntry_getTrackComplete(spTrackEntry *entry);
 SP_API float spTrackEntry_getTrackComplete(spTrackEntry *entry);
 
 
+SP_API void spAnimationState_clearNext(spAnimationState *self, spTrackEntry *entry);
+
 /** Use this to dispose static memory before your app exits to appease your memory leak detector*/
 /** Use this to dispose static memory before your app exits to appease your memory leak detector*/
 SP_API void spAnimationState_disposeStatics();
 SP_API void spAnimationState_disposeStatics();
 
 

+ 5 - 11
spine-c/spine-c/src/spine/AnimationState.c

@@ -78,8 +78,6 @@ spTrackEntry *
 _spAnimationState_trackEntry(spAnimationState *self, int trackIndex, spAnimation *animation, int /*boolean*/ loop,
 _spAnimationState_trackEntry(spAnimationState *self, int trackIndex, spAnimation *animation, int /*boolean*/ loop,
 							 spTrackEntry *last);
 							 spTrackEntry *last);
 
 
-void _spAnimationState_disposeNext(spAnimationState *self, spTrackEntry *entry);
-
 void _spAnimationState_animationsChanged(spAnimationState *self);
 void _spAnimationState_animationsChanged(spAnimationState *self);
 
 
 float *_spAnimationState_resizeTimelinesRotation(spTrackEntry *entry, int newSize);
 float *_spAnimationState_resizeTimelinesRotation(spTrackEntry *entry, int newSize);
@@ -321,7 +319,7 @@ void spAnimationState_update(spAnimationState *self, float delta) {
 			if (current->trackLast >= current->trackEnd && current->mixingFrom == 0) {
 			if (current->trackLast >= current->trackEnd && current->mixingFrom == 0) {
 				self->tracks[i] = 0;
 				self->tracks[i] = 0;
 				_spEventQueue_end(internal->queue, current);
 				_spEventQueue_end(internal->queue, current);
-				_spAnimationState_disposeNext(self, current);
+				spAnimationState_clearNext(self, current);
 				continue;
 				continue;
 			}
 			}
 		}
 		}
@@ -742,10 +740,6 @@ void _spAnimationState_queueEvents(spAnimationState *self, spTrackEntry *entry,
 	}
 	}
 }
 }
 
 
-void spAnimationState_clearNext(spTrackEntry *entry) {
-	_spAnimationState_disposeTrackEntry(entry);
-}
-
 void spAnimationState_clearTracks(spAnimationState *self) {
 void spAnimationState_clearTracks(spAnimationState *self) {
 	_spAnimationState *internal = SUB_CAST(_spAnimationState, self);
 	_spAnimationState *internal = SUB_CAST(_spAnimationState, self);
 	int i, n, oldDrainDisabled;
 	int i, n, oldDrainDisabled;
@@ -770,7 +764,7 @@ void spAnimationState_clearTrack(spAnimationState *self, int trackIndex) {
 
 
 	_spEventQueue_end(internal->queue, current);
 	_spEventQueue_end(internal->queue, current);
 
 
-	_spAnimationState_disposeNext(self, current);
+    spAnimationState_clearNext(self, current);
 
 
 	entry = current;
 	entry = current;
 	while (1) {
 	while (1) {
@@ -827,11 +821,11 @@ spAnimationState_setAnimation(spAnimationState *self, int trackIndex, spAnimatio
 			self->tracks[trackIndex] = current->mixingFrom;
 			self->tracks[trackIndex] = current->mixingFrom;
 			_spEventQueue_interrupt(internal->queue, current);
 			_spEventQueue_interrupt(internal->queue, current);
 			_spEventQueue_end(internal->queue, current);
 			_spEventQueue_end(internal->queue, current);
-			_spAnimationState_disposeNext(self, current);
+            spAnimationState_clearNext(self, current);
 			current = current->mixingFrom;
 			current = current->mixingFrom;
 			interrupt = 0;
 			interrupt = 0;
 		} else
 		} else
-			_spAnimationState_disposeNext(self, current);
+            spAnimationState_clearNext(self, current);
 	}
 	}
 	entry = _spAnimationState_trackEntry(self, trackIndex, animation, loop, current);
 	entry = _spAnimationState_trackEntry(self, trackIndex, animation, loop, current);
 	_spAnimationState_setCurrent(self, trackIndex, entry, interrupt);
 	_spAnimationState_setCurrent(self, trackIndex, entry, interrupt);
@@ -957,7 +951,7 @@ _spAnimationState_trackEntry(spAnimationState *self, int trackIndex, spAnimation
 	return entry;
 	return entry;
 }
 }
 
 
-void _spAnimationState_disposeNext(spAnimationState *self, spTrackEntry *entry) {
+void spAnimationState_clearNext(spAnimationState *self, spTrackEntry *entry) {
 	_spAnimationState *internal = SUB_CAST(_spAnimationState, self);
 	_spAnimationState *internal = SUB_CAST(_spAnimationState, self);
 	spTrackEntry *next = entry->next;
 	spTrackEntry *next = entry->next;
 	while (next) {
 	while (next) {

+ 0 - 6
spine-c/spine-c/src/spine/Atlas.c

@@ -79,12 +79,6 @@ void spKeyValueArray_addAllValues(spKeyValueArray *self, spKeyValue *values, int
 	for (; i < n; i++) { spKeyValueArray_add(self, values[i]); }
 	for (; i < n; i++) { spKeyValueArray_add(self, values[i]); }
 }
 }
 
 
-void spKeyValueArray_removeAt(spKeyValueArray *self, int index) {
-	self->size--;
-	__builtin___memmove_chk(self->items + index, self->items + index + 1, sizeof(spKeyValue) * (self->size - index),
-							__builtin_object_size(self->items + index, 0));
-}
-
 int spKeyValueArray_contains(spKeyValueArray *self, spKeyValue value) {
 int spKeyValueArray_contains(spKeyValueArray *self, spKeyValue value) {
 	spKeyValue *items = self->items;
 	spKeyValue *items = self->items;
 	int i, n;
 	int i, n;

+ 0 - 3
spine-cpp/spine-cpp/include/spine/AnimationState.h

@@ -480,9 +480,6 @@ namespace spine {
 		/// @param last May be NULL.
 		/// @param last May be NULL.
 		TrackEntry *newTrackEntry(size_t trackIndex, Animation *animation, bool loop, TrackEntry *last);
 		TrackEntry *newTrackEntry(size_t trackIndex, Animation *animation, bool loop, TrackEntry *last);
 
 
-		/// Dispose all track entries queued after the given TrackEntry.
-		void disposeNext(TrackEntry *entry);
-
 		void animationsChanged();
 		void animationsChanged();
 
 
 		void computeHold(TrackEntry *entry);
 		void computeHold(TrackEntry *entry);

+ 5 - 9
spine-cpp/spine-cpp/src/spine/AnimationState.cpp

@@ -383,7 +383,7 @@ void AnimationState::update(float delta) {
 			_tracks[i] = NULL;
 			_tracks[i] = NULL;
 
 
 			_queue->end(currentP);
 			_queue->end(currentP);
-			disposeNext(currentP);
+			clearNext(currentP);
 			continue;
 			continue;
 		}
 		}
 
 
@@ -513,7 +513,7 @@ void AnimationState::clearTrack(size_t trackIndex) {
 
 
 	_queue->end(current);
 	_queue->end(current);
 
 
-	disposeNext(current);
+    clearNext(current);
 
 
 	TrackEntry *entry = current;
 	TrackEntry *entry = current;
 	while (true) {
 	while (true) {
@@ -548,11 +548,11 @@ TrackEntry *AnimationState::setAnimation(size_t trackIndex, Animation *animation
 			_tracks[trackIndex] = current->_mixingFrom;
 			_tracks[trackIndex] = current->_mixingFrom;
 			_queue->interrupt(current);
 			_queue->interrupt(current);
 			_queue->end(current);
 			_queue->end(current);
-			disposeNext(current);
+            clearNext(current);
 			current = current->_mixingFrom;
 			current = current->_mixingFrom;
 			interrupt = false;
 			interrupt = false;
 		} else {
 		} else {
-			disposeNext(current);
+            clearNext(current);
 		}
 		}
 	}
 	}
 
 
@@ -911,10 +911,6 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
 	}
 	}
 }
 }
 
 
-void AnimationState::clearNext(TrackEntry *entry) {
-	disposeNext(entry->_next);
-}
-
 void AnimationState::setCurrent(size_t index, TrackEntry *current, bool interrupt) {
 void AnimationState::setCurrent(size_t index, TrackEntry *current, bool interrupt) {
 	TrackEntry *from = expandToIndex(index);
 	TrackEntry *from = expandToIndex(index);
 	_tracks[index] = current;
 	_tracks[index] = current;
@@ -979,7 +975,7 @@ TrackEntry *AnimationState::newTrackEntry(size_t trackIndex, Animation *animatio
 	return entryP;
 	return entryP;
 }
 }
 
 
-void AnimationState::disposeNext(TrackEntry *entry) {
+void AnimationState::clearNext(TrackEntry *entry) {
 	TrackEntry *next = entry->_next;
 	TrackEntry *next = entry->_next;
 	while (next != NULL) {
 	while (next != NULL) {
 		_queue->dispose(next);
 		_queue->dispose(next);