Skip to content
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

Open
wants to merge 9 commits into
base: v3.8.5
Choose a base branch
from

Conversation

bofeng-song
Copy link
Contributor

@bofeng-song bofeng-song commented Sep 20, 2024

Re: #
cocos/cocos-test-projects#887

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

Copy link

github-actions bot commented Sep 20, 2024

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -51436,9 +51436,10 @@
                 frames: ArrayLike<number>;
                 frameVertices: Array<ArrayLike<number>>;
                 constructor(frameCount: number);
                 getPropertyId(): number;
-                setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
+                setFrame(frameIndex: number, time: number, vertices: [
+                ]): void;
                 apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
             }
             export class EventTimeline implements Timeline {
                 frames: ArrayLike<number>;


private:
std::vector<std::shared_ptr<Timeline>> _vecTimelines;
spine::Vector<Timeline*> _spineVecTimelines;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need to use two different containers at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

* Spine Runtimes License Agreement
* Last updated January 1, 2020. Replaces all prior versions.
*
* Copyright (c) 2013-2020, Esoteric Software LLC
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -0,0 +1,18 @@

#include "SpineAnimationState.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing licenese.

@@ -0,0 +1,21 @@
#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing licenese.

@@ -5,6 +5,7 @@
#include "spine-mesh-data.h"
#include "spine-wasm.h"
#include "util-function.h"
#include "../spine-creator-support/SpineAnimationState.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use '../' for include path is not a good way.

@@ -47,6 +47,8 @@ SkeletonCache *SkeletonCacheMgr::buildSkeletonCache(const std::string &uuid) {
void SkeletonCacheMgr::removeSkeletonCache(const std::string &uuid) {
auto it = _caches.find(uuid);
if (it != _caches.end()) {
auto *item = it->second;
delete item;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item->release();

}

TrackEntry* SpineAnimationState::addAnimation(size_t trackIndex, std::shared_ptr<Animation> animation, bool loop, float delay) {
_vecAnimations.push_back(animation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use emplace_back instead.

@@ -449,7 +450,6 @@ class SkeletonCache {
animationCache = new AnimationCache(spData);
animationCache._privateMode = this._privateMode;
}
animationCache.init(skeletonInfo, animationName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't need to call init method now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be called outer this block

#include <spine/AnimationState.h>
#include "spine/Animation.h"
#include<vector>
#include<memory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space before <

@@ -53,6 +53,7 @@ class SP_API TranslateTimeline : public CurveTimeline {
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);

virtual int getPropertyId();
inline void setBoneIndex(int inValue) {_boneIndex = inValue;}
Copy link
Contributor

@dumganhar dumganhar Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't modify source code in spine-runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants