[cpp] Switch AnimationState.propertyIDs to a hash map.

This commit is contained in:
badlogic 2019-09-26 16:46:21 +02:00
parent 2c0881da61
commit 3821389cd7
4 changed files with 13 additions and 6 deletions

View File

@ -393,7 +393,7 @@ namespace spine {
Vector<Event*> _events;
EventQueue* _queue;
Vector<int> _propertyIDs;
HashMap<int, bool> _propertyIDs;
bool _animationsChanged;
AnimationStateListener _listener;

View File

@ -30,6 +30,7 @@
#ifndef Spine_Extension_h
#define Spine_Extension_h
#include <stdlib.h>
#include <spine/dll.h>

View File

@ -89,11 +89,17 @@ public:
}
~HashMap() {
clear();
}
void clear() {
for (Entry *entry = _head; entry != NULL;) {
Entry* next = entry->next;
delete entry;
entry = next;
}
_head = NULL;
_size = 0;
}
size_t size() {

View File

@ -976,7 +976,7 @@ void AnimationState::computeHold(TrackEntry *entry) {
if (to != NULL && to->_holdPrevious) {
for (size_t i = 0; i < timelinesCount; i++) {
int id = timelines[i]->getPropertyId();
if (!_propertyIDs.contains(id)) _propertyIDs.add(id);
if (!_propertyIDs.containsKey(id)) _propertyIDs.put(id, true);
timelineMode[i] = Hold;
}
return;
@ -988,10 +988,10 @@ void AnimationState::computeHold(TrackEntry *entry) {
for (; i < timelinesCount; ++i) {
Timeline *timeline = timelines[i];
int id = timeline->getPropertyId();
if (_propertyIDs.contains(id)) {
if (_propertyIDs.containsKey(id)) {
timelineMode[i] = Subsequent;
} else {
_propertyIDs.add(id);
_propertyIDs.put(id, true);
if (to == NULL || timeline->getRTTI().isExactly(AttachmentTimeline::rtti) ||
timeline->getRTTI().isExactly(DrawOrderTimeline::rtti) ||
@ -1022,8 +1022,8 @@ void AnimationState::computeNotLast(TrackEntry *entry) {
for (size_t i = 0; i < timelinesCount; i++) {
if (timelines[i]->getRTTI().isExactly(AttachmentTimeline::rtti)) {
AttachmentTimeline *timeline = static_cast<AttachmentTimeline *>(timelines[i]);
if (!_propertyIDs.contains(timeline->getSlotIndex()))
_propertyIDs.add(timeline->getSlotIndex());
if (!_propertyIDs.containsKey(timeline->getSlotIndex()))
_propertyIDs.put(timeline->getSlotIndex(), true);
else
timelineMode[i] |= NotLast;
}