-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix spine::Animation & spine::Timeline can not release normally
- Loading branch information
1 parent
486c562
commit fa73743
Showing
18 changed files
with
223 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
native/cocos/editor-support/spine-creator-support/SpineAnimation.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
#include "SpineAnimation.h" | ||
|
||
using namespace spine; | ||
|
||
spine::Vector<Timeline*> convertAndUseVector(const std::vector<std::shared_ptr<Timeline>>& stdVec) { | ||
spine::Vector<Timeline*> spineVec; | ||
|
||
for (const auto& element : stdVec) { | ||
spineVec.add(element.get()); | ||
} | ||
|
||
return spineVec; | ||
} | ||
|
||
SpineAnimation::SpineAnimation(const String& name, std::vector<std::shared_ptr<Timeline>> timelines, float duration) : Animation(name, convertAndUseVector(timelines), duration) { | ||
_vecTimelines = timelines; | ||
} | ||
|
||
SpineAnimation::~SpineAnimation() { | ||
_vecTimelines.clear(); | ||
auto& timelines = getTimelines(); | ||
timelines.clear(); | ||
} |
19 changes: 19 additions & 0 deletions
19
native/cocos/editor-support/spine-creator-support/SpineAnimation.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <spine/Animation.h> | ||
#include <vector> | ||
#include <memory> | ||
|
||
namespace spine { | ||
|
||
class SpineAnimation : public Animation { | ||
public: | ||
SpineAnimation(const String &name, std::vector<std::shared_ptr<Timeline>> timelines, float duration); | ||
|
||
~SpineAnimation(); | ||
|
||
private: | ||
std::vector<std::shared_ptr<Timeline>> _vecTimelines; | ||
}; | ||
|
||
} // namespace spine |
20 changes: 20 additions & 0 deletions
20
native/cocos/editor-support/spine-creator-support/SpineAnimationState.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
#include "SpineAnimationState.h" | ||
|
||
using namespace spine; | ||
|
||
SpineAnimationState::SpineAnimationState(AnimationStateData* data) : AnimationState(data) { | ||
|
||
} | ||
|
||
SpineAnimationState::~SpineAnimationState() { | ||
_vecAnimations.clear(); | ||
} | ||
|
||
TrackEntry* SpineAnimationState::addAnimation(size_t trackIndex, std::shared_ptr<Animation> animation, bool loop, float delay) { | ||
_vecAnimations.push_back(animation); | ||
return AnimationState::addAnimation(trackIndex, animation.get(), loop, delay); | ||
} | ||
|
||
|
||
|
53 changes: 53 additions & 0 deletions
53
native/cocos/editor-support/spine-creator-support/SpineAnimationState.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/****************************************************************************** | ||
* Spine Runtimes License Agreement | ||
* Last updated January 1, 2020. Replaces all prior versions. | ||
* | ||
* Copyright (c) 2013-2020, Esoteric Software LLC | ||
* | ||
* Integration of the Spine Runtimes into software or otherwise creating | ||
* derivative works of the Spine Runtimes is permitted under the terms and | ||
* conditions of Section 2 of the Spine Editor License Agreement: | ||
* http://esotericsoftware.com/spine-editor-license | ||
* | ||
* Otherwise, it is permitted to integrate the Spine Runtimes into software | ||
* or otherwise create derivative works of the Spine Runtimes (collectively, | ||
* "Products"), provided that each user of the Products must obtain their own | ||
* Spine Editor license and redistribution of the Products in any form must | ||
* include this license and copyright notice. | ||
* | ||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY | ||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, | ||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND | ||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <spine/AnimationState.h> | ||
#include "spine/Animation.h" | ||
#include<vector> | ||
#include<memory> | ||
|
||
namespace spine { | ||
|
||
|
||
class SP_API SpineAnimationState : public AnimationState { | ||
|
||
public: | ||
explicit SpineAnimationState(AnimationStateData* data); | ||
|
||
~SpineAnimationState(); | ||
|
||
TrackEntry* addAnimation(size_t trackIndex, std::shared_ptr<Animation> animation, bool loop, float delay); | ||
|
||
private: | ||
std::vector<std::shared_ptr<Animation>> _vecAnimations; | ||
}; | ||
} // namespace spine | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
native/cocos/editor-support/spine-wasm/SpineAnimationState.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
#include "SpineAnimationState.h" | ||
|
||
using namespace spine; | ||
|
||
SpineAnimationState::SpineAnimationState(AnimationStateData* data) : AnimationState(data) { | ||
} | ||
|
||
SpineAnimationState::~SpineAnimationState() { | ||
_mapAnimations.clear(); | ||
} | ||
|
||
TrackEntry* SpineAnimationState::addAnimation(size_t trackIndex, Animation* animation, bool loop, float delay) { | ||
if (_mapAnimations.count(animation) == 0) { | ||
_mapAnimations[animation] = std::shared_ptr<Animation>(animation); | ||
} | ||
return AnimationState::addAnimation(trackIndex, animation, loop, delay); | ||
} |
21 changes: 21 additions & 0 deletions
21
native/cocos/editor-support/spine-wasm/SpineAnimationState.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <spine/AnimationState.h> | ||
#include <map> | ||
#include <memory> | ||
#include "spine/Animation.h" | ||
|
||
namespace spine { | ||
|
||
class SP_API SpineAnimationState : public AnimationState { | ||
public: | ||
explicit SpineAnimationState(AnimationStateData* data); | ||
|
||
~SpineAnimationState(); | ||
|
||
TrackEntry* addAnimation(size_t trackIndex, Animation* animation, bool loop, float delay); | ||
|
||
private: | ||
std::map<Animation*, std::shared_ptr<Animation>> _mapAnimations; | ||
}; | ||
} // namespace spine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.