Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
bofeng-song committed Feb 17, 2025
1 parent 3ceb1b8 commit a218836
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 18 deletions.
4 changes: 4 additions & 0 deletions EngineErrorMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -3972,3 +3972,7 @@ cached mode not support setMix!!!
### 16418

Debug bones or slots is invalid in cached mode.

### 16419

Spine version not supported.
8 changes: 4 additions & 4 deletions cocos/spine/lib/instantiated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import { instantiateWasm, fetchBuffer, ensureWasmModuleReady } from 'pal/wasm';
import { BUILD, JSB, LOAD_SPINE_MANUALLY, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
import { game } from '../../game';
import { error, sys } from '../../core';
import { error, errorID, sys } from '../../core';
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
import { overrideSpineDefine } from './spine-define';
import { SPINE_VERSION } from './spine-version';
Expand Down Expand Up @@ -101,8 +101,8 @@ function shouldUseWasmModule (): boolean {
function waitForSpineWasmInstantiation_3_8 (): Promise<void> {
const errorReport = (msg: any): void => { error(msg); };
return ensureWasmModuleReady().then(() => {
//We should use static code here, import operation will cause file copy to cache folder.
if (shouldUseWasmModule()) {
//We should use static code here, import operation will cause file copye to cache folder.
return Promise.all([
import('external:emscripten/spine/3.8/spine.wasm.js'),

Check failure on line 107 in cocos/spine/lib/instantiated.ts

View workflow job for this annotation

GitHub Actions / npm_test

Cannot find module 'external:emscripten/spine/3.8/spine.wasm.js' or its corresponding type declarations.
import('external:emscripten/spine/3.8/spine.wasm'),
Expand All @@ -125,8 +125,8 @@ function waitForSpineWasmInstantiation_3_8 (): Promise<void> {
function waitForSpineWasmInstantiation_4_2 (): Promise<void> {
const errorReport = (msg: any): void => { error(msg); };
return ensureWasmModuleReady().then(() => {
//We should use static code here, import operation will cause file copy to cache folder.
if (shouldUseWasmModule()) {
//We should use static code here, import operation will cause file copye to cache folder.
return Promise.all([
import('external:emscripten/spine/4.2/spine.wasm.js'),

Check failure on line 131 in cocos/spine/lib/instantiated.ts

View workflow job for this annotation

GitHub Actions / npm_test

Cannot find module 'external:emscripten/spine/4.2/spine.wasm.js' or its corresponding type declarations.
import('external:emscripten/spine/4.2/spine.wasm'),
Expand All @@ -152,7 +152,7 @@ export function waitForSpineWasmInstantiation (): Promise<void> {
} else if (SPINE_VERSION === '4.2') {
return waitForSpineWasmInstantiation_4_2();
}
error('Spine version not supported');
errorID(16419);
return Promise.resolve();
}

Expand Down
11 changes: 6 additions & 5 deletions native/cocos/bindings/manual/jsb_module_register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@
#if CC_USE_MIDDLEWARE
#include "cocos/bindings/auto/jsb_editor_support_auto.h"

#if CC_USE_SPINE_3_8
#include "cocos/bindings/auto/jsb_spine_3_8_auto.h"
#elif CC_USE_SPINE_4_2
#include "cocos/bindings/auto/jsb_spine_4_2_auto.h"
#endif
#if CC_USE_SPINE
#if CC_USE_SPINE_3_8
#include "cocos/bindings/auto/jsb_spine_3_8_auto.h"
#elif CC_USE_SPINE_4_2
#include "cocos/bindings/auto/jsb_spine_4_2_auto.h"
#endif

#include "cocos/bindings/manual/jsb_spine_manual.h"
#endif

Expand Down
4 changes: 2 additions & 2 deletions native/cocos/bindings/manual/jsb_spine_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ static bool js_register_spine_initSkeletonData(se::State &s) {
spine::SkeletonBinary binary(attachmentLoader);
binary.setScale(scale);
skeletonData = binary.readSkeletonData(cocos2dData.getBytes(), (int)cocos2dData.getSize());
auto &errorMsg = binary.getError();
const auto &errorMsg = binary.getError();
CC_ASSERT_FORMAT(skeletonData, "Spine parse error: %s", errorMsg.buffer());
}
} else {
spine::SkeletonJson json(attachmentLoader);
json.setScale(scale);
skeletonData = json.readSkeletonData(skeletonDataFile.c_str());
auto &errorMsg = json.getError();
const auto &errorMsg = json.getError();
CC_ASSERT_FORMAT(skeletonData, "Spine parse error: %s", errorMsg.buffer());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class SkeletonDataInfo {
auto *region = regions[i];
if (region->rendererObject) {
delete static_cast<AttachmentVertices *>(region->rendererObject);
region->rendererObject = nullptr;
}
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
}
#endif

// 获取当前插槽的变换矩阵
// TODO: implement PathAttachment
//auto &transform = slot->getBone().getWorldTransform();
} else if (slot->getAttachment()->getRTTI().isExactly(ClippingAttachment::rtti)) {
auto *clip = dynamic_cast<ClippingAttachment *>(slot->getAttachment());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "base/RefCounted.h"
#include "spine/spine.h"
using namespace spine;
namespace cc {
namespace cc {

class VertexEffectDelegate : public cc::RefCounted {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ using namespace spine;

#include <emscripten/emscripten.h>
#include <emscripten/val.h>



using namespace spine;

static void wasmLog(const char* message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void SpineSkeletonInstance::collectMeshData() {
uint32_t strideColor = byteStrideColor / sizeof_float;

Color4F color;
auto &slotArray = _skeleton->getDrawOrder();
auto &slotArray = _skeleton->getDrawOrder();
uint32_t slotCount = slotArray.size();
DEBUG_SHAPE_TYPE debugShapeType = DEBUG_SHAPE_TYPE::DEBUG_REGION;

Expand Down
2 changes: 1 addition & 1 deletion platforms/native/engine/jsb-spine-skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ const cacheManager = require('./jsb-cache-manager');
};

skeleton.setVertexEffectDelegate = function (effectDelegate) {
if (cc.sp.SPINE_VERSION !== '3.8') {
if (cc.sp.SPINE_VERSION === '4.2') {
cc.warn('setVertexEffectDelegate is deprecated since spine 4.2');
return;
}
Expand Down

0 comments on commit a218836

Please sign in to comment.