-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Optimize spine performance & fix memory leaks. #16485
Merged
Merged
Conversation
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
Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -50631,8 +50631,21 @@
THE SOFTWARE.
*/
/* eslint @typescript-eslint/no-explicit-any: "off" */
export namespace spine {
+ export class String {
+ length: number;
+ isEmpty: boolean;
+ strPtr: number;
+ str: string;
+ }
+ export class SPVectorFloat {
+ size(): number;
+ resize(newSize: number, defaultValue: number);
+ set(index: number, value: number);
+ get(index: number): number;
+ delete();
+ }
export class Animation {
constructor(name: string, timelines: Array<Timeline>, duration: number);
duration: number;
name: string;
@@ -51146,9 +51159,8 @@
ikConstraints: Array<IkConstraint>;
transformConstraints: Array<TransformConstraint>;
pathConstraints: Array<PathConstraint>;
_updateCache: Updatable[];
- updateCacheReset: Updatable[];
skin: Skin;
color: Color;
time: number;
scaleX: number;
@@ -51261,9 +51273,9 @@
export class SkeletonJson {
attachmentLoader: AttachmentLoader;
scale: number;
constructor(attachmentLoader: AttachmentLoader);
- readSkeletonData(json: string | any): SkeletonData;
+ readSkeletonData(json: any): SkeletonData;
readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment;
readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void;
readAnimation(map: any, name: string, skeletonData: SkeletonData): void;
readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void;
@@ -51719,9 +51731,18 @@
begin(skeleton: Skeleton): void;
transform(x: number, y: number): void;
end(): void;
}
+ export class SkeletonSystem {
+ public static updateAnimation(deltaTime: number): void;
+ public static updateRenderData(): void;
+ public static getCount(): number;
+ }
export class SkeletonInstance {
+ dtRate: number;
+ isCache: boolean;
+ isDelete: boolean;
+ enable: boolean;
initSkeleton(data: SkeletonData);
getAnimationState();
setAnimation(trackIndex: number, name: string, loop: boolean): spine.TrackEntry | null;
setSkin(name: string);
@@ -51854,8 +51875,14 @@
* @zh 私有缓存模式。
*/
PRIVATE_CACHE = 2
}
+ export interface TempColor {
+ r: number;
+ g: number;
+ b: number;
+ a: number;
+ }
/**
* @en
* The Sockets attached to bones, synchronous transform with spine animation.
* @zh
@@ -51909,9 +51936,8 @@
protected _premultipliedAlpha: boolean;
protected _timeScale: number;
protected _preCacheMode: AnimationCacheMode;
protected _cacheMode: AnimationCacheMode;
- protected _defaultCacheMode: AnimationCacheMode;
protected _sockets: SpineSocket[];
protected _useTint: boolean;
protected _debugMesh: boolean;
protected _debugBones: boolean;
@@ -51944,8 +51970,14 @@
protected _isAniComplete: boolean;
protected _playTimes: number;
protected _needUpdateSkeltonData: boolean;
protected _listener: __private._cocos_spine_track_entry_listeners__TrackEntryListeners | null;
+ _vLength: number;
+ _vBuffer: Uint8Array | null;
+ _iLength: number;
+ _iBuffer: Uint8Array | null;
+ _model: any;
+ _tempColor: TempColor;
constructor();
/**
* @en
* The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
@@ -52021,9 +52053,9 @@
* @zh 是否显示 mesh 的 debug 信息。
*/
get debugMesh(): boolean;
set debugMesh(value: boolean);
- get socketNodes(): Map<number, Node>;
+ get socketNodes(): Map<number, Node> | null;
/**
* @en The name of current playing animation.
* @zh 当前播放的动画名称。
* @property {String} animation
@@ -67074,22 +67106,30 @@
texture: Texture2D | null;
indexOffset: number;
indexCount: number;
}
+ export class _cocos_spine_skeleton_cache__FrameBoneInfo {
+ a: number;
+ b: number;
+ c: number;
+ d: number;
+ worldX: number;
+ worldY: number;
+ }
/**
* @en Attach node tool
* @zh 挂点工具类
* @class sp.AttachUtil
*/
export class _cocos_spine_attach_util__AttachUtil {
- protected _inited: boolean;
- protected _skeleton: sp.spine.Skeleton | null;
- protected _skeletonNode: Node | null;
- protected _skeletonComp: sp.Skeleton | null;
+ protected _isInitialized: boolean;
+ protected _skeletonBones: sp.spine.Bone[] | _cocos_spine_skeleton_cache__FrameBoneInfo[] | null;
+ protected _socketNodes: Map<number, Node> | null;
constructor();
init(skeletonComp: sp.Skeleton): void;
reset(): void;
_syncAttachedNode(): void;
+ matrixHandle(node: Node, bone: any): void;
}
export type _cocos_spine_track_entry_listeners__TrackListener = (x: sp.spine.TrackEntry) => void;
export type _cocos_spine_track_entry_listeners__TrackListener2 = (x: sp.spine.TrackEntry, ev: sp.spine.Event) => void;
export type _cocos_spine_track_entry_listeners__CommonTrackEntryListener = _cocos_spine_track_entry_listeners__TrackListener | _cocos_spine_track_entry_listeners__TrackListener2;
@@ -67115,16 +67155,8 @@
vData: Uint8Array;
iData: Uint16Array;
meshes: _cocos_spine_skeleton_cache__SpineDrawItem[];
}
- export class _cocos_spine_skeleton_cache__FrameBoneInfo {
- a: number;
- b: number;
- c: number;
- d: number;
- worldX: number;
- worldY: number;
- }
export interface _cocos_spine_skeleton_cache__AnimationFrame {
model: _cocos_spine_skeleton_cache__SpineModel;
boneInfos: _cocos_spine_skeleton_cache__FrameBoneInfo[];
}
@@ -67163,14 +67195,14 @@
isInvalid(): boolean;
invalidAllFrame(): void;
enableCacheAttachedInfo(): void;
clear(): void;
- destory(): void;
+ destroy(): void;
}
export interface _cocos_spine_skeleton_cache__SkeletonCacheItemInfo {
- skeleton: sp.spine.Skeleton;
- clipper: sp.spine.SkeletonClipping;
- state: sp.spine.AnimationState;
+ skeleton: sp.spine.Skeleton | null;
+ clipper: sp.spine.SkeletonClipping | null;
+ state: sp.spine.AnimationState | null;
listener: _cocos_spine_track_entry_listeners__TrackEntryListeners;
curAnimationCache: _cocos_spine_skeleton_cache__AnimationCache | null;
animationsCache: {
[key: string]: _cocos_spine_skeleton_cache__AnimationCache;
|
dumganhar
approved these changes
Nov 9, 2023
6 tasks
minggo
approved these changes
Nov 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Re: # #16384
Changelog
Fix memory leaks.
Improve the performance of wasm interaction with TS.
Optimize the code of attach node synchronization.
Optimize spine rendering data processing logic.
*
Continuous Integration
This pull request:
Compatibility Check
This pull request: