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 different texture object still use the same cached SkeletonData #18410

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cocos/spine/skeleton-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
textureUUIDs.push(tex.uuid || tex.getId());
}
if (this._skeletonJson) {
this._skeletonCache = spine.wasmUtil.createSpineSkeletonDataWithJson(this.skeletonJsonStr, this._atlasText, this.textureNames, textureUUIDs);

Check warning on line 223 in cocos/spine/skeleton-data.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 157. Maximum allowed is 150
spine.wasmUtil.registerSpineSkeletonDataWithUUID(this._skeletonCache, uuid);
} else {
const rawData = new Uint8Array(this._nativeAsset);
Expand Down Expand Up @@ -280,7 +280,14 @@
}

private mergedUUID (): string {
return this._uuid + murmurhash2_32_gc(this._atlasText, 668).toString();
// merge texture's id and atlas content
const hashContent = [
this._atlasText,
...this.textures.map((texture) => texture.getId()),
].join('');

// merge asset's uuid & hashContent
return `${this._uuid}${murmurhash2_32_gc(hashContent, 668)}`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cocos/spine/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ export class Skeleton extends UIRenderer {
let tex: Texture2D = assetManager.assets.get(textureUUID) as Texture2D;
if (!tex) {
// read from skeleton's texture map
tex = this.skeletonData?.textures.find((t) => t.getId() === textureUUID) as Texture2D;
tex = this.skeletonData?.textures.find((t) => (t.uuid === textureUUID || t.getId() === textureUUID)) as Texture2D;
if (!tex) {
// read from setSlotTexture's cache
tex = this._slotTextures?.get(textureUUID) as Texture2D;
Expand Down