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

提供spine可被自定义顶点数据格式的方法 #18511

Open
wants to merge 6 commits into
base: v3.8.7
Choose a base branch
from

Conversation

NorhsArk
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Mar 26, 2025

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1002411 bytes 1002411 bytes ✅ 0 bytes
2D All (legacy pipeline) 2663845 bytes 2664241 bytes ⚠️ +396 bytes
2D All (new pipeline) 2751265 bytes 2751661 bytes ⚠️ +396 bytes
(2D + 3D) All 10004545 bytes 10004939 bytes ⚠️ +394 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16917045 bytes 16917439 bytes ⚠️ +394 bytes

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -70480,8 +70480,9 @@
             model: _cocos_spine_skeleton_cache__SpineModel;
             boneInfos: _cocos_spine_skeleton_cache__FrameBoneInfo[];
         }
         export class _cocos_spine_skeleton_cache__AnimationCache {
+            static customVfmts(customizedOneColorVfmt: gfx.Attribute[], customizedTwoColorVfmt: gfx.Attribute[]): void;
             protected _instance: sp.spine.SkeletonInstance | null;
             protected _state: sp.spine.AnimationState;
             protected _skeletonData: sp.spine.SkeletonData;
             protected _skeleton: sp.spine.Skeleton;

@dumganhar dumganhar requested a review from bofeng-song March 27, 2025 05:38
@dumganhar dumganhar changed the base branch from v3.8.6 to v3.8.7 March 27, 2025 05:38
public static customVfmts (customizedOneColorVfmt: Attribute[], customizedTwoColorVfmt: Attribute[]): void {
vfmtOneColor = customizedOneColorVfmt;
vfmtTwoColor = customizedTwoColorVfmt;
_byteStrideOneColorCustomized = getAttributeStride(vfmtOneColor);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to recalculate _byteStrideOneColor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, when the number of bit stride in the custom vertex format is different, it needs to be recalculated

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not recalculate here.

@@ -95,8 +93,6 @@ class Simple implements IAssembler {
public static customVfmts (customizedOneColorVfmt: Attribute[], customizedTwoColorVfmt: Attribute[]): void {
vfmtOneColor = customizedOneColorVfmt;
vfmtTwoColor = customizedTwoColorVfmt;
Copy link
Contributor

Choose a reason for hiding this comment

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

As colorVfmt is customized, _byteStrideOneColor & _byteStrideTwoColor can not be delcared as const.
And its value must be recalculated here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The _byteStrideOneColor & _byteStrideTwoColor in the realTimeTraverse function is always used because The vertex data format obtained in spine.wasmUtel.wasm.heap8 is fixed. The custom vertex format byteStripe can be obtained from the renderData's allocator without the need for recalculation

@@ -28,12 +28,15 @@ import { vfmtPosUvColor4B, vfmtPosUvTwoColor4B, getAttributeStride } from '../2d
import spine from './lib/spine-core';
import { SkeletonData } from './skeleton-data';
import { warn } from '../core/platform/debug';
import { Attribute } from '../gfx';

const MaxCacheTime = 30;
const FrameTime = 1 / 60;
const _useTint = true;
const _byteStrideOneColor = getAttributeStride(vfmtPosUvColor4B);
const _byteStrideTwoColor = getAttributeStride(vfmtPosUvTwoColor4B);
Copy link
Contributor

Choose a reason for hiding this comment

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

_byteStrideOneColor may be changed after call customVfmts();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The _byteStrideOneColor in skeleton-cache.ts will always be used because the vertex data format obtained in spine.wasmUtel.wasm.heapu8 in updateRenderData is fixed. And the customized 'byteRideOneColorCustomized' only needs to be calculated in customVfmts

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.

2 participants