-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix spine::Animation & spine::Timeline can not release normally #17653
base: v3.8.5
Are you sure you want to change the base?
Changes from 4 commits
fa73743
8768952
7a051b8
8c532a4
efe5467
9a0b427
be6db1b
194cc0c
d7f452c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#include "SpineAnimation.h" | ||
|
||
using namespace spine; | ||
|
||
spine::Vector<Timeline*>& convertAndUseVector(const std::vector<std::shared_ptr<Timeline>>& stdVec, spine::Vector<Timeline*>& _spineVecTimelines) { | ||
for (const auto& element : stdVec) { | ||
_spineVecTimelines.add(element.get()); | ||
} | ||
|
||
return _spineVecTimelines; | ||
} | ||
|
||
SpineAnimation::SpineAnimation(const String& name, std::vector<std::shared_ptr<Timeline>> timelines, float duration) : Animation(name, convertAndUseVector(timelines, _spineVecTimelines), duration) { | ||
_vecTimelines = timelines; | ||
} | ||
|
||
SpineAnimation::~SpineAnimation() { | ||
_vecTimelines.clear(); | ||
_spineVecTimelines.clear(); | ||
auto& timelines = getTimelines(); | ||
timelines.clear(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#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; | ||
spine::Vector<Timeline*> _spineVecTimelines; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why need to use two different containers at the same time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spine::Animation's constructor requires spine::Vector<Timeline*>, we need to change from std::vector to spine::Vector |
||
}; | ||
|
||
} // namespace spine |
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
return AnimationState::addAnimation(trackIndex, animation.get(), loop, delay); | ||
} | ||
|
||
|
||
|
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a new file we created, it's not a file in spine runtime , so I think we need to use our license. |
||
* | ||
* 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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a space before |
||
|
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
#include "SpineAnimationState.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing licenese. |
||
|
||
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); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing licenese. |
||
|
||
#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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
#include "spine-mesh-data.h" | ||
#include "spine-wasm.h" | ||
#include "util-function.h" | ||
#include "../spine-creator-support/SpineAnimationState.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use '../' for include path is not a good way. |
||
|
||
SlotMesh globalMesh(nullptr, nullptr, 0, 0); | ||
|
||
|
@@ -57,7 +58,7 @@ Skeleton *SpineSkeletonInstance::initSkeleton(SkeletonData *data) { | |
_skeletonData = data; | ||
_skeleton = new Skeleton(_skeletonData); | ||
_animStateData = new AnimationStateData(_skeletonData); | ||
_animState = new AnimationState(_animStateData); | ||
_animState = new SpineAnimationState(_animStateData); | ||
_clipper = new SkeletonClipping(); | ||
_skeleton->setToSetupPose(); | ||
_skeleton->updateWorldTransform(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item->release();