-
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 some bugs in spine webassembly #15569
Conversation
Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -51152,9 +51152,9 @@
}
export class SkeletonInstance {
initSkeleton(data: SkeletonData);
getAnimationState();
- setAnimation(trackIndex: number, name: string, loop: boolean);
+ setAnimation(trackIndex: number, name: string, loop: boolean): spine.TrackEntry | null;
setSkin(name: string);
setPremultipliedAlpha(usePremultipliedAlpha: boolean);
setColor(r: number, g: number, b: number, a: number);
setMix(fromName: string, toName: string, duration: number);
@@ -51166,8 +51166,10 @@
updateRenderData();
setListener(id: number, type: number);
setDebugMode(debug: boolean);
getDebugShapes();
+ resizeSlotRegion(slotName: string, width: number, height: number, createNew: boolean);
+ setSlotTexture(slotName: string, index: number);
}
export class wasmUtil {
static spineWasmInit(): void;
static spineWasmDestroy(): void;
@@ -51361,9 +51363,9 @@
protected _runtimeData: spine.SkeletonData | null;
_skeleton: spine.Skeleton;
protected _instance: spine.SkeletonInstance;
protected _state: spine.AnimationState;
- protected _texture: Texture2D | null;
+ protected _textures: Texture2D[];
protected _animationName: string;
protected _skinName: string;
protected _drawList: memop.RecyclePool<__private._cocos_spine_skeleton__SkeletonDrawData>;
protected _materialCache: {
@@ -51526,10 +51528,38 @@
* @param trackIndex @en Index of track. @zh 动画通道索引。
* @param name @en The name of animation. @zh 动画名称。
* @param loop @en Use loop mode or not. @zh 是否使用循环播放模式。
*/
- setAnimation(trackIndex: number, name: string, loop?: boolean): void;
+ setAnimation(trackIndex: number, name: string, loop?: boolean): spine.TrackEntry | null;
/**
+ * @en Adds an animation to be played delay seconds after the current or last queued animation.<br>
+ * Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
+ * @zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。<br>
+ * 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
+ * @param trackIndex @en Index of trackEntry. @zh TrackEntry 索引。
+ * @param name @en The name of animation. @zh 动画名称。
+ * @param loop @en Set play animation in a loop. @zh 是否循环播放。
+ * @param delay @en Delay time of animation start. @zh 动画开始的延迟时间。
+ * @return {sp.spine.TrackEntry}
+ */
+ addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): spine.TrackEntry | null;
+ /**
+ * @en Find animation with specified name.
+ * @zh 查找指定名称的动画
+ * @param name @en The name of animation. @zh 动画名称。
+ * @returns {sp.spine.Animation}
+ */
+ findAnimation(name: string): spine.Animation | null;
+ /**
+ * @en Returns track entry by trackIndex.<br>
+ * Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
+ * @zh 通过 track 索引获取 TrackEntry。<br>
+ * 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
+ * @param trackIndex @en The index of trackEntry. @zh TrackEntry 索引。
+ * @return {sp.spine.TrackEntry}
+ */
+ getCurrent(trackIndex: number): spine.TrackEntry | null;
+ /**
* @en
* Finds a skin by name and makes it the active skin.
* This does a string comparison for every skin.<br>
* Note that setting the skin does not change which attachments are visible.<br>
@@ -51758,8 +51788,18 @@
* @param entry
* @param listener @en Listener for registering callback functions. @zh 监听器对象,可注册回调方法。
*/
setTrackEventListener(entry: spine.TrackEntry, listener: __private._cocos_spine_skeleton__TrackListener | __private._cocos_spine_skeleton__TrackListener2): void;
+ /**
+ * @en Set texture for slot, this function can be use to changing local skin.
+ * @zh 为 slot 设置贴图纹理,可使用该该方法实现局部换装功能。
+ * @param slotName @en The name of slot. @zh Slot 名字。
+ * @param tex2d @en The texture will show on the slot. @zh 在该 Slot 上显示的 2D 纹理。
+ * @param createNew @en Whether to create new Attachment. If value is false, all sp.Skeleton share the
+ * same attachment will be changed. @zh 是否需要创建新的 attachment,如果值为 false, 所有共享相同 attachment
+ * 的组件都将受影响。
+ */
+ setSlotTexture(slotName: string, tex2d: Texture2D, createNew?: boolean): void;
}
/**
* @en The skeleton data of spine.
* @zh Spine 的骨骼数据。
@@ -66217,8 +66257,9 @@
* @engineInternal Since v3.7.2, this is an engine private interface.
*/
export interface _cocos_spine_skeleton__SkeletonDrawData {
material: Material | null;
+ texture: Texture2D | null;
indexOffset: number;
indexCount: number;
}
/**
|
@cocos-robot run test cases |
@zhakesi, Please check the result of
Task Details
|
AttachmentVertices *AttachmentVertices::copy() { | ||
AttachmentVertices *atv = new AttachmentVertices(nullptr, _triangles->vertCount, _triangles->indices, _triangles->indexCount); | ||
return atv; | ||
} |
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.
Where to delete the memeory?
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.
统一解释下这里的内存问题:
AttachmentVertices 是多个组件共享的。因此在接口上层提供了createNew的选项,用于避免在多个共享数据的组件时,更改一个组件对其他组件产生影响。在createNew 为false时,在原本的数据上做修改即可,不用创建新数据。
数据会在组件销毁时释放。
这里是把释放需要新建数据的选择交给了用户。
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.
Ok.
native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-wasm/spine-skeleton-instance.cpp
Outdated
Show resolved
Hide resolved
native/cocos/editor-support/spine-wasm/spine-skeleton-instance.cpp
Outdated
Show resolved
Hide resolved
std::string stdStr(str.buffer(), str.length()); | ||
return stdStr; | ||
} | ||
|
||
const spine::String convertStd2SPString(std::string& str) { | ||
const spine::String STRING_STD2SP(std::string& str) { |
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.
Why to rename the function to all capital?
2e0c087
to
27d384e
Compare
As CI doesn't check wasm lib. And previous CI passed, so merge it. |
No description provided.