diff --git a/.github/workflows/native-compile-platforms.yml b/.github/workflows/native-compile-platforms.yml
index 4dd62ed335..3c6d29b61d 100644
--- a/.github/workflows/native-compile-platforms.yml
+++ b/.github/workflows/native-compile-platforms.yml
@@ -44,8 +44,6 @@ jobs:
echo "set(CC_USE_GLES3 ON)" >> build-win64/proj/cfg.cmake
echo "set(CC_USE_VULKAN ON)" >> build-win64/proj/cfg.cmake
echo "set(CC_USE_GLES2 ON)" >> build-win64/proj/cfg.cmake
- echo "set(USE_SPINE OFF)" >> build-win64/proj/cfg.cmake
- echo "set(USE_DRAGONBONES OFF)" >> build-win64/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER ON)" >> build-win64/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-win64/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-win64/proj/cfg.cmake
@@ -193,6 +191,8 @@ jobs:
echo "set(USE_BOX2D_JSB ON)" >> build-android/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER ON)" >> build-android/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-android/proj/cfg.cmake
+ echo "set(USE_SPINE_3_8 OFF)" >> build-android/proj/cfg.cmake
+ echo "set(USE_SPINE_4_2 ON)" >> build-android/proj/cfg.cmake
echo "set(COCOS_X_PATH $NATIVE_ROOT)" >> build-android/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-android/proj/cfg.cmake
diff --git a/.github/workflows/package-size-check.js b/.github/workflows/package-size-check.js
index 383b17bf0a..8cfd310037 100644
--- a/.github/workflows/package-size-check.js
+++ b/.github/workflows/package-size-check.js
@@ -7,8 +7,8 @@ if (args.length == 0) {
console.error('Please specify the engine root path');
process.exit(1);
}
-const engineRoot = args[0];
+const engineRoot = args[0];
console.log(`Engine root: ${engineRoot}`);
const features2DCommon = [
@@ -30,7 +30,8 @@ const features2DCommon = [
"physics-2d-box2d-wasm",
"profiler",
"rich-text",
- "spine",
+ "spine", // Old version uses 'spine' feature
+ "spine-3.8", // New version uses 'spine-xxx' feature
"tiled-map",
"tween",
"ui",
@@ -115,13 +116,24 @@ async function buildEngineForFeatures(options) {
const excludeFeatures = [
'vendor-google',
'xr',
+ 'spine-3.8',
+ 'spine-4.2',
];
const allFeatures = statsQuery.getFeatures().filter(feature => !excludeFeatures.includes(feature));
console.log(`all features: [ ${allFeatures.join(', ')} ]`);
+ const allFeaturesForWeChat = [...allFeatures, 'spine-3.8'];
+ let allFeaturesForWeb = [...allFeatures, 'spine-4.2'];
+
+ if (!fs.pathExistsSync(ps.join(engineRoot, 'cocos', 'spine', 'lib', 'spine-version-4.2.ts'))) {
+ console.log(`Doesn't found spine-version-4.2.ts`);
+ allFeaturesForWeb = allFeaturesForWeChat;
+ } else {
+ console.log(`Found spine-version-4.2.ts`);
+ }
await buildEngineForFeatures({
- features: allFeatures,
+ features: allFeaturesForWeChat,
outDir: ps.join(engineRoot, 'build-cc-out-all'),
noDeprecatedFeatures: false,
platform: "WECHAT",
@@ -130,7 +142,7 @@ async function buildEngineForFeatures(options) {
});
await buildEngineForFeatures({
- features: allFeatures,
+ features: allFeaturesForWeb,
outDir: ps.join(engineRoot, 'build-cc-out-all-web'),
noDeprecatedFeatures: false,
platform: "HTML5",
diff --git a/.github/workflows/web-interface-check.yml b/.github/workflows/web-interface-check.yml
index ea5d7d4999..56d0ebde87 100644
--- a/.github/workflows/web-interface-check.yml
+++ b/.github/workflows/web-interface-check.yml
@@ -96,6 +96,17 @@ jobs:
echo "HEAD LOG:"
git --no-pager log -3
+ - name: Check for SPINE_VERSION in CMakeLists.txt (BASE)
+ run: |
+ cd ./engine/native/cocos/editor-support/spine-wasm
+ if grep -q "SPINE_VERSION" CMakeLists.txt; then
+ echo "FOUND_SPINE_VERSION_BASE=true"
+ echo "FOUND_SPINE_VERSION_BASE=true" >> $GITHUB_ENV
+ else
+ echo "FOUND_SPINE_VERSION_BASE=false"
+ echo "FOUND_SPINE_VERSION_BASE=false" >> $GITHUB_ENV
+ fi
+
- run: |
echo "EXT_VERSION=$(node ./engine/.github/workflows/get-native-external-version.js)" >> $GITHUB_ENV
@@ -116,41 +127,94 @@ jobs:
echo "--------------------------------- Apply patches DONE! ---------------------------------"
cat $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp
- - name: Build Spine WASM (BASE)
- run: |
- cd ./engine/native/cocos/editor-support/spine-wasm
- mkdir build-wasm
- cd build-wasm
- emcmake cmake .. -GNinja
- ninja
- ls -l
+ # - name: Build Spine 3.8 WASM (BASE)
+ # run: |
+ # cd ./engine/native/cocos/editor-support/spine-wasm
+ # rm -rf build-wasm
+ # mkdir build-wasm
+ # cd build-wasm
+ # emcmake cmake .. -GNinja
+ # ninja
+ # ls -l
- - name: Build Spine ASMJS (BASE)
- run: |
- cd ./engine/native/cocos/editor-support/spine-wasm
- sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
- mkdir build-asmjs
- cd build-asmjs
- emcmake cmake .. -GNinja
- ninja
- ls -l
+ # - name: Build Spine 3.8 ASMJS (BASE)
+ # run: |
+ # cd ./engine/native/cocos/editor-support/spine-wasm
+ # sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
+ # rm -rf build-asmjs
+ # mkdir build-asmjs
+ # cd build-asmjs
+ # emcmake cmake .. -GNinja
+ # ninja
+ # ls -l
- - name: Copy files to external directory (BASE)
- run: |
- rm -rf dist
- mkdir dist
- cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./dist/
- cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./dist/spine.wasm.js
- cp ./engine/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./dist/
- cp ./engine/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./dist/spine.asm.js
- echo "-------- Before replace spine wasm -----------"
- ls -l ./engine/native/external/emscripten/spine/
- cp -f ./dist/* ./engine/native/external/emscripten/spine/
- echo "-------- After replace spine wasm ------------"
- ls -l ./engine/native/external/emscripten/spine/
- echo "-----------------------------------------------"
- cd ./engine/native/external
- git status
+ # - name: Copy Spine 3.8 files to external directory (BASE)
+ # run: |
+ # if [[ $FOUND_SPINE_VERSION_BASE ]]; then
+ # SPINE_VERSION="3.8"
+ # fi
+ # DIST_PATH="dist/3.8"
+ # rm -rf $DIST_PATH
+ # mkdir -p $DIST_PATH
+ # cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./$DIST_PATH/
+ # cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./$DIST_PATH/spine.wasm.js
+ # cp ./engine/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./$DIST_PATH/
+ # cp ./engine/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./$DIST_PATH/spine.asm.js
+ # mkdir -p ./engine/native/external/emscripten/spine/$SPINE_VERSION
+ # echo "-------- Before replace spine wasm -----------"
+ # ls -l ./engine/native/external/emscripten/spine/$SPINE_VERSION
+ # cp -f ./$DIST_PATH/* ./engine/native/external/emscripten/spine/$SPINE_VERSION
+ # echo "-------- After replace spine wasm ------------"
+ # ls -l ./engine/native/external/emscripten/spine/$SPINE_VERSION
+ # echo "-----------------------------------------------"
+ # cd ./engine/native/external
+ # git status
+
+ # - name: Build Spine 4.2 WASM (BASE)
+ # if: env.FOUND_SPINE_VERSION_BASE == 'true'
+ # run: |
+ # cd ./engine/native/cocos/editor-support/spine-wasm
+ # sed -i 's/set(BUILD_WASM 0)/set(BUILD_WASM 1)/g' CMakeLists.txt
+ # sed -i 's/set(SPINE_VERSION "3.8")/set(SPINE_VERSION "4.2")/g' CMakeLists.txt
+ # rm -rf build-wasm
+ # mkdir build-wasm
+ # cd build-wasm
+ # emcmake cmake .. -GNinja
+ # ninja
+ # ls -l
+
+ # - name: Build Spine 4.2 ASMJS (BASE)
+ # if: env.FOUND_SPINE_VERSION_BASE == 'true'
+ # run: |
+ # cd ./engine/native/cocos/editor-support/spine-wasm
+ # sed -i 's/set(SPINE_VERSION "3.8")/set(SPINE_VERSION "4.2")/g' CMakeLists.txt
+ # sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
+ # rm -rf build-asmjs
+ # mkdir build-asmjs
+ # cd build-asmjs
+ # emcmake cmake .. -GNinja
+ # ninja
+ # ls -l
+
+ # - name: Copy Spine 4.2 files to external directory (BASE)
+ # if: env.FOUND_SPINE_VERSION_BASE == 'true'
+ # run: |
+ # DIST_PATH="dist/4.2"
+ # rm -rf $DIST_PATH
+ # mkdir -p $DIST_PATH
+ # cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./$DIST_PATH/
+ # cp ./engine/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./$DIST_PATH/spine.wasm.js
+ # cp ./engine/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./$DIST_PATH/
+ # cp ./engine/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./$DIST_PATH/spine.asm.js
+ # mkdir -p ./engine/native/external/emscripten/spine/4.2/
+ # echo "-------- Before replace spine wasm -----------"
+ # ls -l ./engine/native/external/emscripten/spine/4.2/
+ # cp -f ./$DIST_PATH/* ./engine/native/external/emscripten/spine/4.2/
+ # echo "-------- After replace spine wasm ------------"
+ # ls -l ./engine/native/external/emscripten/spine/4.2/
+ # echo "-----------------------------------------------"
+ # cd ./engine/native/external
+ # git status
- name: Build Base Declarations
working-directory: .
@@ -195,7 +259,7 @@ jobs:
echo "--------------------------------- Apply patches DONE! ---------------------------------"
cat $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp
- - name: Build Spine WASM (HEAD)
+ - name: Build Spine 3.8 WASM (HEAD)
run: |
cd ./engine-HEAD/native/cocos/editor-support/spine-wasm
mkdir build-wasm
@@ -204,7 +268,7 @@ jobs:
ninja
ls -l
- - name: Build Spine ASMJS (HEAD)
+ - name: Build Spine 3.8 ASMJS (HEAD)
run: |
cd ./engine-HEAD/native/cocos/editor-support/spine-wasm
sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
@@ -214,19 +278,64 @@ jobs:
ninja
ls -l
- - name: Copy files to external directory (HEAD)
+ - name: Copy Spine 3.8 files to external directory (HEAD)
run: |
- rm -rf dist
- mkdir dist
- cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./dist/
- cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./dist/spine.wasm.js
- cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./dist/
- cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./dist/spine.asm.js
+ DIST_PATH="dist/3.8"
+ rm -rf $DIST_PATH
+ mkdir -p $DIST_PATH
+ cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./$DIST_PATH
+ cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./$DIST_PATH/spine.wasm.js
+ cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./$DIST_PATH/
+ cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./$DIST_PATH/spine.asm.js
echo "-------- Before replace spine wasm -----------"
- ls -l ./engine-HEAD/native/external/emscripten/spine/
- cp -f ./dist/* ./engine-HEAD/native/external/emscripten/spine/
+ mkdir -p ./engine-HEAD/native/external/emscripten/spine/3.8
+ ls -l ./engine-HEAD/native/external/emscripten/spine/3.8
+ cp -f ./$DIST_PATH/* ./engine-HEAD/native/external/emscripten/spine/3.8
echo "-------- After replace spine wasm ------------"
- ls -l ./engine-HEAD/native/external/emscripten/spine/
+ ls -l ./engine-HEAD/native/external/emscripten/spine/3.8
+ echo "-----------------------------------------------"
+ cd ./engine-HEAD/native/external
+ git status
+
+ - name: Build Spine 4.2 WASM (HEAD)
+ run: |
+ cd ./engine-HEAD/native/cocos/editor-support/spine-wasm
+ sed -i 's/set(BUILD_WASM 0)/set(BUILD_WASM 1)/g' CMakeLists.txt
+ sed -i 's/set(SPINE_VERSION "3.8")/set(SPINE_VERSION "4.2")/g' CMakeLists.txt
+ rm -rf build-wasm
+ mkdir build-wasm
+ cd build-wasm
+ emcmake cmake .. -GNinja
+ ninja
+ ls -l
+
+ - name: Build Spine 4.2 ASMJS (HEAD)
+ run: |
+ cd ./engine-HEAD/native/cocos/editor-support/spine-wasm
+ sed -i 's/set(SPINE_VERSION "3.8")/set(SPINE_VERSION "4.2")/g' CMakeLists.txt
+ sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
+ rm -rf build-asmjs
+ mkdir build-asmjs
+ cd build-asmjs
+ emcmake cmake .. -GNinja
+ ninja
+ ls -l
+
+ - name: Copy Spine 4.2 files to external directory (HEAD)
+ run: |
+ DIST_PATH="dist/4.2"
+ rm -rf $DIST_PATH
+ mkdir -p $DIST_PATH
+ cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./$DIST_PATH
+ cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./$DIST_PATH/spine.wasm.js
+ cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./$DIST_PATH/
+ cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./$DIST_PATH/spine.asm.js
+ echo "-------- Before replace spine wasm -----------"
+ mkdir -p ./engine-HEAD/native/external/emscripten/spine/4.2/
+ ls -l ./engine-HEAD/native/external/emscripten/spine/4.2/
+ cp -f ./$DIST_PATH/* ./engine-HEAD/native/external/emscripten/spine/4.2/
+ echo "-------- After replace spine wasm ------------"
+ ls -l ./engine-HEAD/native/external/emscripten/spine/4.2/
echo "-----------------------------------------------"
cd ./engine-HEAD/native/external
git status
diff --git a/.github/workflows/web-npm_test.yml b/.github/workflows/web-npm_test.yml
index f65573df49..00722e8a4e 100644
--- a/.github/workflows/web-npm_test.yml
+++ b/.github/workflows/web-npm_test.yml
@@ -18,12 +18,127 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: '18.x'
+
+ - name: Setup emsdk
+ uses: dumganhar/setup-emsdk@997d2cde2deabda085a11f98e86e842915b0e846
+ with:
+ version: 3.1.41
+ actions-cache-folder: 'emsdk-cache-3.1.41'
+
+ - name: Verify
+ run: |
+ which emcc
+ emcc -v
+
+ - name: Install ninja
+ run: |
+ if ! command -v ninja &> /dev/null; then
+ echo "Ninja not found, installing..."
+ # sudo apt update
+ sudo apt install ninja-build
+ else
+ echo "Ninja is already installed."
+ fi
+ which ninja
- name: Download external
run: |
EXT_VERSION=`node ./.github/workflows/get-native-external-version.js`
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external
+ - name: Apply emscripten patches
+ run: |
+ echo "--------------------------------- Save bind.cpp ---------------------------------"
+ cp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp.bak
+ echo "--------------------------------- Apply embind bind.cpp patches ---------------------------------"
+ cp -f ./.github/workflows/emscripten-patches/embind/bind.cpp $EMSDK/upstream/emscripten/system/lib/embind/
+ echo "--------------------------------- Apply patches DONE! ---------------------------------"
+ cat $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp
+
+ - name: Build Spine 3.8 WASM
+ run: |
+ cd ./native/cocos/editor-support/spine-wasm
+ rm -rf build-wasm
+ mkdir build-wasm
+ cd build-wasm
+ emcmake cmake .. -GNinja
+ ninja
+ ls -l
+
+ - name: Build Spine 3.8 ASMJS
+ run: |
+ cd ./native/cocos/editor-support/spine-wasm
+ sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
+ rm -rf build-asmjs
+ mkdir build-asmjs
+ cd build-asmjs
+ emcmake cmake .. -GNinja
+ ninja
+ ls -l
+
+ - name: Copy Spine 3.8 files to external directory
+ run: |
+ SPINE_VERSION="3.8"
+ DIST_PATH="dist/3.8"
+ rm -rf $DIST_PATH
+ mkdir -p $DIST_PATH
+ cp ./native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./$DIST_PATH/
+ cp ./native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./$DIST_PATH/spine.wasm.js
+ cp ./native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./$DIST_PATH/
+ cp ./native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./$DIST_PATH/spine.asm.js
+ mkdir -p ./native/external/emscripten/spine/$SPINE_VERSION
+ echo "-------- Before replace spine wasm -----------"
+ ls -l ./native/external/emscripten/spine/$SPINE_VERSION
+ cp -f ./$DIST_PATH/* ./native/external/emscripten/spine/$SPINE_VERSION
+ echo "-------- After replace spine wasm ------------"
+ ls -l ./native/external/emscripten/spine/$SPINE_VERSION
+ echo "-----------------------------------------------"
+ cd ./native/external
+ git status
+
+ - name: Build Spine 4.2 WASM
+ run: |
+ cd ./native/cocos/editor-support/spine-wasm
+ sed -i 's/set(BUILD_WASM 0)/set(BUILD_WASM 1)/g' CMakeLists.txt
+ sed -i 's/set(SPINE_VERSION "3.8")/set(SPINE_VERSION "4.2")/g' CMakeLists.txt
+ rm -rf build-wasm
+ mkdir build-wasm
+ cd build-wasm
+ emcmake cmake .. -GNinja
+ ninja
+ ls -l
+
+ - name: Build Spine 4.2 ASMJS
+ run: |
+ cd ./native/cocos/editor-support/spine-wasm
+ sed -i 's/set(SPINE_VERSION "3.8")/set(SPINE_VERSION "4.2")/g' CMakeLists.txt
+ sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
+ rm -rf build-asmjs
+ mkdir build-asmjs
+ cd build-asmjs
+ emcmake cmake .. -GNinja
+ ninja
+ ls -l
+
+ - name: Copy Spine 4.2 files to external directory
+ run: |
+ DIST_PATH="dist/4.2"
+ rm -rf $DIST_PATH
+ mkdir -p $DIST_PATH
+ cp ./native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./$DIST_PATH/
+ cp ./native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./$DIST_PATH/spine.wasm.js
+ cp ./native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./$DIST_PATH/
+ cp ./native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./$DIST_PATH/spine.asm.js
+ mkdir -p ./native/external/emscripten/spine/4.2/
+ echo "-------- Before replace spine wasm -----------"
+ ls -l ./native/external/emscripten/spine/4.2/
+ cp -f ./$DIST_PATH/* ./native/external/emscripten/spine/4.2/
+ echo "-------- After replace spine wasm ------------"
+ ls -l ./native/external/emscripten/spine/4.2/
+ echo "-----------------------------------------------"
+ cd ./native/external
+ git status
+
- name: npm install
run: |
npm install
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 1c60da72a1..2bc4de1795 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -19,7 +19,19 @@
"source.fixAll": "explicit",
},
"files.associations": {
- "iterator": "cpp"
+ "*.cmake": "makefile",
+ "iterator": "cpp",
+ "*.ipp": "cpp",
+ "filesystem": "cpp",
+ "chrono": "cpp",
+ "random": "cpp",
+ "string": "cpp",
+ "regex": "cpp",
+ "xlocale": "cpp",
+ "xstring": "cpp",
+ "tuple": "cpp",
+ "vector": "cpp",
+ "istream": "c"
},
"cmake.configureOnOpen": false,
}
diff --git a/EngineErrorMap.md b/EngineErrorMap.md
index 43718a6770..ff8721296f 100644
--- a/EngineErrorMap.md
+++ b/EngineErrorMap.md
@@ -277,7 +277,7 @@ Failed to initialize render pipeline.
### 1223
-Custom pipeline and legacy pipeline are all culled.
+Custom pipeline and legacy pipeline are all culled.
### 1300
@@ -3471,7 +3471,7 @@ The shadow visible distance is so small that CSM stratification is not effective
### 15004
-The native folder may be generated from older versions, please refer https://docs.cocos.com/creator/manual/en/release-notes/ to upgrade.
+The native folder may be generated from older versions, please refer to upgrade.
### 15100
@@ -3495,11 +3495,11 @@ Camera '%s' clear flag is skybox, but skybox is disabled, may cause strange bac
### 16101
-The effect('%s') you are looking for does not exist, please confirm the effect name in the editor. NOTE: Since 3.6, the name of the built-in effect has been changed to its name in the editor, please check it out. More information please refer to https://docs.cocos.com/creator/manual/en/shader/effect-inspector.html
+The effect('%s') you are looking for does not exist, please confirm the effect name in the editor. NOTE: Since 3.6, the name of the built-in effect has been changed to its name in the editor, please check it out. More information please refer to
### 16201
-The asset replacing failed, can not found override asset('%s') for '%s'
+The asset replacing failed, can not found override asset('%s') for '%s'
### 16301
@@ -3932,3 +3932,47 @@ Spline error: invalid mode
### 16408
[Physics2D] b2PolygonShape failed to decompose polygon into convex polygons, node name: %s
+
+### 16409
+
+setVertexEffectDelegate is deprecated since spine 4.2.
+
+### 16410
+
+Debug bones or slots is invalid in cached mode.
+
+### 16411
+
+Slots visible range can not be modified in cached mode.
+
+### 16412
+
+Track index can not greater than 0 in cached mode.
+
+### 16413
+
+Track index can not greater than 0 in cached mode.
+
+### 16414
+
+'getCurrent' interface can not be invoked in cached mode.
+
+### 16415
+
+cached mode not support setMix!!!
+
+### 16416
+
+'clearTracks' interface can not be invoked in cached mode.
+
+### 16417
+
+'clearTrack' interface can not be invoked in cached mode.
+
+### 16418
+
+Debug bones or slots is invalid in cached mode.
+
+### 16419
+
+Spine version not supported.
diff --git a/cc.config.json b/cc.config.json
index 4a084047a1..26b3013d49 100644
--- a/cc.config.json
+++ b/cc.config.json
@@ -193,13 +193,27 @@
"vendor-google": {
"modules": ["vendor-google"]
},
- "spine": {
+ "spine-3.8": {
"modules": ["spine"],
"dependentAssets": [
"c27215d8-6835-4b68-bfbb-bdeac6100c04",
"b5d6115f-0370-4d7c-aad3-c194cc71cf98"
],
- "dependentModules": ["2d"]
+ "dependentModules": ["2d"],
+ "intrinsicFlags": {
+ "SPINE_3_8": true
+ }
+ },
+ "spine-4.2": {
+ "modules": ["spine"],
+ "dependentAssets": [
+ "c27215d8-6835-4b68-bfbb-bdeac6100c04",
+ "b5d6115f-0370-4d7c-aad3-c194cc71cf98"
+ ],
+ "dependentModules": ["2d"],
+ "intrinsicFlags": {
+ "SPINE_4_2": true
+ }
},
"dragon-bones": {
"modules": ["dragon-bones"],
@@ -429,6 +443,22 @@
"overrides": {
"cocos/animation/marionette/pose-graph/runtime-exports.ts": "cocos/animation/marionette/pose-graph/runtime-exports-empty.ts"
}
+ },
+ {
+ "test": "context.buildTimeConstants.SPINE_3_8",
+ "isVirtualModule": false,
+ "overrides": {
+ "cocos/spine/lib/spine-version.ts": "cocos/spine/lib/spine-version-3.8.ts",
+ "cocos/spine/lib/spine-instantiate.ts": "cocos/spine/lib/spine-instantiate-3.8.ts"
+ }
+ },
+ {
+ "test": "context.buildTimeConstants.SPINE_4_2",
+ "isVirtualModule": false,
+ "overrides": {
+ "cocos/spine/lib/spine-version.ts": "cocos/spine/lib/spine-version-4.2.ts",
+ "cocos/spine/lib/spine-instantiate.ts": "cocos/spine/lib/spine-instantiate-4.2.ts"
+ }
}
],
"includes": [
diff --git a/cocos/spine/index.jsb.ts b/cocos/spine/index.jsb.ts
index 06515f66fe..5bd0f9b750 100644
--- a/cocos/spine/index.jsb.ts
+++ b/cocos/spine/index.jsb.ts
@@ -25,6 +25,7 @@
import { ccenum } from '../core';
import { legacyCC } from '../core/global-exports';
import spineLib from './lib/spine-core';
+import { SPINE_VERSION } from './lib/spine-version';
/**
* @en
@@ -47,6 +48,7 @@ import spineLib from './lib/spine-core';
export * from './skeleton';
export * from './skeleton-data';
export * from './assembler';
+export * from './lib/spine-version';
export const spine = globalThis.spine;
spine.EventType = spineLib.EventType
@@ -111,6 +113,7 @@ export enum AnimationEventType {
ccenum(AnimationEventType);
legacyCC.internal.SpineAnimationEventType = AnimationEventType;
+legacyCC.internal.SPINE_VERSION = SPINE_VERSION;
export function loadWasmModuleSpine (): Promise {
return Promise.resolve();
diff --git a/cocos/spine/index.ts b/cocos/spine/index.ts
index 8bcfb6bb81..fd48de21b3 100644
--- a/cocos/spine/index.ts
+++ b/cocos/spine/index.ts
@@ -49,6 +49,7 @@ export * from './skeleton';
export * from './skeleton-data';
export * from './vertex-effect-delegate';
export * from './assembler';
+export * from './lib/spine-version';
export { spine };
diff --git a/cocos/spine/lib/instantiated.ts b/cocos/spine/lib/instantiated.ts
index 856f059906..8cf02c15c8 100644
--- a/cocos/spine/lib/instantiated.ts
+++ b/cocos/spine/lib/instantiated.ts
@@ -22,108 +22,15 @@
THE SOFTWARE.
*/
-import { instantiateWasm, fetchBuffer, ensureWasmModuleReady } from 'pal/wasm';
-import { BUILD, JSB, LOAD_SPINE_MANUALLY, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
+import { BUILD, JSB, LOAD_SPINE_MANUALLY } from 'internal:constants';
import { game } from '../../game';
-import { error, sys } from '../../core';
-import { NativeCodeBundleMode } from '../../misc/webassembly-support';
-import { overrideSpineDefine } from './spine-define';
-
-const PAGESIZE = 65536; // 64KiB
-
-// How many pages of the wasm memory
-// TODO: let this can be canfiguable by user.
-const PAGECOUNT = 32 * 16;
-
-// How mush memory size of the wasm memory
-const MEMORYSIZE = PAGESIZE * PAGECOUNT; // 32 MiB
-
-let wasmInstance: SpineWasm.instance = null!;
-const registerList: any[] = [];
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-function initWasm (wasmFactory, wasmUrl: string): Promise {
- return new Promise((resolve, reject) => {
- const errorMessage = (err: any): string => `[Spine]: Spine wasm load failed: ${err}`;
- wasmFactory({
- instantiateWasm (
- importObject: WebAssembly.Imports,
- receiveInstance: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void,
- ) {
- // NOTE: the Promise return by instantiateWasm hook can't be caught.
- instantiateWasm(wasmUrl, importObject).then((result) => {
- receiveInstance(result.instance, result.module);
- }).catch((err) => reject(errorMessage(err)));
- },
- }).then((Instance: any) => {
- wasmInstance = Instance;
- registerList.forEach((cb) => {
- cb(wasmInstance);
- });
- }).then(resolve).catch((err: any) => reject(errorMessage(err)));
- });
-}
-
-function initAsmJS (asmFactory, asmJsMemUrl: string): Promise {
- return new Promise((resolve, reject) => {
- fetchBuffer(asmJsMemUrl).then((arrayBuffer) => {
- const wasmMemory: any = {};
- wasmMemory.buffer = new ArrayBuffer(MEMORYSIZE);
- const module = {
- wasmMemory,
- memoryInitializerRequest: {
- response: arrayBuffer,
- status: 200,
- } as Partial,
- };
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
- return asmFactory(module).then((instance: any) => {
- wasmInstance = instance;
- registerList.forEach((cb) => {
- cb(wasmInstance);
- });
- });
- }).then(resolve).catch(reject);
- });
-}
-
-function shouldUseWasmModule (): boolean {
- if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.BOTH as number)) {
- return sys.hasFeature(sys.Feature.WASM);
- } else if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.WASM as number)) {
- return true;
- } else {
- return false;
- }
-}
-
-export function waitForSpineWasmInstantiation (): Promise {
- const errorReport = (msg: any): void => { error(msg); };
- return ensureWasmModuleReady().then(() => {
- if (shouldUseWasmModule()) {
- return Promise.all([
- import('external:emscripten/spine/spine.wasm.js'),
- import('external:emscripten/spine/spine.wasm'),
- ]).then(([
- { default: wasmFactory },
- { default: spineWasmUrl },
- ]) => initWasm(wasmFactory, spineWasmUrl));
- } else {
- return Promise.all([
- import('external:emscripten/spine/spine.asm.js'),
- import('external:emscripten/spine/spine.js.mem'),
- ]).then(([
- { default: asmFactory },
- { default: asmJsMemUrl },
- ]) => initAsmJS(asmFactory, asmJsMemUrl));
- }
- }).catch(errorReport);
-}
+import './spine-define'; // Make spine._overrideSpineDefine take effect.
+import { waitForSpineWasmInstantiation } from './spine-instantiate';
if (!JSB && (!BUILD || !LOAD_SPINE_MANUALLY)) {
game.onPostInfrastructureInitDelegate.add(waitForSpineWasmInstantiation);
}
-registerList.push(overrideSpineDefine);
+export { waitForSpineWasmInstantiation };
export const SPINE_WASM = 1;
diff --git a/cocos/spine/lib/spine-core.d.ts b/cocos/spine/lib/spine-core.d.ts
index 7fdd2f506d..b838a26ae8 100644
--- a/cocos/spine/lib/spine-core.d.ts
+++ b/cocos/spine/lib/spine-core.d.ts
@@ -50,10 +50,35 @@ declare namespace spine {
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void;
hasTimeline(id: number): boolean;
}
- interface Timeline {
+
+ abstract class Timeline {
+ /**
+ * @version 4.2
+ */
+ frames: ArrayLike;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void;
+ /**
+ * @version 4.2
+ */
+ getPropertyIds(): ArrayLike;
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
getPropertyId(): number;
+ /**
+ * @version 4.2
+ */
+ getFrameCount(): number;
+ /**
+ * @version 4.2
+ */
+ getFrameEntries(): number;
+ /**
+ * @version 4.2
+ */
+ getDuration(): number;
}
+
enum MixBlend {
setup = 0,
first = 1,
@@ -86,9 +111,28 @@ declare namespace spine {
static readonly STEPPED: number;
static readonly BEZIER: number;
static readonly BEZIER_SIZE: number;
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
abstract getPropertyId(): number;
constructor(frameCount: number);
getFrameCount(): number;
+ /**
+ * @version 4.2
+ */
+ frames: ArrayLike;
+ /**
+ * @version 4.2
+ */
+ getPropertyIds(): ArrayLike;
+ /**
+ * @version 4.2
+ */
+ getFrameEntries(): number;
+ /**
+ * @version 4.2
+ */
+ getDuration(): number;
setLinear(frameIndex: number): void;
setStepped(frameIndex: number): void;
getCurveType(frameIndex: number): number;
@@ -102,16 +146,28 @@ declare namespace spine {
static PREV_ROTATION: number;
static ROTATION: number;
boneIndex: number;
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
frames: ArrayLike;
constructor(frameCount: number);
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
getPropertyId(): number;
setFrame(frameIndex: number, time: number, degrees: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class TranslateTimeline extends CurveTimeline {
static readonly ENTRIES: number;
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
frames: ArrayLike;
constructor(frameCount: number);
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
getPropertyId(): number;
setFrame(frameIndex: number, time: number, x: number, y: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void;
@@ -123,9 +179,16 @@ declare namespace spine {
}
class ShearTimeline extends TranslateTimeline {
constructor(frameCount: number);
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
+
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
class ColorTimeline extends CurveTimeline {
static ENTRIES: number;
slotIndex: number;
@@ -137,6 +200,10 @@ declare namespace spine {
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
+
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
class TwoColorTimeline extends CurveTimeline {
static readonly ENTRIES: number;
slotIndex: number;
@@ -148,11 +215,38 @@ declare namespace spine {
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
+
+ /**
+ * @version 4.2
+ */
+ class RGBATimeline extends CurveTimeline {
+ static ENTRIES: number;
+ slotIndex: number;
+ constructor(frameCount: number, bezierCount: number, slotIndex: number);
+ getSlotIndex(): number;
+ getPropertyId(): number;
+ setSlotIndex(inValue: number): void;
+ setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
+ apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void;
+ }
+
class AttachmentTimeline implements Timeline {
slotIndex: number;
frames: ArrayLike;
attachmentNames: Array;
constructor(frameCount: number);
+ /**
+ * @version 4.2
+ */
+ getPropertyIds(): ArrayLike;
+ /**
+ * @version 4.2
+ */
+ getFrameEntries(): number;
+ /**
+ * @version 4.2
+ */
+ getDuration(): number;
getPropertyId(): number;
getFrameCount(): number;
getSlotIndex(): number;
@@ -175,6 +269,18 @@ declare namespace spine {
frames: ArrayLike;
events: Array;
constructor(frameCount: number);
+ /**
+ * @version 4.2
+ */
+ getPropertyIds(): ArrayLike;
+ /**
+ * @version 4.2
+ */
+ getFrameEntries(): number;
+ /**
+ * @version 4.2
+ */
+ getDuration(): number;
getPropertyId(): number;
getFrameCount(): number;
setFrame(frameIndex: number, event: Event): void;
@@ -184,6 +290,18 @@ declare namespace spine {
frames: ArrayLike;
drawOrders: Array>;
constructor(frameCount: number);
+ /**
+ * @version 4.2
+ */
+ getPropertyIds(): ArrayLike;
+ /**
+ * @version 4.2
+ */
+ getFrameEntries(): number;
+ /**
+ * @version 4.2
+ */
+ getDuration(): number;
getPropertyId(): number;
getFrameCount(): number;
setFrame(frameIndex: number, time: number, drawOrder: Array): void;
@@ -528,8 +646,26 @@ declare namespace spine {
offsetRotation: number;
position: number;
spacing: number;
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
rotateMix: number;
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
translateMix: number;
+ /**
+ * @version 4.2
+ */
+ mixRotate: number;
+ /**
+ * @version 4.2
+ */
+ mixX: number;
+ /**
+ * @version 4.2
+ */
+ mixY: number;
constructor(name: string);
}
enum PositionMode {
@@ -688,6 +824,9 @@ declare namespace spine {
findBone(boneName: string): BoneData;
findBoneIndex(boneName: string): number;
findSlot(slotName: string): SlotData;
+ /**
+ * @version 3.8, deprecated in 4.2
+ */
findSlotIndex(slotName: string): number;
findSkin(skinName: string): Skin;
findEvent(eventDataName: string): EventData;
diff --git a/cocos/spine/lib/spine-define.ts b/cocos/spine/lib/spine-define.ts
index b84e7b8fe8..d5730a467b 100644
--- a/cocos/spine/lib/spine-define.ts
+++ b/cocos/spine/lib/spine-define.ts
@@ -25,6 +25,7 @@
/* eslint @typescript-eslint/no-unsafe-argument: "off" */
import spine from './spine-core';
+import { SPINE_VERSION } from './spine-version';
import { js } from '../../core';
function resizeArray (array: any[], newSize: number): any[] {
@@ -272,9 +273,16 @@ function overrideProperty_ColorTimeline (): void {
overrideDefineArrayProp(prototype, prototype.getFrames, 'frames');
}
+function overrideProperty_Timeline (): void {
+ const prototype = spine.Timeline.prototype as any;
+ overrideDefineArrayProp(prototype, prototype.getFrames, 'frames');
+}
+
function overrideProperty_AttachmentTimeline (): void {
const prototype = spine.AttachmentTimeline.prototype as any;
- overrideDefineArrayProp(prototype, prototype.getFrames, 'frames');
+ if (SPINE_VERSION === '3.8') {
+ overrideDefineArrayProp(prototype, prototype.getFrames, 'frames');
+ }
overrideDefineArrayProp(prototype, prototype.getAttachmentNames, 'attachmentNames');
}
@@ -335,7 +343,11 @@ export function overrideSpineDefine (wasm): void {
overrideProperty_SkinEntry();
overrideProperty_SkeletonData();
overrideProperty_RotateTimeline();
- overrideProperty_ColorTimeline();
+ if (SPINE_VERSION === '3.8') {
+ overrideProperty_ColorTimeline();
+ } else if (SPINE_VERSION === '4.2') {
+ overrideProperty_Timeline();
+ }
overrideProperty_AttachmentTimeline();
overrideProperty_DeformTimeline();
overrideProperty_EventTimeline();
diff --git a/cocos/spine/lib/spine-instantiate-3.8.ts b/cocos/spine/lib/spine-instantiate-3.8.ts
new file mode 100644
index 0000000000..95668dd5ea
--- /dev/null
+++ b/cocos/spine/lib/spine-instantiate-3.8.ts
@@ -0,0 +1,50 @@
+/*
+ Copyright (c) 2025 Xiamen Yaji Software Co., Ltd.
+
+ https://www.cocos.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+import { ensureWasmModuleReady } from 'pal/wasm';
+import { error } from '../../core';
+import { shouldUseWasmModule, initWasm, initAsmJS } from './spine-wasm-utils';
+
+export function waitForSpineWasmInstantiation (): Promise {
+ const errorReport = (msg: any): void => { error(msg); };
+ return ensureWasmModuleReady().then((): Promise => {
+ //We should use static code here, import operation will cause file copy to cache folder.
+ if (shouldUseWasmModule()) {
+ return Promise.all([
+ import('external:emscripten/spine/3.8/spine.wasm.js'),
+ import('external:emscripten/spine/3.8/spine.wasm'),
+ ]).then(([
+ { default: wasmFactory },
+ { default: spineWasmUrl },
+ ]) => initWasm(wasmFactory, spineWasmUrl));
+ } else {
+ return Promise.all([
+ import('external:emscripten/spine/3.8/spine.asm.js'),
+ import('external:emscripten/spine/3.8/spine.js.mem'),
+ ]).then(([
+ { default: asmFactory },
+ { default: asmJsMemUrl },
+ ]) => initAsmJS(asmFactory, asmJsMemUrl));
+ }
+ }).catch(errorReport);
+}
diff --git a/cocos/spine/lib/spine-instantiate-4.2.ts b/cocos/spine/lib/spine-instantiate-4.2.ts
new file mode 100644
index 0000000000..f8a4a7ed4a
--- /dev/null
+++ b/cocos/spine/lib/spine-instantiate-4.2.ts
@@ -0,0 +1,51 @@
+/*
+ Copyright (c) 2025 Xiamen Yaji Software Co., Ltd.
+
+ https://www.cocos.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+import { ensureWasmModuleReady } from 'pal/wasm';
+import { error } from '../../core';
+import { shouldUseWasmModule, initWasm, initAsmJS } from './spine-wasm-utils';
+
+export function waitForSpineWasmInstantiation (): Promise {
+ const errorReport = (msg: any): void => { error(msg); };
+ return ensureWasmModuleReady().then((): Promise => {
+ //We should use static code here, import operation will cause file copy to cache folder.
+ if (shouldUseWasmModule()) {
+ return Promise.all([
+ import('external:emscripten/spine/4.2/spine.wasm.js'),
+ import('external:emscripten/spine/4.2/spine.wasm'),
+ ]).then(([
+ { default: wasmFactory },
+ { default: spineWasmUrl },
+ ]) => initWasm(wasmFactory, spineWasmUrl));
+ } else {
+ return Promise.all([
+ import('external:emscripten/spine/4.2/spine.asm.js'),
+ import('external:emscripten/spine/4.2/spine.js.mem'),
+ ]).then(([
+ { default: asmFactory },
+ { default: asmJsMemUrl },
+ ]) => initAsmJS(asmFactory, asmJsMemUrl));
+ }
+ }).catch(errorReport);
+}
diff --git a/cocos/spine/lib/spine-instantiate.ts b/cocos/spine/lib/spine-instantiate.ts
new file mode 100644
index 0000000000..5c79cecc05
--- /dev/null
+++ b/cocos/spine/lib/spine-instantiate.ts
@@ -0,0 +1,33 @@
+/*
+ Copyright (c) 2025 Xiamen Yaji Software Co., Ltd.
+
+ https://www.cocos.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+// Defining the following import to make ts compiler know these files
+// spine-instantiate.ts will be overriden by spine-instantiate-3.8.ts or spine-instantiate-4.2.ts while building engine.
+// See 'moduleOverrides' section in cc.config.json.
+import './spine-instantiate-3.8';
+import './spine-instantiate-4.2';
+
+export function waitForSpineWasmInstantiation (): Promise {
+ return null!;
+}
diff --git a/cocos/spine/lib/spine-version-3.8.ts b/cocos/spine/lib/spine-version-3.8.ts
new file mode 100644
index 0000000000..22921abcf2
--- /dev/null
+++ b/cocos/spine/lib/spine-version-3.8.ts
@@ -0,0 +1,25 @@
+/*
+ Copyright (c) 2025 Xiamen Yaji Software Co., Ltd.
+
+ https://www.cocos.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+export const SPINE_VERSION = '3.8';
diff --git a/cocos/spine/lib/spine-version-4.2.ts b/cocos/spine/lib/spine-version-4.2.ts
new file mode 100644
index 0000000000..f1fdb5514c
--- /dev/null
+++ b/cocos/spine/lib/spine-version-4.2.ts
@@ -0,0 +1,25 @@
+/*
+ Copyright (c) 2025 Xiamen Yaji Software Co., Ltd.
+
+ https://www.cocos.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+export const SPINE_VERSION = '4.2';
diff --git a/cocos/spine/lib/spine-version.ts b/cocos/spine/lib/spine-version.ts
new file mode 100644
index 0000000000..22921abcf2
--- /dev/null
+++ b/cocos/spine/lib/spine-version.ts
@@ -0,0 +1,25 @@
+/*
+ Copyright (c) 2025 Xiamen Yaji Software Co., Ltd.
+
+ https://www.cocos.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+export const SPINE_VERSION = '3.8';
diff --git a/cocos/spine/lib/spine-wasm-utils.ts b/cocos/spine/lib/spine-wasm-utils.ts
new file mode 100644
index 0000000000..7b1aabaf07
--- /dev/null
+++ b/cocos/spine/lib/spine-wasm-utils.ts
@@ -0,0 +1,75 @@
+import { instantiateWasm, fetchBuffer } from 'pal/wasm';
+import { NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
+import { sys } from '../../core';
+import { NativeCodeBundleMode } from '../../misc/webassembly-support';
+import { overrideSpineDefine } from './spine-define';
+
+const PAGESIZE = 65536; // 64KiB
+
+// How many pages of the wasm memory
+// TODO: let this can be canfiguable by user.
+const PAGECOUNT = 32 * 16;
+
+// How mush memory size of the wasm memory
+const MEMORYSIZE = PAGESIZE * PAGECOUNT; // 32 MiB
+
+let wasmInstance: SpineWasm.instance = null!;
+const registerList: any[] = [];
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+export function initWasm (wasmFactory, wasmUrl: string): Promise {
+ return new Promise((resolve, reject) => {
+ const errorMessage = (err: any): string => `[Spine]: Spine wasm load failed: ${err}`;
+ wasmFactory({
+ instantiateWasm (
+ importObject: WebAssembly.Imports,
+ receiveInstance: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void,
+ ) {
+ // NOTE: the Promise return by instantiateWasm hook can't be caught.
+ instantiateWasm(wasmUrl, importObject).then((result) => {
+ receiveInstance(result.instance, result.module);
+ }).catch((err) => reject(errorMessage(err)));
+ },
+ }).then((Instance: any) => {
+ wasmInstance = Instance;
+ registerList.forEach((cb) => {
+ cb(wasmInstance);
+ });
+ }).then(resolve).catch((err: any) => reject(errorMessage(err)));
+ });
+}
+
+export function initAsmJS (asmFactory, asmJsMemUrl: string): Promise {
+ return new Promise((resolve, reject) => {
+ fetchBuffer(asmJsMemUrl).then((arrayBuffer) => {
+ const wasmMemory: any = {};
+ wasmMemory.buffer = new ArrayBuffer(MEMORYSIZE);
+ const module = {
+ wasmMemory,
+ memoryInitializerRequest: {
+ response: arrayBuffer,
+ status: 200,
+ } as Partial,
+ };
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
+ return asmFactory(module).then((instance: any) => {
+ wasmInstance = instance;
+ registerList.forEach((cb) => {
+ cb(wasmInstance);
+ });
+ });
+ }).then(resolve).catch(reject);
+ });
+}
+
+export function shouldUseWasmModule (): boolean {
+ if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.BOTH as number)) {
+ return sys.hasFeature(sys.Feature.WASM);
+ } else if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.WASM as number)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+registerList.push(overrideSpineDefine);
diff --git a/cocos/spine/skeleton.ts b/cocos/spine/skeleton.ts
index ae6b988951..069a64cb9c 100644
--- a/cocos/spine/skeleton.ts
+++ b/cocos/spine/skeleton.ts
@@ -24,7 +24,7 @@
import { EDITOR_NOT_IN_PREVIEW, JSB } from 'internal:constants';
import { ccclass, executeInEditMode, help, menu, serializable, type, override, displayOrder, editable, visible } from 'cc.decorator';
import { Material, Texture2D } from '../asset/assets';
-import { error, errorID, logID, warn } from '../core/platform/debug';
+import { error, errorID, logID, warnID } from '../core/platform/debug';
import { Enum, EnumType, ccenum } from '../core/value-types/enum';
import { Node, NodeEventType } from '../scene-graph';
import { CCObjectFlags, Color, RecyclePool, js } from '../core';
@@ -45,6 +45,7 @@ import SkeletonCache, { AnimationCache, AnimationFrame, SkeletonCacheItemInfo }
import { TrackEntryListeners } from './track-entry-listeners';
import { setPropertyEnumType } from '../core/internal-index';
import { RenderData } from '../2d/renderer/render-data';
+import { SPINE_VERSION } from './lib/spine-version';
const CachedFrameTime = 1 / 60;
@@ -783,7 +784,12 @@ export class Skeleton extends UIRenderer {
it will cause rendering issues when a prefab with Spine assets is added to the scene node tree.
*/
if (this.defaultSkin && this.defaultSkin !== '') this.setSkin(this.defaultSkin);
- if (this.defaultAnimation) this.animation = this.defaultAnimation.toString();
+ if (this.defaultAnimation) {
+ this.animation = this.defaultAnimation.toString();
+ } else if (this._animationName) {
+ this.animation = this._animationName;
+ }
+
this._updateUseTint();
this._indexBoneSockets();
this._updateSocketBindings();
@@ -821,7 +827,7 @@ export class Skeleton extends UIRenderer {
}
if (this.isAnimationCached()) {
if (this.debugBones || this.debugSlots) {
- warn('Debug bones or slots is invalid in cached mode');
+ warnID(16410);
}
const skeletonInfo = this._skeletonCache!.getSkeletonInfo(this._skeletonData!);
if (this._skeletonInfo !== skeletonInfo) {
@@ -848,7 +854,7 @@ export class Skeleton extends UIRenderer {
*/
public setSlotsRange (startSlotIndex: number, endSlotIndex: number): void {
if (this.isAnimationCached()) {
- warn('Slots visible range can not be modified in cached mode.');
+ warnID(16411);
} else {
this._startSlotIndex = startSlotIndex;
this._endSlotIndex = endSlotIndex;
@@ -928,7 +934,7 @@ export class Skeleton extends UIRenderer {
this._playTimes = loop ? 0 : 1;
if (this.isAnimationCached()) {
if (trackIndex !== 0) {
- warn('Track index can not greater than 0 in cached mode.');
+ warnID(16412);
}
if (!this._skeletonCache) return null;
let cache = this._skeletonCache.getAnimationCache(this._skeletonData!.uuid, name);
@@ -970,7 +976,7 @@ export class Skeleton extends UIRenderer {
delay = delay || 0;
if (this.isAnimationCached()) {
if (trackIndex !== 0) {
- warn('Track index can not greater than 0 in cached mode.');
+ warnID(16413);
}
this._animationQueue.push({ animationName: name, loop, delay });
return null;
@@ -1006,7 +1012,7 @@ export class Skeleton extends UIRenderer {
*/
public getCurrent (trackIndex: number): spine.TrackEntry | null {
if (this.isAnimationCached()) {
- warn('\'getCurrent\' interface can not be invoked in cached mode.');
+ warnID(16414);
} else if (this._state) {
return this._state.getCurrent(trackIndex);
}
@@ -1462,7 +1468,7 @@ export class Skeleton extends UIRenderer {
*/
public setMix (fromAnimation: string, toAnimation: string, duration: number): void {
if (this.isAnimationCached()) {
- warn('cached mode not support setMix!!!');
+ warnID(16415);
return;
}
if (this._state) {
@@ -1477,7 +1483,7 @@ export class Skeleton extends UIRenderer {
*/
public clearTracks (): void {
if (this.isAnimationCached()) {
- warn('\'clearTracks\' interface can not be invoked in cached mode.');
+ warnID(16416);
} else if (this._state) {
this._state.clearTracks();
this.setToSetupPose();
@@ -1491,7 +1497,7 @@ export class Skeleton extends UIRenderer {
*/
public clearTrack (trackIndex: number): void {
if (this.isAnimationCached()) {
- warn('\'clearTrack\' interface can not be invoked in cached mode.');
+ warnID(16417);
} else if (this._state) {
this._state.clearTrack(trackIndex);
if (EDITOR_NOT_IN_PREVIEW) {
@@ -1638,7 +1644,7 @@ export class Skeleton extends UIRenderer {
}
}
if (this.isAnimationCached()) {
- warn('Debug bones or slots is invalid in cached mode');
+ warnID(16418);
} else if (!JSB) {
this._instance!.setDebugMode(true);
}
@@ -1699,11 +1705,16 @@ export class Skeleton extends UIRenderer {
}
/**
+ * @version 3.8, deprecated since spine 4.2
* @en Sets vertex effect delegate.
* @zh 设置顶点特效动画代理。
* @param effectDelegate @en Vertex effect delegate. @zh 顶点特效代理。
*/
public setVertexEffectDelegate (effectDelegate: VertexEffectDelegate | null | undefined): void {
+ if (SPINE_VERSION !== '3.8') {
+ warnID(16409);
+ return;
+ }
if (!this._instance) {
return;
}
diff --git a/editor/engine-features/render-config.json b/editor/engine-features/render-config.json
index e699b511cb..6c9ff8dc52 100644
--- a/editor/engine-features/render-config.json
+++ b/editor/engine-features/render-config.json
@@ -375,22 +375,42 @@
"hidden": true
},
"spine": {
- "default": true,
"label": "i18n:ENGINE.features.spine.label",
"description": "i18n:ENGINE.features.spine.description",
- "cmakeConfig": "USE_SPINE",
"isNativeModule": true,
- "enginePlugin": true,
+ "enginePlugin": false,
"category": "2d",
"dependencies": [
"2d"
],
- "flags": {
- "LOAD_SPINE_MANUALLY": {
- "label": "i18n:ENGINE.features.flags.spine.loadManual.label",
- "description": "i18n:ENGINE.features.flags.spine.loadManual.description",
- "ui-type": "checkbox",
- "default": false
+ "options": {
+ "spine-3.8": {
+ "cmakeConfig": "USE_SPINE_3_8",
+ "default": true,
+ "label": "i18n:ENGINE.features.spine_38.label",
+ "description": "i18n:ENGINE.features.spine_38.description",
+ "flags": {
+ "LOAD_SPINE_MANUALLY": {
+ "label": "i18n:ENGINE.features.flags.spine.loadManual.label",
+ "description": "i18n:ENGINE.features.flags.spine.loadManual.description",
+ "ui-type": "checkbox",
+ "default": false
+ }
+ }
+ },
+ "spine-4.2": {
+ "cmakeConfig": "USE_SPINE_4_2",
+ "default": false,
+ "label": "i18n:ENGINE.features.spine_42.label",
+ "description": "i18n:ENGINE.features.spine_42.description",
+ "flags": {
+ "LOAD_SPINE_MANUALLY": {
+ "label": "i18n:ENGINE.features.flags.spine.loadManual.label",
+ "description": "i18n:ENGINE.features.flags.spine.loadManual.description",
+ "ui-type": "checkbox",
+ "default": false
+ }
+ }
}
}
},
diff --git a/editor/i18n/en/localization.js b/editor/i18n/en/localization.js
index 25806beb87..81b4d170a1 100755
--- a/editor/i18n/en/localization.js
+++ b/editor/i18n/en/localization.js
@@ -1075,6 +1075,14 @@ module.exports = link(mixin({
label: "Spine Animation",
description: "Spine Animation support.",
},
+ spine_38: {
+ label: "Spine 3.8",
+ description: "Spine 3.8",
+ },
+ spine_42: {
+ label: "Spine 4.2",
+ description: "Spine 4.2",
+ },
dragon_bones: {
label: "Dragon Bones",
description: "Dragon Bones support.",
diff --git a/editor/i18n/zh/localization.js b/editor/i18n/zh/localization.js
index 849d99b2b5..baafc971a3 100755
--- a/editor/i18n/zh/localization.js
+++ b/editor/i18n/zh/localization.js
@@ -1053,6 +1053,14 @@ module.exports = link(mixin({
label: "Spine 动画",
description: "Spine 动画支持。",
},
+ spine_38: {
+ label: "Spine 3.8",
+ description: "Spine 3.8",
+ },
+ spine_42: {
+ label: "Spine 4.2",
+ description: "Spine 4.2",
+ },
dragon_bones: {
label: "Dragon Bones",
description: "Dragon Bones 支持。",
diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt
index 3f8c4b914b..8e7e10a004 100644
--- a/native/CMakeLists.txt
+++ b/native/CMakeLists.txt
@@ -28,6 +28,13 @@ cc_set_if_undefined(USE_VIDEO ON)
cc_set_if_undefined(USE_WEBVIEW ON)
cc_set_if_undefined(USE_MIDDLEWARE ON)
cc_set_if_undefined(USE_DRAGONBONES ON)
+cc_set_if_undefined(USE_SPINE_3_8 ON)
+cc_set_if_undefined(USE_SPINE_4_2 OFF)
+if (USE_SPINE_3_8 OR USE_SPINE_4_2)
+ cc_set_if_undefined(USE_SPINE ON)
+else()
+ cc_set_if_undefined(USE_SPINE OFF)
+endif()
cc_set_if_undefined(USE_SPINE ON)
cc_set_if_undefined(USE_WEBSOCKET_SERVER OFF)
cc_set_if_undefined(USE_JOB_SYSTEM_TASKFLOW OFF)
@@ -222,7 +229,8 @@ cc_inspect_values(
USE_WEBVIEW
USE_MIDDLEWARE
USE_DRAGONBONES
- USE_SPINE
+ USE_SPINE_3_8
+ USE_SPINE_4_2
USE_WEBSOCKET_SERVER
USE_PHYSICS_PHYSX
USE_JOB_SYSTEM_TBB
@@ -2316,184 +2324,363 @@ if(USE_MIDDLEWARE)
${SWIG_OUTPUT}/jsb_editor_support_auto.h
)
- if(USE_SPINE)
+ if(USE_SPINE_3_8)
+ include_directories(${CWD}/cocos/editor-support/spine/3.8)
cocos_source_files(
- NO_WERROR NO_UBUILD cocos/editor-support/spine/Animation.cpp
- cocos/editor-support/spine/Animation.h
- NO_WERROR NO_UBUILD cocos/editor-support/spine/AnimationState.cpp
- cocos/editor-support/spine/AnimationState.h
- NO_WERROR cocos/editor-support/spine/AnimationStateData.cpp
- cocos/editor-support/spine/AnimationStateData.h
- NO_WERROR cocos/editor-support/spine/Atlas.cpp
- cocos/editor-support/spine/Atlas.h
- NO_WERROR cocos/editor-support/spine/AtlasAttachmentLoader.cpp
- cocos/editor-support/spine/AtlasAttachmentLoader.h
- NO_WERROR cocos/editor-support/spine/Attachment.cpp
- cocos/editor-support/spine/Attachment.h
- NO_WERROR cocos/editor-support/spine/AttachmentLoader.cpp
- cocos/editor-support/spine/AttachmentLoader.h
- NO_WERROR cocos/editor-support/spine/AttachmentTimeline.cpp
- cocos/editor-support/spine/AttachmentTimeline.h
- cocos/editor-support/spine/AttachmentType.h
- cocos/editor-support/spine/BlendMode.h
- NO_WERROR cocos/editor-support/spine/Bone.cpp
- cocos/editor-support/spine/Bone.h
- NO_WERROR cocos/editor-support/spine/BoneData.cpp
- cocos/editor-support/spine/BoneData.h
- NO_WERROR cocos/editor-support/spine/BoundingBoxAttachment.cpp
- cocos/editor-support/spine/BoundingBoxAttachment.h
- NO_WERROR cocos/editor-support/spine/ClippingAttachment.cpp
- cocos/editor-support/spine/ClippingAttachment.h
- cocos/editor-support/spine/Color.h
- NO_WERROR cocos/editor-support/spine/ColorTimeline.cpp
- cocos/editor-support/spine/ColorTimeline.h
- NO_WERROR cocos/editor-support/spine/Constraint.cpp
- cocos/editor-support/spine/Constraint.h
- NO_WERROR NO_UBUILD cocos/editor-support/spine/ConstraintData.cpp
- cocos/editor-support/spine/ConstraintData.h
- cocos/editor-support/spine/ContainerUtil.h
- NO_WERROR cocos/editor-support/spine/CurveTimeline.cpp
- cocos/editor-support/spine/CurveTimeline.h
- cocos/editor-support/spine/Debug.h
- NO_WERROR cocos/editor-support/spine/DeformTimeline.cpp
- cocos/editor-support/spine/DeformTimeline.h
- cocos/editor-support/spine/dll.h
- NO_WERROR cocos/editor-support/spine/DrawOrderTimeline.cpp
- cocos/editor-support/spine/DrawOrderTimeline.h
- NO_WERROR cocos/editor-support/spine/Event.cpp
- cocos/editor-support/spine/Event.h
- NO_WERROR cocos/editor-support/spine/EventData.cpp
- cocos/editor-support/spine/EventData.h
- NO_WERROR cocos/editor-support/spine/EventTimeline.cpp
- cocos/editor-support/spine/EventTimeline.h
- NO_WERROR cocos/editor-support/spine/Extension.cpp
- cocos/editor-support/spine/Extension.h
- cocos/editor-support/spine/HashMap.h
- cocos/editor-support/spine/HasRendererObject.h
- NO_WERROR cocos/editor-support/spine/IkConstraint.cpp
- cocos/editor-support/spine/IkConstraint.h
- NO_WERROR cocos/editor-support/spine/IkConstraintData.cpp
- cocos/editor-support/spine/IkConstraintData.h
- NO_WERROR cocos/editor-support/spine/IkConstraintTimeline.cpp
- cocos/editor-support/spine/IkConstraintTimeline.h
- NO_WERROR cocos/editor-support/spine/Json.cpp
- cocos/editor-support/spine/Json.h
- NO_WERROR cocos/editor-support/spine/LinkedMesh.cpp
- cocos/editor-support/spine/LinkedMesh.h
- NO_WERROR cocos/editor-support/spine/MathUtil.cpp
- cocos/editor-support/spine/MathUtil.h
- NO_WERROR cocos/editor-support/spine/MeshAttachment.cpp
- cocos/editor-support/spine/MeshAttachment.h
- cocos/editor-support/spine/MixBlend.h
- cocos/editor-support/spine/MixDirection.h
- NO_WERROR cocos/editor-support/spine/PathAttachment.cpp
- cocos/editor-support/spine/PathAttachment.h
- NO_WERROR cocos/editor-support/spine/PathConstraint.cpp
- cocos/editor-support/spine/PathConstraint.h
- NO_WERROR cocos/editor-support/spine/PathConstraintData.cpp
- cocos/editor-support/spine/PathConstraintData.h
- NO_WERROR cocos/editor-support/spine/PathConstraintMixTimeline.cpp
- cocos/editor-support/spine/PathConstraintMixTimeline.h
- NO_WERROR cocos/editor-support/spine/PathConstraintPositionTimeline.cpp
- cocos/editor-support/spine/PathConstraintPositionTimeline.h
- NO_WERROR cocos/editor-support/spine/PathConstraintSpacingTimeline.cpp
- cocos/editor-support/spine/PathConstraintSpacingTimeline.h
- NO_WERROR cocos/editor-support/spine/PointAttachment.cpp
- cocos/editor-support/spine/PointAttachment.h
- cocos/editor-support/spine/Pool.h
- cocos/editor-support/spine/PositionMode.h
- NO_WERROR cocos/editor-support/spine/RegionAttachment.cpp
- cocos/editor-support/spine/RegionAttachment.h
- cocos/editor-support/spine/RotateMode.h
- NO_WERROR cocos/editor-support/spine/RotateTimeline.cpp
- cocos/editor-support/spine/RotateTimeline.h
- NO_WERROR cocos/editor-support/spine/RTTI.cpp
- cocos/editor-support/spine/RTTI.h
- NO_WERROR cocos/editor-support/spine/ScaleTimeline.cpp
- cocos/editor-support/spine/ScaleTimeline.h
- NO_WERROR cocos/editor-support/spine/ShearTimeline.cpp
- cocos/editor-support/spine/ShearTimeline.h
- NO_WERROR cocos/editor-support/spine/Skeleton.cpp
- cocos/editor-support/spine/Skeleton.h
- NO_WERROR cocos/editor-support/spine/SkeletonBinary.cpp
- cocos/editor-support/spine/SkeletonBinary.h
- NO_WERROR cocos/editor-support/spine/SkeletonBounds.cpp
- cocos/editor-support/spine/SkeletonBounds.h
- NO_WERROR cocos/editor-support/spine/SkeletonClipping.cpp
- cocos/editor-support/spine/SkeletonClipping.h
- NO_WERROR cocos/editor-support/spine/SkeletonData.cpp
- cocos/editor-support/spine/SkeletonData.h
- NO_WERROR cocos/editor-support/spine/SkeletonJson.cpp
- cocos/editor-support/spine/SkeletonJson.h
- NO_WERROR cocos/editor-support/spine/Skin.cpp
- cocos/editor-support/spine/Skin.h
- NO_WERROR cocos/editor-support/spine/Slot.cpp
- cocos/editor-support/spine/Slot.h
- NO_WERROR cocos/editor-support/spine/SlotData.cpp
- cocos/editor-support/spine/SlotData.h
- cocos/editor-support/spine/SpacingMode.h
- cocos/editor-support/spine/spine.h
- NO_WERROR cocos/editor-support/spine/SpineObject.cpp
- cocos/editor-support/spine/SpineObject.h
- cocos/editor-support/spine/SpineString.cpp
- cocos/editor-support/spine/SpineString.h
- NO_WERROR cocos/editor-support/spine/TextureLoader.cpp
- cocos/editor-support/spine/TextureLoader.h
- NO_WERROR cocos/editor-support/spine/Timeline.cpp
- cocos/editor-support/spine/Timeline.h
- cocos/editor-support/spine/TimelineType.h
- NO_WERROR cocos/editor-support/spine/TransformConstraint.cpp
- cocos/editor-support/spine/TransformConstraint.h
- NO_WERROR cocos/editor-support/spine/TransformConstraintData.cpp
- cocos/editor-support/spine/TransformConstraintData.h
- NO_WERROR cocos/editor-support/spine/TransformConstraintTimeline.cpp
- cocos/editor-support/spine/TransformConstraintTimeline.h
- cocos/editor-support/spine/TransformMode.h
- NO_WERROR cocos/editor-support/spine/TranslateTimeline.cpp
- cocos/editor-support/spine/TranslateTimeline.h
- NO_WERROR cocos/editor-support/spine/Triangulator.cpp
- cocos/editor-support/spine/Triangulator.h
- NO_WERROR cocos/editor-support/spine/TwoColorTimeline.cpp
- cocos/editor-support/spine/TwoColorTimeline.h
- NO_WERROR cocos/editor-support/spine/Updatable.cpp
- cocos/editor-support/spine/Updatable.h
- cocos/editor-support/spine/Vector.h
- NO_WERROR cocos/editor-support/spine/VertexAttachment.cpp
- cocos/editor-support/spine/VertexAttachment.h
- NO_WERROR cocos/editor-support/spine/VertexEffect.cpp
- cocos/editor-support/spine/VertexEffect.h
- cocos/editor-support/spine/Vertices.h
- NO_WERROR cocos/editor-support/spine-creator-support/AttachmentVertices.cpp
- cocos/editor-support/spine-creator-support/AttachmentVertices.h
- NO_WERROR cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp
- cocos/editor-support/spine-creator-support/SkeletonAnimation.h
- NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCache.cpp
- cocos/editor-support/spine-creator-support/SkeletonCache.h
- NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp
- cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h
- NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp
- cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h
- NO_WERROR cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp
- cocos/editor-support/spine-creator-support/SkeletonDataMgr.h
- NO_WERROR NO_UBUILD cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
- cocos/editor-support/spine-creator-support/SkeletonRenderer.h
- NO_WERROR cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp
- cocos/editor-support/spine-creator-support/spine-cocos2dx.h
+ NO_WERROR NO_UBUILD cocos/editor-support/spine/3.8/spine/Animation.cpp
+ cocos/editor-support/spine/3.8/spine/Animation.h
+ NO_WERROR NO_UBUILD cocos/editor-support/spine/3.8/spine/AnimationState.cpp
+ cocos/editor-support/spine/3.8/spine/AnimationState.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/AnimationStateData.cpp
+ cocos/editor-support/spine/3.8/spine/AnimationStateData.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Atlas.cpp
+ cocos/editor-support/spine/3.8/spine/Atlas.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/AtlasAttachmentLoader.cpp
+ cocos/editor-support/spine/3.8/spine/AtlasAttachmentLoader.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Attachment.cpp
+ cocos/editor-support/spine/3.8/spine/Attachment.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/AttachmentLoader.cpp
+ cocos/editor-support/spine/3.8/spine/AttachmentLoader.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/AttachmentTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/AttachmentTimeline.h
+ cocos/editor-support/spine/3.8/spine/AttachmentType.h
+ cocos/editor-support/spine/3.8/spine/BlendMode.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Bone.cpp
+ cocos/editor-support/spine/3.8/spine/Bone.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/BoneData.cpp
+ cocos/editor-support/spine/3.8/spine/BoneData.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/BoundingBoxAttachment.cpp
+ cocos/editor-support/spine/3.8/spine/BoundingBoxAttachment.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/ClippingAttachment.cpp
+ cocos/editor-support/spine/3.8/spine/ClippingAttachment.h
+ cocos/editor-support/spine/3.8/spine/Color.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/ColorTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/ColorTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Constraint.cpp
+ cocos/editor-support/spine/3.8/spine/Constraint.h
+ NO_WERROR NO_UBUILD cocos/editor-support/spine/3.8/spine/ConstraintData.cpp
+ cocos/editor-support/spine/3.8/spine/ConstraintData.h
+ cocos/editor-support/spine/3.8/spine/ContainerUtil.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/CurveTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/CurveTimeline.h
+ cocos/editor-support/spine/3.8/spine/Debug.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/DeformTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/DeformTimeline.h
+ cocos/editor-support/spine/3.8/spine/dll.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/DrawOrderTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/DrawOrderTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Event.cpp
+ cocos/editor-support/spine/3.8/spine/Event.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/EventData.cpp
+ cocos/editor-support/spine/3.8/spine/EventData.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/EventTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/EventTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Extension.cpp
+ cocos/editor-support/spine/3.8/spine/Extension.h
+ cocos/editor-support/spine/3.8/spine/HashMap.h
+ cocos/editor-support/spine/3.8/spine/HasRendererObject.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/IkConstraint.cpp
+ cocos/editor-support/spine/3.8/spine/IkConstraint.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/IkConstraintData.cpp
+ cocos/editor-support/spine/3.8/spine/IkConstraintData.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/IkConstraintTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/IkConstraintTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Json.cpp
+ cocos/editor-support/spine/3.8/spine/Json.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/LinkedMesh.cpp
+ cocos/editor-support/spine/3.8/spine/LinkedMesh.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/MathUtil.cpp
+ cocos/editor-support/spine/3.8/spine/MathUtil.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/MeshAttachment.cpp
+ cocos/editor-support/spine/3.8/spine/MeshAttachment.h
+ cocos/editor-support/spine/3.8/spine/MixBlend.h
+ cocos/editor-support/spine/3.8/spine/MixDirection.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/PathAttachment.cpp
+ cocos/editor-support/spine/3.8/spine/PathAttachment.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/PathConstraint.cpp
+ cocos/editor-support/spine/3.8/spine/PathConstraint.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/PathConstraintData.cpp
+ cocos/editor-support/spine/3.8/spine/PathConstraintData.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/PathConstraintMixTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/PathConstraintMixTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/PathConstraintPositionTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/PathConstraintPositionTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/PathConstraintSpacingTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/PathConstraintSpacingTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/PointAttachment.cpp
+ cocos/editor-support/spine/3.8/spine/PointAttachment.h
+ cocos/editor-support/spine/3.8/spine/Pool.h
+ cocos/editor-support/spine/3.8/spine/PositionMode.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/RegionAttachment.cpp
+ cocos/editor-support/spine/3.8/spine/RegionAttachment.h
+ cocos/editor-support/spine/3.8/spine/RotateMode.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/RotateTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/RotateTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/RTTI.cpp
+ cocos/editor-support/spine/3.8/spine/RTTI.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/ScaleTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/ScaleTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/ShearTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/ShearTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Skeleton.cpp
+ cocos/editor-support/spine/3.8/spine/Skeleton.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/SkeletonBinary.cpp
+ cocos/editor-support/spine/3.8/spine/SkeletonBinary.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/SkeletonBounds.cpp
+ cocos/editor-support/spine/3.8/spine/SkeletonBounds.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/SkeletonClipping.cpp
+ cocos/editor-support/spine/3.8/spine/SkeletonClipping.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/SkeletonData.cpp
+ cocos/editor-support/spine/3.8/spine/SkeletonData.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/SkeletonJson.cpp
+ cocos/editor-support/spine/3.8/spine/SkeletonJson.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Skin.cpp
+ cocos/editor-support/spine/3.8/spine/Skin.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Slot.cpp
+ cocos/editor-support/spine/3.8/spine/Slot.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/SlotData.cpp
+ cocos/editor-support/spine/3.8/spine/SlotData.h
+ cocos/editor-support/spine/3.8/spine/SpacingMode.h
+ cocos/editor-support/spine/3.8/spine/spine.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/SpineObject.cpp
+ cocos/editor-support/spine/3.8/spine/SpineObject.h
+ cocos/editor-support/spine/3.8/spine/SpineString.cpp
+ cocos/editor-support/spine/3.8/spine/SpineString.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/TextureLoader.cpp
+ cocos/editor-support/spine/3.8/spine/TextureLoader.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Timeline.cpp
+ cocos/editor-support/spine/3.8/spine/Timeline.h
+ cocos/editor-support/spine/3.8/spine/TimelineType.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/TransformConstraint.cpp
+ cocos/editor-support/spine/3.8/spine/TransformConstraint.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/TransformConstraintData.cpp
+ cocos/editor-support/spine/3.8/spine/TransformConstraintData.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/TransformConstraintTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/TransformConstraintTimeline.h
+ cocos/editor-support/spine/3.8/spine/TransformMode.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/TranslateTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/TranslateTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Triangulator.cpp
+ cocos/editor-support/spine/3.8/spine/Triangulator.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/TwoColorTimeline.cpp
+ cocos/editor-support/spine/3.8/spine/TwoColorTimeline.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/Updatable.cpp
+ cocos/editor-support/spine/3.8/spine/Updatable.h
+ cocos/editor-support/spine/3.8/spine/Vector.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/VertexAttachment.cpp
+ cocos/editor-support/spine/3.8/spine/VertexAttachment.h
+ NO_WERROR cocos/editor-support/spine/3.8/spine/VertexEffect.cpp
+ cocos/editor-support/spine/3.8/spine/VertexEffect.h
+ cocos/editor-support/spine/3.8/spine/Vertices.h
NO_WERROR cocos/editor-support/spine-creator-support/VertexEffectDelegate.cpp
cocos/editor-support/spine-creator-support/VertexEffectDelegate.h
- cocos/editor-support/spine-creator-support/VertexEffectDelegate.h
- NO_WERROR cocos/editor-support/spine-creator-support/Vector2.cpp
- cocos/editor-support/spine-creator-support/Vector2.h
)
cocos_source_files(
- NO_WERROR ${SWIG_OUTPUT}/jsb_spine_auto.cpp
- ${SWIG_OUTPUT}/jsb_spine_auto.h
+ NO_WERROR ${SWIG_OUTPUT}/jsb_spine_3_8_auto.cpp
+ ${SWIG_OUTPUT}/jsb_spine_3_8_auto.h
NO_WERROR cocos/bindings/manual/jsb_spine_manual.cpp
cocos/bindings/manual/jsb_spine_manual.h
)
endif()
+ if(USE_SPINE_4_2)
+ include_directories(${CWD}/cocos/editor-support/spine/4.2)
+ cocos_source_files(
+ NO_WERROR NO_UBUILD cocos/editor-support/spine/4.2/spine/Animation.cpp
+ cocos/editor-support/spine/4.2/spine/Animation.h
+ NO_WERROR NO_UBUILD cocos/editor-support/spine/4.2/spine/AnimationState.cpp
+ cocos/editor-support/spine/4.2/spine/AnimationState.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/AnimationStateData.cpp
+ cocos/editor-support/spine/4.2/spine/AnimationStateData.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Atlas.cpp
+ cocos/editor-support/spine/4.2/spine/Atlas.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/AtlasAttachmentLoader.cpp
+ cocos/editor-support/spine/4.2/spine/AtlasAttachmentLoader.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Attachment.cpp
+ cocos/editor-support/spine/4.2/spine/Attachment.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/AttachmentLoader.cpp
+ cocos/editor-support/spine/4.2/spine/AttachmentLoader.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/AttachmentTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/AttachmentTimeline.h
+ cocos/editor-support/spine/4.2/spine/AttachmentType.h
+ cocos/editor-support/spine/4.2/spine/BlendMode.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Bone.cpp
+ cocos/editor-support/spine/4.2/spine/Bone.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/BoneData.cpp
+ cocos/editor-support/spine/4.2/spine/BoneData.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/BoundingBoxAttachment.cpp
+ cocos/editor-support/spine/4.2/spine/BoundingBoxAttachment.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/ClippingAttachment.cpp
+ cocos/editor-support/spine/4.2/spine/ClippingAttachment.h
+ cocos/editor-support/spine/4.2/spine/Color.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/ColorTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/ColorTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Constraint.cpp
+ cocos/editor-support/spine/4.2/spine/Constraint.h
+ NO_WERROR NO_UBUILD cocos/editor-support/spine/4.2/spine/ConstraintData.cpp
+ cocos/editor-support/spine/4.2/spine/ConstraintData.h
+ cocos/editor-support/spine/4.2/spine/ContainerUtil.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/CurveTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/CurveTimeline.h
+ cocos/editor-support/spine/4.2/spine/Debug.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/DeformTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/DeformTimeline.h
+ cocos/editor-support/spine/4.2/spine/dll.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/DrawOrderTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/DrawOrderTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Event.cpp
+ cocos/editor-support/spine/4.2/spine/Event.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/EventData.cpp
+ cocos/editor-support/spine/4.2/spine/EventData.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/EventTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/EventTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Extension.cpp
+ cocos/editor-support/spine/4.2/spine/Extension.h
+ cocos/editor-support/spine/4.2/spine/HashMap.h
+ cocos/editor-support/spine/4.2/spine/HasRendererObject.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/IkConstraint.cpp
+ cocos/editor-support/spine/4.2/spine/IkConstraint.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/IkConstraintData.cpp
+ cocos/editor-support/spine/4.2/spine/IkConstraintData.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/IkConstraintTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/IkConstraintTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Json.cpp
+ cocos/editor-support/spine/4.2/spine/Json.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/LinkedMesh.cpp
+ cocos/editor-support/spine/4.2/spine/LinkedMesh.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/MathUtil.cpp
+ cocos/editor-support/spine/4.2/spine/MathUtil.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/MeshAttachment.cpp
+ cocos/editor-support/spine/4.2/spine/MeshAttachment.h
+ cocos/editor-support/spine/4.2/spine/MixBlend.h
+ cocos/editor-support/spine/4.2/spine/MixDirection.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PathAttachment.cpp
+ cocos/editor-support/spine/4.2/spine/PathAttachment.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PathConstraint.cpp
+ cocos/editor-support/spine/4.2/spine/PathConstraint.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PathConstraintData.cpp
+ cocos/editor-support/spine/4.2/spine/PathConstraintData.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PathConstraintMixTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/PathConstraintMixTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PathConstraintPositionTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/PathConstraintPositionTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PathConstraintSpacingTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/PathConstraintSpacingTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PointAttachment.cpp
+ cocos/editor-support/spine/4.2/spine/PointAttachment.h
+ cocos/editor-support/spine/4.2/spine/Pool.h
+ cocos/editor-support/spine/4.2/spine/Physics.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Sequence.cpp
+ cocos/editor-support/spine/4.2/spine/Sequence.h
+ cocos/editor-support/spine/4.2/spine/SequenceTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SequenceTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/TextureRegion.h
+ cocos/editor-support/spine/4.2/spine/BlockAllocator.h
+ cocos/editor-support/spine/4.2/spine/Inherit.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/InheritTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/InheritTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Log.cpp
+ cocos/editor-support/spine/4.2/spine/Log.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PhysicsConstraintData.cpp
+ cocos/editor-support/spine/4.2/spine/PhysicsConstraintData.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PhysicsConstraint.cpp
+ cocos/editor-support/spine/4.2/spine/PhysicsConstraint.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/PhysicsConstraintTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/PhysicsConstraintTimeline.h
+ cocos/editor-support/spine/4.2/spine/Property.h
+ cocos/editor-support/spine/4.2/spine/Version.h
+ cocos/editor-support/spine/4.2/spine/PositionMode.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/RegionAttachment.cpp
+ cocos/editor-support/spine/4.2/spine/RegionAttachment.h
+ cocos/editor-support/spine/4.2/spine/RotateMode.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/RotateTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/RotateTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/RTTI.cpp
+ cocos/editor-support/spine/4.2/spine/RTTI.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/ScaleTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/ScaleTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/ShearTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/ShearTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Skeleton.cpp
+ cocos/editor-support/spine/4.2/spine/Skeleton.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SkeletonBinary.cpp
+ cocos/editor-support/spine/4.2/spine/SkeletonBinary.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SkeletonBounds.cpp
+ cocos/editor-support/spine/4.2/spine/SkeletonBounds.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SkeletonClipping.cpp
+ cocos/editor-support/spine/4.2/spine/SkeletonClipping.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SkeletonData.cpp
+ cocos/editor-support/spine/4.2/spine/SkeletonData.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SkeletonJson.cpp
+ cocos/editor-support/spine/4.2/spine/SkeletonJson.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SkeletonRenderer.cpp
+ cocos/editor-support/spine/4.2/spine/SkeletonRenderer.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Skin.cpp
+ cocos/editor-support/spine/4.2/spine/Skin.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Slot.cpp
+ cocos/editor-support/spine/4.2/spine/Slot.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SlotData.cpp
+ cocos/editor-support/spine/4.2/spine/SlotData.h
+ cocos/editor-support/spine/4.2/spine/SpacingMode.h
+ cocos/editor-support/spine/4.2/spine/spine.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/SpineObject.cpp
+ cocos/editor-support/spine/4.2/spine/SpineObject.h
+ cocos/editor-support/spine/4.2/spine/SpineString.cpp
+ cocos/editor-support/spine/4.2/spine/SpineString.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/TextureLoader.cpp
+ cocos/editor-support/spine/4.2/spine/TextureLoader.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Timeline.cpp
+ cocos/editor-support/spine/4.2/spine/Timeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/TransformConstraint.cpp
+ cocos/editor-support/spine/4.2/spine/TransformConstraint.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/TransformConstraintData.cpp
+ cocos/editor-support/spine/4.2/spine/TransformConstraintData.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/TransformConstraintTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/TransformConstraintTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/TranslateTimeline.cpp
+ cocos/editor-support/spine/4.2/spine/TranslateTimeline.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Triangulator.cpp
+ cocos/editor-support/spine/4.2/spine/Triangulator.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/Updatable.cpp
+ cocos/editor-support/spine/4.2/spine/Updatable.h
+ cocos/editor-support/spine/4.2/spine/Vector.h
+ NO_WERROR cocos/editor-support/spine/4.2/spine/VertexAttachment.cpp
+ cocos/editor-support/spine/4.2/spine/VertexAttachment.h
+ cocos/editor-support/spine/4.2/spine/Vertices.h
+
+ )
+ cocos_source_files(
+ NO_WERROR ${SWIG_OUTPUT}/jsb_spine_4_2_auto.cpp
+ ${SWIG_OUTPUT}/jsb_spine_4_2_auto.h
+ NO_WERROR cocos/bindings/manual/jsb_spine_manual.cpp
+ cocos/bindings/manual/jsb_spine_manual.h
+ )
+ endif()
+
+ if(USE_SPINE)
+ cocos_source_files(
+ NO_WERROR cocos/editor-support/spine-creator-support/AttachmentVertices.cpp
+ cocos/editor-support/spine-creator-support/AttachmentVertices.h
+ NO_WERROR cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp
+ cocos/editor-support/spine-creator-support/SkeletonAnimation.h
+ NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCache.cpp
+ cocos/editor-support/spine-creator-support/SkeletonCache.h
+ NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp
+ cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h
+ NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp
+ cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h
+ NO_WERROR cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp
+ cocos/editor-support/spine-creator-support/SkeletonDataMgr.h
+ NO_WERROR NO_UBUILD cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
+ cocos/editor-support/spine-creator-support/SkeletonRenderer.h
+ NO_WERROR cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp
+ cocos/editor-support/spine-creator-support/spine-cocos2dx.h
+ NO_WERROR cocos/editor-support/spine-creator-support/Vector2.cpp
+ cocos/editor-support/spine-creator-support/Vector2.h
+ )
+ endif()
+
if(USE_DRAGONBONES)
cocos_source_files(
cocos/editor-support/dragonbones/DragonBonesHeaders.h
@@ -3169,6 +3356,8 @@ function(cc_apply_definations target)
$,$>,$>,USE_V8_DEBUGGER=1,USE_V8_DEBUGGER=0>
$,CC_USE_MIDDLEWARE=1,CC_USE_MIDDLEWARE=0>
$,CC_USE_SPINE=1,CC_USE_SPINE=0>
+ $,CC_USE_SPINE_3_8=1,CC_USE_SPINE_3_8=0>
+ $,CC_USE_SPINE_4_2=1,CC_USE_SPINE_4_2=0>
$,CC_USE_DRAGONBONES=1,CC_USE_DRAGONBONES=0>
$,CC_USE_JOB_SYSTEM_TBB=1,CC_USE_JOB_SYSTEM_TBB=0>
$,CC_USE_JOB_SYSTEM_TASKFLOW=1,CC_USE_JOB_SYSTEM_TASKFLOW=0>
diff --git a/native/cocos/bindings/manual/jsb_module_register.cpp b/native/cocos/bindings/manual/jsb_module_register.cpp
index 4b47dfba35..95f1a54bb5 100644
--- a/native/cocos/bindings/manual/jsb_module_register.cpp
+++ b/native/cocos/bindings/manual/jsb_module_register.cpp
@@ -114,7 +114,12 @@
#include "cocos/bindings/auto/jsb_editor_support_auto.h"
#if CC_USE_SPINE
- #include "cocos/bindings/auto/jsb_spine_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
+
#include "cocos/bindings/manual/jsb_spine_manual.h"
#endif
diff --git a/native/cocos/bindings/manual/jsb_spine_manual.cpp b/native/cocos/bindings/manual/jsb_spine_manual.cpp
index 4bc5f5fbb6..ca7f07f5ee 100644
--- a/native/cocos/bindings/manual/jsb_spine_manual.cpp
+++ b/native/cocos/bindings/manual/jsb_spine_manual.cpp
@@ -25,13 +25,19 @@
#include "jsb_spine_manual.h"
#include "base/Data.h"
#include "base/memory/Memory.h"
-#include "bindings/auto/jsb_spine_auto.h"
+
#include "bindings/jswrapper/SeApi.h"
#include "bindings/manual/jsb_conversions.h"
#include "bindings/manual/jsb_global.h"
#include "bindings/manual/jsb_helper.h"
#include "editor-support/spine-creator-support/spine-cocos2dx.h"
-#include "editor-support/spine/spine.h"
+#if CC_USE_SPINE_3_8
+ #include "bindings/auto/jsb_spine_3_8_auto.h"
+ #include "editor-support/spine/3.8/spine/spine.h"
+#else
+ #include "bindings/auto/jsb_spine_4_2_auto.h"
+ #include "editor-support/spine/4.2/spine/spine.h"
+#endif
#include "middleware-adapter.h"
#include "platform/FileUtils.h"
#include "spine-creator-support/SkeletonDataMgr.h"
@@ -41,7 +47,7 @@
using namespace cc;
-static spine::Cocos2dTextureLoader textureLoader;
+static cc::Cocos2dTextureLoader textureLoader;
static cc::RefMap *_preloadedAtlasTextures = nullptr;
static middleware::Texture2D *_getPreloadedAtlasTexture(const char *path) {
CC_ASSERT(_preloadedAtlasTextures);
@@ -62,7 +68,7 @@ static bool js_register_spine_initSkeletonData(se::State &s) {
ok = sevalue_to_native(args[0], &uuid);
SE_PRECONDITION2(ok, false, "Invalid uuid content!");
- auto mgr = spine::SkeletonDataMgr::getInstance();
+ auto mgr = SkeletonDataMgr::getInstance();
bool hasSkeletonData = mgr->hasSkeletonData(uuid);
if (hasSkeletonData) {
spine::SkeletonData *skeletonData = mgr->retainByUUID(uuid);
@@ -89,14 +95,14 @@ static bool js_register_spine_initSkeletonData(se::State &s) {
// create atlas from preloaded texture
_preloadedAtlasTextures = &textures;
- spine::spAtlasPage_setCustomTextureLoader(_getPreloadedAtlasTexture);
+ spAtlasPage_setCustomTextureLoader(_getPreloadedAtlasTexture);
spine::Atlas *atlas = ccnew_placement(__FILE__, __LINE__) spine::Atlas(atlasText.c_str(), (int)atlasText.size(), "", &textureLoader);
_preloadedAtlasTextures = nullptr;
- spine::spAtlasPage_setCustomTextureLoader(nullptr);
+ spAtlasPage_setCustomTextureLoader(nullptr);
- spine::AttachmentLoader *attachmentLoader = ccnew_placement(__FILE__, __LINE__) spine::Cocos2dAtlasAttachmentLoader(atlas);
+ spine::AttachmentLoader *attachmentLoader = ccnew_placement(__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(atlas);
spine::SkeletonData *skeletonData = nullptr;
std::size_t length = skeletonDataFile.length();
@@ -113,13 +119,15 @@ static bool js_register_spine_initSkeletonData(se::State &s) {
spine::SkeletonBinary binary(attachmentLoader);
binary.setScale(scale);
skeletonData = binary.readSkeletonData(cocos2dData.getBytes(), (int)cocos2dData.getSize());
- CC_ASSERT(skeletonData); // Can use binary.getError() to get error message.
+ const auto &errorMsg = binary.getError();
+ CC_ASSERTF(skeletonData, "Spine parse error: %s", errorMsg.buffer());
}
} else {
spine::SkeletonJson json(attachmentLoader);
json.setScale(scale);
skeletonData = json.readSkeletonData(skeletonDataFile.c_str());
- CC_ASSERT(skeletonData); // Can use json.getError() to get error message.
+ const auto &errorMsg = json.getError();
+ CC_ASSERTF(skeletonData, "Spine parse error: %s", errorMsg.buffer());
}
if (skeletonData) {
@@ -156,7 +164,7 @@ static bool js_register_spine_disposeSkeletonData(se::State &s) {
ok = sevalue_to_native(args[0], &uuid);
SE_PRECONDITION2(ok, false, "Invalid uuid content!");
- auto mgr = spine::SkeletonDataMgr::getInstance();
+ auto mgr = SkeletonDataMgr::getInstance();
bool hasSkeletonData = mgr->hasSkeletonData(uuid);
if (!hasSkeletonData) return true;
mgr->releaseByUUID(uuid);
@@ -174,7 +182,7 @@ static bool js_register_spine_initSkeletonRenderer(se::State &s) {
}
bool ok = false;
- spine::SkeletonRenderer *node = nullptr;
+ cc::SkeletonRenderer *node = nullptr;
ok = seval_to_native_ptr(args[0], &node);
SE_PRECONDITION2(ok, false, "Converting SpineRenderer failed!");
@@ -182,7 +190,7 @@ static bool js_register_spine_initSkeletonRenderer(se::State &s) {
ok = sevalue_to_native(args[1], &uuid);
SE_PRECONDITION2(ok, false, "Invalid uuid content!");
- auto mgr = spine::SkeletonDataMgr::getInstance();
+ auto mgr = SkeletonDataMgr::getInstance();
bool hasSkeletonData = mgr->hasSkeletonData(uuid);
if (hasSkeletonData) {
node->initWithUUID(uuid);
@@ -204,7 +212,7 @@ static bool js_register_spine_retainSkeletonData(se::State &s) {
ok = sevalue_to_native(args[0], &uuid);
SE_PRECONDITION2(ok, false, "Invalid uuid content!");
- auto mgr = spine::SkeletonDataMgr::getInstance();
+ auto mgr = SkeletonDataMgr::getInstance();
bool hasSkeletonData = mgr->hasSkeletonData(uuid);
if (hasSkeletonData) {
spine::SkeletonData *skeletonData = mgr->retainByUUID(uuid);
@@ -270,12 +278,20 @@ static bool js_RegionAttachment_computeWorldVertices(se::State &s) {
spine::RegionAttachment *regionAttachment = SE_THIS_OBJECT(s);
if (nullptr == regionAttachment) return true;
+#if CC_USE_SPINE_3_8
spine::Bone *bone = nullptr;
+#else
+ spine::Slot *slot = nullptr;
+#endif
size_t offset = 0, stride = 0;
se::Value worldVerticesVal;
bool ok = false;
+#if CC_USE_SPINE_3_8
ok = sevalue_to_native(args[0], &bone, s.thisObject());
+#else
+ ok = sevalue_to_native(args[0], &slot, s.thisObject());
+#endif
SE_PRECONDITION2(ok, false, "Error processing arguments");
ok = sevalue_to_native(args[1], &worldVerticesVal, s.thisObject());
@@ -291,12 +307,20 @@ static bool js_RegionAttachment_computeWorldVertices(se::State &s) {
uint8_t* ptr = nullptr;
size_t len = 0;
worldVerticesVal.toObject()->getTypedArrayData(&ptr, &len);
- regionAttachment->computeWorldVertices(*bone, reinterpret_cast(ptr), offset, stride);
+#if CC_USE_SPINE_3_8
+ regionAttachment->computeWorldVertices(*bone, reinterpret_cast(ptr), offset, stride);
+#else
+ regionAttachment->computeWorldVertices(*slot, reinterpret_cast(ptr), offset, stride);
+#endif
} else if (worldVerticesVal.toObject()->isArray()) {
spine::Vector worldVertices;
int count = 8;
worldVertices.ensureCapacity(count);
+#if CC_USE_SPINE_3_8
regionAttachment->computeWorldVertices(*bone, worldVertices, 0);
+#else
+ regionAttachment->computeWorldVertices(*slot, worldVertices, 0);
+#endif
int curr = offset;
worldVerticesVal.toObject()->setArrayElement(curr, se::Value(worldVertices[0]));
@@ -444,6 +468,7 @@ static bool js_Skin_findAttachmentsForSlot(se::State &s) {
}
SE_BIND_FUNC(js_Skin_findAttachmentsForSlot)
+#if CC_USE_SPINE_3_8
static bool js_VertexEffect_transform(se::State &s) {
const auto &args = s.args();
spine::VertexEffect* effect = SE_THIS_OBJECT(s);
@@ -485,6 +510,7 @@ static bool js_JitterVertexEffect_transform(se::State &s) {
return true;
}
SE_BIND_FUNC(js_JitterVertexEffect_transform)
+#endif
static bool js_spine_Skin_getAttachments(se::State& s) {
CC_UNUSED bool ok = true;
@@ -577,14 +603,16 @@ bool register_all_spine_manual(se::Object *obj) {
__jsb_spine_Bone_proto->defineFunction("worldToLocal", _SE(js_Bone_worldToLocal));
__jsb_spine_Bone_proto->defineFunction("localToWorld", _SE(js_Bone_localToWorld));
__jsb_spine_PointAttachment_proto->defineFunction("computeWorldPosition", _SE(js_PointAttachment_computeWorldPosition));
+#if CC_USE_SPINE_3_8
__jsb_spine_VertexEffect_proto->defineFunction("transform", _SE(js_VertexEffect_transform));
__jsb_spine_SwirlVertexEffect_proto->defineFunction("transform", _SE(js_SwirlVertexEffect_transform));
__jsb_spine_JitterVertexEffect_proto->defineFunction("transform", _SE(js_JitterVertexEffect_transform));
+#endif
__jsb_spine_Skin_proto->defineFunction("getAttachments", _SE(js_spine_Skin_getAttachments));
__jsb_spine_Slot_proto->defineFunction("setAttachment", _SE(js_spine_Slot_setAttachment));
__jsb_spine_Slot_proto->defineFunction("getAttachment", _SE(js_spine_Slot_getAttachment));
- spine::setSpineObjectDisposeCallback([](void *spineObj) {
+ cc::setSpineObjectDisposeCallback([](void *spineObj) {
if (!se::NativePtrToObjectMap::isValid()) {
return;
}
@@ -600,7 +628,7 @@ bool register_all_spine_manual(se::Object *obj) {
});
se::ScriptEngine::getInstance()->addBeforeCleanupHook([]() {
- spine::SkeletonDataMgr::destroyInstance();
+ SkeletonDataMgr::destroyInstance();
});
se::ScriptEngine::getInstance()->clearException();
diff --git a/native/cocos/editor-support/spine-creator-support/AttachmentVertices.cpp b/native/cocos/editor-support/spine-creator-support/AttachmentVertices.cpp
index e71ae64f0e..80d975390d 100644
--- a/native/cocos/editor-support/spine-creator-support/AttachmentVertices.cpp
+++ b/native/cocos/editor-support/spine-creator-support/AttachmentVertices.cpp
@@ -31,7 +31,7 @@
using namespace cc; // NOLINT(google-build-using-namespace)
-namespace spine {
+namespace cc {
AttachmentVertices::AttachmentVertices(middleware::Texture2D *texture, int verticesCount, uint16_t *triangles, int trianglesCount) {
_texture = texture;
@@ -55,4 +55,4 @@ AttachmentVertices *AttachmentVertices::copy() {
return atv;
}
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/AttachmentVertices.h b/native/cocos/editor-support/spine-creator-support/AttachmentVertices.h
index 6d2c5a36ef..fde45f375b 100644
--- a/native/cocos/editor-support/spine-creator-support/AttachmentVertices.h
+++ b/native/cocos/editor-support/spine-creator-support/AttachmentVertices.h
@@ -32,7 +32,7 @@
#include "base/Macros.h"
#include "middleware-adapter.h"
-namespace spine {
+namespace cc {
/**
* Store attachment vertex and indice list
*/
@@ -45,4 +45,4 @@ public:
cc::middleware::Texture2D *_texture = nullptr;
cc::middleware::Triangles *_triangles = nullptr;
};
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp
index 79636f7c87..d3b60c17ba 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp
@@ -34,7 +34,7 @@
#include "spine-creator-support/spine-cocos2dx.h"
#include "spine/Extension.h"
-namespace spine {
+namespace cc {
struct TrackEntryListeners {
StartListener startListener;
@@ -53,7 +53,7 @@ void trackEntryCallback(AnimationState *state, EventType type, TrackEntry *entry
(static_cast(state->getRendererObject()))->onTrackEntryEvent(entry, type, event);
if (type == EventType_Dispose) {
if (entry->getRendererObject()) {
- delete static_cast(entry->getRendererObject());
+ delete static_cast(entry->getRendererObject());
entry->setRendererObject(nullptr);
}
}
@@ -61,7 +61,7 @@ void trackEntryCallback(AnimationState *state, EventType type, TrackEntry *entry
static TrackEntryListeners *getListeners(TrackEntry *entry) {
if (!entry->getRendererObject()) {
- entry->setRendererObject(new spine::TrackEntryListeners());
+ entry->setRendererObject(new TrackEntryListeners());
entry->setListener(trackEntryCallback);
}
return static_cast(entry->getRendererObject());
@@ -127,7 +127,11 @@ void SkeletonAnimation::update(float deltaTime) {
if (_ownsSkeleton) _skeleton->update(deltaTime);
_state->update(deltaTime);
_state->apply(*_skeleton);
+#if CC_USE_SPINE_3_8
_skeleton->updateWorldTransform();
+#else
+ _skeleton->updateWorldTransform(Physics::Physics_Update);
+#endif
}
}
@@ -323,4 +327,4 @@ AnimationState *SkeletonAnimation::getState() const {
return _state;
}
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.h b/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.h
index 93eb7ab630..af53afaf60 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.h
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.h
@@ -31,37 +31,37 @@
#include "spine-creator-support/SkeletonRenderer.h"
#include "spine/spine.h"
-namespace spine {
+namespace cc {
-typedef std::function StartListener;
-typedef std::function InterruptListener;
-typedef std::function EndListener;
-typedef std::function DisposeListener;
-typedef std::function CompleteListener;
-typedef std::function EventListener;
+typedef std::function StartListener;
+typedef std::function InterruptListener;
+typedef std::function EndListener;
+typedef std::function DisposeListener;
+typedef std::function CompleteListener;
+typedef std::function EventListener;
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
* played later. */
-class SkeletonAnimation : public SkeletonRenderer {
+class SkeletonAnimation : public cc::SkeletonRenderer {
public:
static SkeletonAnimation *create();
- static SkeletonAnimation *createWithData(SkeletonData *skeletonData, bool ownsSkeletonData = false);
+ static SkeletonAnimation *createWithData(spine::SkeletonData *skeletonData, bool ownsSkeletonData = false);
static SkeletonAnimation *createWithJsonFile(const std::string &skeletonJsonFile, const std::string &atlasFile, float scale = 1);
static SkeletonAnimation *createWithBinaryFile(const std::string &skeletonBinaryFile, const std::string &atlasFile, float scale = 1);
static void setGlobalTimeScale(float timeScale);
virtual void update(float deltaTime) override;
- void setAnimationStateData(AnimationStateData *stateData);
+ void setAnimationStateData(spine::AnimationStateData *stateData);
void setMix(const std::string &fromAnimation, const std::string &toAnimation, float duration);
- TrackEntry *setAnimation(int trackIndex, const std::string &name, bool loop);
- TrackEntry *addAnimation(int trackIndex, const std::string &name, bool loop, float delay = 0);
- TrackEntry *setEmptyAnimation(int trackIndex, float mixDuration);
+ spine::TrackEntry *setAnimation(int trackIndex, const std::string &name, bool loop);
+ spine::TrackEntry *addAnimation(int trackIndex, const std::string &name, bool loop, float delay = 0);
+ spine::TrackEntry *setEmptyAnimation(int trackIndex, float mixDuration);
void setEmptyAnimations(float mixDuration);
- TrackEntry *addEmptyAnimation(int trackIndex, float mixDuration, float delay = 0);
- Animation *findAnimation(const std::string &name) const;
- TrackEntry *getCurrent(int trackIndex = 0);
+ spine::TrackEntry *addEmptyAnimation(int trackIndex, float mixDuration, float delay = 0);
+ spine::Animation *findAnimation(const std::string &name) const;
+ spine::TrackEntry *getCurrent(int trackIndex = 0);
void clearTracks();
void clearTrack(int trackIndex = 0);
@@ -72,17 +72,17 @@ public:
void setCompleteListener(const CompleteListener &listener);
void setEventListener(const EventListener &listener);
- void setTrackStartListener(TrackEntry *entry, const StartListener &listener);
- void setTrackInterruptListener(TrackEntry *entry, const InterruptListener &listener);
- void setTrackEndListener(TrackEntry *entry, const EndListener &listener);
- void setTrackDisposeListener(TrackEntry *entry, const DisposeListener &listener);
- void setTrackCompleteListener(TrackEntry *entry, const CompleteListener &listener);
- void setTrackEventListener(TrackEntry *entry, const EventListener &listener);
+ void setTrackStartListener(spine::TrackEntry *entry, const StartListener &listener);
+ void setTrackInterruptListener(spine::TrackEntry *entry, const InterruptListener &listener);
+ void setTrackEndListener(spine::TrackEntry *entry, const EndListener &listener);
+ void setTrackDisposeListener(spine::TrackEntry *entry, const DisposeListener &listener);
+ void setTrackCompleteListener(spine::TrackEntry *entry, const CompleteListener &listener);
+ void setTrackEventListener(spine::TrackEntry *entry, const EventListener &listener);
- virtual void onAnimationStateEvent(TrackEntry *entry, EventType type, Event *event);
- virtual void onTrackEntryEvent(TrackEntry *entry, EventType type, Event *event);
+ virtual void onAnimationStateEvent(spine::TrackEntry *entry, spine::EventType type, spine::Event *event);
+ virtual void onTrackEntryEvent(spine::TrackEntry *entry, spine::EventType type, spine::Event *event);
- AnimationState *getState() const;
+ spine::AnimationState *getState() const;
SkeletonAnimation();
virtual ~SkeletonAnimation();
@@ -92,7 +92,7 @@ public:
static float GlobalTimeScale;
protected:
- AnimationState *_state = nullptr;
+ spine::AnimationState *_state = nullptr;
bool _ownsAnimationStateData = false;
StartListener _startListener = nullptr;
InterruptListener _interruptListener = nullptr;
@@ -102,7 +102,7 @@ protected:
EventListener _eventListener = nullptr;
private:
- typedef SkeletonRenderer super;
+ typedef cc::SkeletonRenderer super;
};
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCache.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonCache.cpp
index 703f430924..446bdeb96b 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonCache.cpp
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonCache.cpp
@@ -33,8 +33,8 @@
USING_NS_MW; // NOLINT(google-build-using-namespace)
using namespace cc; // NOLINT(google-build-using-namespace)
-
-namespace spine {
+using namespace spine;
+namespace cc {
float SkeletonCache::FrameTime = 1.0F / 60.0F;
float SkeletonCache::MaxCacheTime = 120.0F;
@@ -192,7 +192,11 @@ void SkeletonCache::update(float deltaTime) {
if (_ownsSkeleton) _skeleton->update(deltaTime);
_state->update(deltaTime);
_state->apply(*_skeleton);
+#if CC_USE_SPINE_3_8
_skeleton->updateWorldTransform();
+#else
+ _skeleton->updateWorldTransform(Physics::Physics_Update);
+#endif
}
void SkeletonCache::updateToFrame(const std::string &animationName, int toFrameIdx /*= -1*/) {
@@ -325,7 +329,11 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) {
spine::Color attachmentColor;
if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
auto *attachment = dynamic_cast(slot->getAttachment());
+#if CC_USE_SPINE_3_8
attachmentVertices = static_cast(attachment->getRendererObject());
+#else
+ attachmentVertices = static_cast(attachment->getRegion()->rendererObject);
+#endif
// Early exit if attachment is invisible
if (attachment->getColor().a == 0) {
@@ -340,7 +348,11 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) {
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) {
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
}
+#if CC_USE_SPINE_3_8
attachment->computeWorldVertices(slot->getBone(), reinterpret_cast(trianglesTwoColor.verts), 0, vs2);
+#else
+ attachment->computeWorldVertices(*slot, reinterpret_cast(trianglesTwoColor.verts), 0, vs2);
+#endif
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = static_cast(trianglesTwoColor.indexCount * sizeof(uint16_t));
@@ -352,7 +364,11 @@ void SkeletonCache::renderAnimationFrame(AnimationData *animationData) {
} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
auto *attachment = dynamic_cast(slot->getAttachment());
+#if CC_USE_SPINE_3_8
attachmentVertices = static_cast(attachment->getRendererObject());
+#else
+ attachmentVertices = static_cast(attachment->getRegion()->rendererObject);
+#endif
// Early exit if attachment is invisible
if (attachment->getColor().a == 0) {
@@ -543,4 +559,4 @@ void SkeletonCache::resetAnimationData(const std::string &animationName) {
}
}
}
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCache.h b/native/cocos/editor-support/spine-creator-support/SkeletonCache.h
index 424e8cfa9e..b6fc76cf44 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonCache.h
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonCache.h
@@ -34,7 +34,7 @@
#include "SkeletonAnimation.h"
#include "middleware-adapter.h"
-namespace spine {
+namespace cc {
class SkeletonCache : public SkeletonAnimation {
public:
struct SegmentData {
@@ -134,7 +134,7 @@ public:
virtual void stopSchedule() override {}
virtual void update(float deltaTime) override;
virtual void render(float deltaTime) override {}
- virtual void onAnimationStateEvent(TrackEntry *entry, EventType type, Event *event) override;
+ virtual void onAnimationStateEvent(spine::TrackEntry *entry, spine::EventType type, spine::Event *event) override;
void updateToFrame(const std::string &animationName, int toFrameIdx = -1);
// if animation data is empty, it will build new one.
@@ -154,4 +154,4 @@ private:
std::string _curAnimationName = "";
std::map _animationCaches;
};
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp
index b65d6a736d..d2c9e8f2cc 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp
@@ -43,10 +43,11 @@ USING_NS_MW; // NOLINT(google-build-using-namespace)
using namespace cc; // NOLINT(google-build-using-namespace)
using namespace cc::gfx; // NOLINT(google-build-using-namespace)
+using namespace spine;
static const std::string TECH_STAGE = "opaque";
static const std::string TEXTURE_KEY = "texture";
-namespace spine {
+namespace cc {
SkeletonCacheAnimation::SkeletonCacheAnimation(const std::string &uuid, bool isShare) {
if (isShare) {
@@ -601,4 +602,4 @@ cc::Material *SkeletonCacheAnimation::requestMaterial(uint16_t blendSrc, uint16_
return _materialCaches[key];
}
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h b/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h
index 94f247d61b..884691a3b9 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h
@@ -41,7 +41,7 @@ class RenderDrawInfo;
class Material;
};
-namespace spine {
+namespace cc {
class SkeletonCacheAnimation : public cc::RefCounted, public cc::middleware::IMiddleware {
public:
@@ -51,20 +51,20 @@ public:
void update(float dt) override;
void render(float dt) override;
- Skeleton *getSkeleton() const;
+ spine::Skeleton *getSkeleton() const;
void setTimeScale(float scale);
float getTimeScale() const;
void paused(bool value);
- Bone *findBone(const std::string &boneName) const;
- Slot *findSlot(const std::string &slotName) const;
+ spine::Bone *findBone(const std::string &boneName) const;
+ spine::Slot *findSlot(const std::string &slotName) const;
void setSkin(const std::string &skinName);
void setSkin(const char *skinName);
- Attachment *getAttachment(const std::string &slotName, const std::string &attachmentName) const;
+ spine::Attachment *getAttachment(const std::string &slotName, const std::string &attachmentName) const;
bool setAttachment(const std::string &slotName, const std::string &attachmentName);
bool setAttachment(const std::string &slotName, const char *attachmentName);
void setColor(float r, float g, float b, float a);
@@ -82,7 +82,7 @@ public:
void setAnimation(const std::string &name, bool loop);
void addAnimation(const std::string &name, bool loop, float delay = 0);
- Animation *findAnimation(const std::string &name) const;
+ spine::Animation *findAnimation(const std::string &name) const;
using CacheFrameEvent = std::function;
void setStartListener(const CacheFrameEvent &listener);
@@ -143,4 +143,4 @@ private:
ccstd::unordered_map _materialCaches;
bool _needClearMaterialCaches = false;
};
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp
index 85bfeca2c7..381bcb547e 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp
@@ -30,7 +30,7 @@
#include "SkeletonCacheMgr.h"
#include "base/DeferredReleasePool.h"
-namespace spine {
+namespace cc {
SkeletonCacheMgr *SkeletonCacheMgr::instance = nullptr;
SkeletonCache *SkeletonCacheMgr::buildSkeletonCache(const std::string &uuid) {
SkeletonCache *animation = _caches.at(uuid);
@@ -50,4 +50,4 @@ void SkeletonCacheMgr::removeSkeletonCache(const std::string &uuid) {
_caches.erase(it);
}
}
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h b/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h
index 12421c1a02..754b5531f9 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h
@@ -31,7 +31,7 @@
#include "SkeletonCache.h"
#include "base/RefMap.h"
-namespace spine {
+namespace cc {
class SkeletonCacheMgr {
public:
@@ -50,11 +50,11 @@ public:
}
void removeSkeletonCache(const std::string &uuid);
- SkeletonCache *buildSkeletonCache(const std::string &uuid);
+ cc::SkeletonCache *buildSkeletonCache(const std::string &uuid);
private:
static SkeletonCacheMgr *instance;
cc::RefMap _caches;
};
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp
index 1f02e7df75..ac80cf9cb4 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp
@@ -32,8 +32,11 @@
#include
using namespace spine; //NOLINT
+using namespace cc; //NOLINT
-namespace spine {
+namespace cc {
+
+class AttachmentVertices;
class SkeletonDataInfo {
public:
@@ -46,6 +49,17 @@ public:
}
if (atlas) {
+#if CC_USE_SPINE_4_2
+ auto ®ions = atlas->getRegions();
+ int size = regions.size();
+ for (int i = 0; i < size; i++) {
+ auto *region = regions[i];
+ if (region->rendererObject) {
+ delete static_cast(region->rendererObject);
+ region->rendererObject = nullptr;
+ }
+ }
+#endif
delete atlas;
atlas = nullptr;
}
@@ -62,7 +76,7 @@ public:
std::vector texturesIndex;
};
-} // namespace spine
+} // namespace cc
SkeletonDataMgr *SkeletonDataMgr::instance = nullptr;
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.h b/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.h
index 197a881060..8fdba3615a 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.h
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.h
@@ -37,7 +37,8 @@
#include "spine/SkeletonData.h"
#include "spine/spine.h"
-namespace spine {
+using namespace spine;
+namespace cc {
class SkeletonDataInfo;
@@ -81,4 +82,4 @@ private:
std::map _dataMap;
};
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
index 21d248e932..02c6864388 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
@@ -55,7 +55,7 @@ using std::min;
static const std::string TECH_STAGE = "opaque";
static const std::string TEXTURE_KEY = "texture";
-static spine::Cocos2dTextureLoader textureLoader;
+static Cocos2dTextureLoader textureLoader;
static std::vector _slotTextureSet{};
enum DebugType {
@@ -64,6 +64,8 @@ enum DebugType {
MESH,
BONES
};
+
+namespace cc {
SkeletonRenderer *SkeletonRenderer::create() {
return new SkeletonRenderer();
}
@@ -91,7 +93,11 @@ void SkeletonRenderer::initialize() {
}
_skeleton->setToSetupPose();
+#if CC_USE_SPINE_3_8
_skeleton->updateWorldTransform();
+#else
+ _skeleton->updateWorldTransform(spine::Physics::Physics_Pose);
+#endif
}
void SkeletonRenderer::beginSchedule() {
@@ -138,7 +144,9 @@ SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, const st
}
SkeletonRenderer::~SkeletonRenderer() {
+#if CC_USE_SPINE_3_8
CC_SAFE_RELEASE(_effectDelegate);
+#endif
if (_ownsSkeletonData) delete _skeleton->getData();
if (_ownsSkeleton) delete _skeleton;
if (_ownsAtlas && _atlas) delete _atlas;
@@ -354,8 +362,8 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
}
auto *material = requestMaterial(curBlendSrc, curBlendDst);
curDrawInfo->setMaterial(material);
- gfx::Texture *texture = curTexture->getGFXTexture();
- gfx::Sampler *sampler = curTexture->getGFXSampler();
+ gfx::Texture *texture = curTexture ? curTexture->getGFXTexture() : nullptr;
+ gfx::Sampler *sampler = curTexture? curTexture->getGFXSampler() : nullptr;
curDrawInfo->setTexture(texture);
curDrawInfo->setSampler(sampler);
auto *uiMeshBuffer = mb->getUIMeshBuffer();
@@ -371,6 +379,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
materialLen++;
};
+#if CC_USE_SPINE_3_8
VertexEffect *effect = nullptr;
if (_effectDelegate) {
effect = _effectDelegate->getVertexEffect();
@@ -379,6 +388,9 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
if (effect) {
effect->begin(*_skeleton);
}
+#else
+ void *effect = nullptr;
+#endif
auto &drawOrder = _skeleton->getDrawOrder();
for (size_t i = 0, n = drawOrder.size(); i < n; ++i) {
@@ -412,7 +424,11 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
auto *attachment = dynamic_cast(slot->getAttachment());
+#if CC_USE_SPINE_3_8
attachmentVertices = reinterpret_cast(attachment->getRendererObject());
+#else
+ attachmentVertices = reinterpret_cast(attachment->getRegion()->rendererObject);
+#endif
// Early exit if attachment is invisible
if (attachment->getColor().a == 0) {
@@ -426,7 +442,11 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
isFull |= vb.checkSpace(vbSize, true);
triangles.verts = reinterpret_cast(vb.getCurBuffer());
memcpy(static_cast(triangles.verts), static_cast(attachmentVertices->_triangles->verts), vbSize);
+#if CC_USE_SPINE_3_8
attachment->computeWorldVertices(slot->getBone(), reinterpret_cast(triangles.verts), 0, vs1);
+#else
+ attachment->computeWorldVertices(*slot, reinterpret_cast(triangles.verts), 0, vs1);
+#endif
triangles.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = triangles.indexCount * sizeof(uint16_t);
@@ -441,7 +461,11 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) {
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
}
+#if CC_USE_SPINE_3_8
attachment->computeWorldVertices(slot->getBone(), reinterpret_cast(trianglesTwoColor.verts), 0, vs2);
+#else
+ attachment->computeWorldVertices(*slot, reinterpret_cast(trianglesTwoColor.verts), 0, vs2);
+#endif
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
ibSize = trianglesTwoColor.indexCount * sizeof(uint16_t);
@@ -469,7 +493,11 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
}
} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
auto *attachment = dynamic_cast(slot->getAttachment());
+#if CC_USE_SPINE_3_8
attachmentVertices = static_cast(attachment->getRendererObject());
+#else
+ attachmentVertices = static_cast(attachment->getRegion()->rendererObject);
+#endif
// Early exit if attachment is invisible
if (attachment->getColor().a == 0) {
@@ -533,6 +561,17 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
}
}
+ } else if (slot->getAttachment()->getRTTI().isExactly(PathAttachment::rtti)) {
+ auto *pathAttachment = dynamic_cast(slot->getAttachment());
+#if CC_USE_SPINE_4_2
+ if (pathAttachment->getColor().a == 0) {
+ _clipper->clipEnd(*slot);
+ continue;
+ }
+#endif
+
+ // TODO: implement PathAttachment
+ //auto &transform = slot->getBone().getWorldTransform();
} else if (slot->getAttachment()->getRTTI().isExactly(ClippingAttachment::rtti)) {
auto *clip = dynamic_cast(slot->getAttachment());
_clipper->clipStart(*slot, clip);
@@ -600,6 +639,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
float *uvs = _clipper->getClippedUVs().buffer();
if (effect) {
+#if CC_USE_SPINE_3_8
for (int v = 0, vn = triangles.vertCount, vv = 0; v < vn; ++v, vv += 2) {
V3F_T2F_C4B *vertex = triangles.verts + v;
vertex->vertex.x = verts[vv];
@@ -609,6 +649,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
effect->transform(vertex->vertex.x, vertex->vertex.y);
vertex->color = light;
}
+#endif
} else {
for (int v = 0, vn = triangles.vertCount, vv = 0; v < vn; ++v, vv += 2) {
V3F_T2F_C4B *vertex = triangles.verts + v;
@@ -622,11 +663,13 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
// No cliping logic
} else {
if (effect) {
+#if CC_USE_SPINE_3_8
for (int v = 0, vn = triangles.vertCount; v < vn; ++v) {
V3F_T2F_C4B *vertex = triangles.verts + v;
effect->transform(vertex->vertex.x, vertex->vertex.y);
vertex->color = light;
}
+#endif
} else {
for (int v = 0, vn = triangles.vertCount; v < vn; ++v) {
V3F_T2F_C4B *vertex = triangles.verts + v;
@@ -669,6 +712,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
float *uvs = _clipper->getClippedUVs().buffer();
if (effect) {
+#if CC_USE_SPINE_3_8
for (int v = 0, vn = trianglesTwoColor.vertCount, vv = 0; v < vn; ++v, vv += 2) {
V3F_T2F_C4B_C4B *vertex = trianglesTwoColor.verts + v;
vertex->vertex.x = verts[vv];
@@ -679,6 +723,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
vertex->color = light;
vertex->color2 = dark;
}
+#endif
} else {
for (int v = 0, vn = trianglesTwoColor.vertCount, vv = 0; v < vn; ++v, vv += 2) {
V3F_T2F_C4B_C4B *vertex = trianglesTwoColor.verts + v;
@@ -692,12 +737,14 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
}
} else {
if (effect) {
+#if CC_USE_SPINE_3_8
for (int v = 0, vn = trianglesTwoColor.vertCount; v < vn; ++v) {
V3F_T2F_C4B_C4B *vertex = trianglesTwoColor.verts + v;
effect->transform(vertex->vertex.x, vertex->vertex.y);
vertex->color = light;
vertex->color2 = dark;
}
+#endif
} else {
for (int v = 0, vn = trianglesTwoColor.vertCount; v < vn; ++v) {
V3F_T2F_C4B_C4B *vertex = trianglesTwoColor.verts + v;
@@ -708,7 +755,12 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
}
}
- curTexture = (cc::Texture2D *)attachmentVertices->_texture->getRealTexture();
+ if (attachmentVertices) {
+ curTexture = (cc::Texture2D *)attachmentVertices->_texture->getRealTexture();
+ } else {
+ curTexture = nullptr;
+ }
+
// If texture or blendMode change,will change material.
if (preTexture != curTexture || preBlendMode != slot->getData().getBlendMode() || isFull) {
flush();
@@ -742,7 +794,9 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
_clipper->clipEnd();
+#if CC_USE_SPINE_3_8
if (effect) effect->end();
+#endif
if (curDrawInfo) curDrawInfo->setIbCount(curISegLen);
@@ -807,7 +861,11 @@ cc::Rect SkeletonRenderer::getBoundingBox() const {
auto *attachment = dynamic_cast(slot->getAttachment());
buffer.checkSpace(8 * sizeof(float));
worldVertices = reinterpret_cast(buffer.getCurBuffer());
+#if CC_USE_SPINE_3_8
attachment->computeWorldVertices(slot->getBone(), worldVertices, 0, 2);
+#else
+ attachment->computeWorldVertices(*slot, worldVertices, 0, 2);
+#endif
verticesCount = 8;
} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
auto *mesh = dynamic_cast(slot->getAttachment());
@@ -833,7 +891,11 @@ cc::Rect SkeletonRenderer::getBoundingBox() const {
void SkeletonRenderer::updateWorldTransform() {
if (_skeleton) {
+#if CC_USE_SPINE_3_8
_skeleton->updateWorldTransform();
+#else
+ _skeleton->updateWorldTransform(Physics::Physics_Update);
+#endif
}
}
@@ -912,6 +974,7 @@ void SkeletonRenderer::setUseTint(bool enabled) {
_useTint = enabled;
}
+#if CC_USE_SPINE_3_8
void SkeletonRenderer::setVertexEffectDelegate(VertexEffectDelegate *effectDelegate) {
if (_effectDelegate == effectDelegate) {
return;
@@ -920,6 +983,7 @@ void SkeletonRenderer::setVertexEffectDelegate(VertexEffectDelegate *effectDeleg
_effectDelegate = effectDelegate;
CC_SAFE_ADD_REF(_effectDelegate);
}
+#endif
void SkeletonRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex) {
this->_startSlotIndex = startSlotIndex;
@@ -1059,6 +1123,7 @@ void SkeletonRenderer::setSlotTexture(const std::string &slotName, cc::Texture2D
AttachmentVertices *attachmentVertices = nullptr;
if (attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) {
auto region = static_cast(attachment);
+#if CC_USE_SPINE_3_8
region->setRegionWidth(width);
region->setRegionHeight(height);
region->setRegionOriginalWidth(width);
@@ -1072,6 +1137,32 @@ void SkeletonRenderer::setSlotTexture(const std::string &slotName, cc::Texture2D
attachmentVertices = attachmentVertices->copy();
region->setRendererObject(attachmentVertices);
}
+#else
+ auto *textureRegion = region->getRegion();
+ if (textureRegion) {
+ textureRegion->width = width;
+ textureRegion->height = height;
+ textureRegion->originalWidth = width;
+ textureRegion->originalHeight = height;
+ }
+ region->setWidth(width);
+ region->setHeight(height);
+ auto &uvs = region->getUVs();
+ uvs[2] = 0;
+ uvs[3] = 1;
+ uvs[4] = 0;
+ uvs[5] = 0;
+ uvs[6] = 1;
+ uvs[7] = 0;
+ uvs[0] = 1;
+ uvs[1] = 1;
+ region->updateRegion();
+ attachmentVertices = static_cast(textureRegion->rendererObject);
+ if (createAttachment) {
+ attachmentVertices = attachmentVertices->copy();
+ textureRegion->rendererObject = attachmentVertices;
+ }
+#endif
V3F_T2F_C4B *vertices = attachmentVertices->_triangles->verts;
const auto &UVs = region->getUVs();
for (int i = 0, ii = 0; i < 4; ++i, ii += 2) {
@@ -1080,6 +1171,7 @@ void SkeletonRenderer::setSlotTexture(const std::string &slotName, cc::Texture2D
}
} else if (attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) {
auto mesh = static_cast(attachment);
+#if CC_USE_SPINE_3_8
mesh->setRegionWidth(width);
mesh->setRegionHeight(height);
mesh->setRegionOriginalWidth(width);
@@ -1098,6 +1190,28 @@ void SkeletonRenderer::setSlotTexture(const std::string &slotName, cc::Texture2D
attachmentVertices = attachmentVertices->copy();
mesh->setRendererObject(attachmentVertices);
}
+#else
+ auto *region = mesh->getRegion();
+ if (region) {
+ region->width = width;
+ region->height = height;
+ region->originalWidth = width;
+ region->originalHeight = height;
+ region->u = 0;
+ region->v = 0;
+ region->u2 = 1.0f;
+ region->v2 = 1.0f;
+ region->degrees = 0;
+ }
+ mesh->setWidth(width);
+ mesh->setHeight(height);
+ mesh->updateRegion();
+ attachmentVertices = static_cast(mesh->getRegion()->rendererObject);
+ if (createAttachment) {
+ attachmentVertices = attachmentVertices->copy();
+ mesh->getRegion()->rendererObject = attachmentVertices;
+ }
+#endif
V3F_T2F_C4B *vertices = attachmentVertices->_triangles->verts;
const auto &UVs = mesh->getUVs();
for (size_t i = 0, ii = 0, nn = mesh->getWorldVerticesLength(); ii < nn; ++i, ii += 2) {
@@ -1123,3 +1237,4 @@ void SkeletonRenderer::setSlotTexture(const std::string &slotName, cc::Texture2D
}
attachmentVertices->_texture = middlewareTexture;
}
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.h b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.h
index 3503ae821e..336210cf18 100644
--- a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.h
+++ b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.h
@@ -38,16 +38,15 @@
#include "base/RefMap.h"
#include "core/assets/Texture2D.h"
#include "middleware-adapter.h"
+#if CC_USE_SPINE_3_8
#include "spine-creator-support/VertexEffectDelegate.h"
+#endif
#include "spine/spine.h"
namespace cc {
class RenderEntity;
class RenderDrawInfo;
class Material;
-}; // namespace cc
-
-namespace spine {
class AttachmentVertices;
@@ -56,15 +55,15 @@ class AttachmentVertices;
class SkeletonRenderer : public cc::RefCounted, public cc::middleware::IMiddleware {
public:
static SkeletonRenderer *create();
- static SkeletonRenderer *createWithSkeleton(Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
- static SkeletonRenderer *createWithData(SkeletonData *skeletonData, bool ownsSkeletonData = false);
+ static SkeletonRenderer *createWithSkeleton(spine::Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false);
+ static SkeletonRenderer *createWithData(spine::SkeletonData *skeletonData, bool ownsSkeletonData = false);
static SkeletonRenderer *createWithFile(const std::string &skeletonDataFile, const std::string &atlasFile, float scale = 1);
void update(float deltaTime) override {}
void render(float deltaTime) override;
virtual cc::Rect getBoundingBox() const;
- Skeleton *getSkeleton() const;
+ spine::Skeleton *getSkeleton() const;
void setTimeScale(float scale);
float getTimeScale() const;
@@ -77,9 +76,9 @@ public:
void paused(bool value);
/* Returns 0 if the bone was not found. */
- Bone *findBone(const std::string &boneName) const;
+ spine::Bone *findBone(const std::string &boneName) const;
/* Returns 0 if the slot was not found. */
- Slot *findSlot(const std::string &slotName) const;
+ spine::Slot *findSlot(const std::string &slotName) const;
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
* attached if the corresponding attachment from the old skin was attached.
@@ -89,7 +88,7 @@ public:
void setSkin(const char *skinName);
/* Returns 0 if the slot or attachment was not found. */
- Attachment *getAttachment(const std::string &slotName, const std::string &attachmentName) const;
+ spine::Attachment *getAttachment(const std::string &slotName, const std::string &attachmentName) const;
/* Returns false if the slot or attachment was not found.
* @param attachmentName May be empty string ("") for no attachment. */
bool setAttachment(const std::string &slotName, const std::string &attachmentName);
@@ -98,9 +97,10 @@ public:
/* Enables/disables two color tinting for this instance. May break batching */
void setUseTint(bool enabled);
-
+#if CC_USE_SPINE_3_8
/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
void setVertexEffectDelegate(VertexEffectDelegate *effectDelegate);
+#endif
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
void setSlotsRange(int startSlotIndex, int endSlotIndex);
@@ -131,18 +131,18 @@ public:
void onDisable();
SkeletonRenderer();
- explicit SkeletonRenderer(Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
- explicit SkeletonRenderer(SkeletonData *skeletonData, bool ownsSkeletonData = false);
+ explicit SkeletonRenderer(spine::Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
+ explicit SkeletonRenderer(spine::SkeletonData *skeletonData, bool ownsSkeletonData = false);
SkeletonRenderer(const std::string &skeletonDataFile, const std::string &atlasFile, float scale = 1);
~SkeletonRenderer() override;
void initWithUUID(const std::string &uuid);
- void initWithSkeleton(Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
- void initWithData(SkeletonData *skeletonData, bool ownsSkeletonData = false);
- void initWithJsonFile(const std::string &skeletonDataFile, Atlas *atlas, float scale = 1);
+ void initWithSkeleton(spine::Skeleton *skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
+ void initWithData(spine::SkeletonData *skeletonData, bool ownsSkeletonData = false);
+ void initWithJsonFile(const std::string &skeletonDataFile, spine::Atlas *atlas, float scale = 1);
void initWithJsonFile(const std::string &skeletonDataFile, const std::string &atlasFile, float scale = 1);
- void initWithBinaryFile(const std::string &skeletonDataFile, Atlas *atlas, float scale = 1);
+ void initWithBinaryFile(const std::string &skeletonDataFile, spine::Atlas *atlas, float scale = 1);
void initWithBinaryFile(const std::string &skeletonDataFile, const std::string &atlasFile, float scale = 1);
virtual void initialize();
@@ -154,15 +154,17 @@ public:
void setSlotTexture(const std::string &slotName, cc::Texture2D *tex2d, bool createAttachment);
protected:
- void setSkeletonData(SkeletonData *skeletonData, bool ownsSkeletonData);
+ void setSkeletonData(spine::SkeletonData *skeletonData, bool ownsSkeletonData);
bool _ownsSkeletonData = false;
bool _ownsSkeleton = false;
bool _ownsAtlas = false;
- Atlas *_atlas = nullptr;
- AttachmentLoader *_attachmentLoader = nullptr;
- Skeleton *_skeleton = nullptr;
+ spine::Atlas *_atlas = nullptr;
+ spine::AttachmentLoader *_attachmentLoader = nullptr;
+ spine::Skeleton *_skeleton = nullptr;
+#if CC_USE_SPINE_3_8
VertexEffectDelegate *_effectDelegate = nullptr;
+#endif
float _timeScale = 1;
bool _paused = false;
@@ -172,7 +174,7 @@ protected:
bool _debugBones = false;
cc::middleware::Color4F _nodeColor = cc::middleware::Color4F::WHITE;
bool _premultipliedAlpha = false;
- SkeletonClipping *_clipper = nullptr;
+ spine::SkeletonClipping *_clipper = nullptr;
bool _useTint = false;
bool _enableBatch = false;
std::string _uuid;
@@ -189,5 +191,4 @@ protected:
ccstd::unordered_map _materialCaches;
bool _needClearMaterialCaches = false;
};
-
-} // namespace spine
+}; // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.cpp b/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.cpp
index cf360b8dd8..688261fc13 100644
--- a/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.cpp
+++ b/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.cpp
@@ -1,84 +1,85 @@
-/******************************************************************************
- * Spine Runtimes License Agreement
- * Last updated January 1, 2020. Replaces all prior versions.
- *
- * Copyright (c) 2013-2020, Esoteric Software LLC
- *
- * Integration of the Spine Runtimes into software or otherwise creating
- * derivative works of the Spine Runtimes is permitted under the terms and
- * conditions of Section 2 of the Spine Editor License Agreement:
- * http://esotericsoftware.com/spine-editor-license
- *
- * Otherwise, it is permitted to integrate the Spine Runtimes into software
- * or otherwise create derivative works of the Spine Runtimes (collectively,
- * "Products"), provided that each user of the Products must obtain their own
- * Spine Editor license and redistribution of the Products in any form must
- * include this license and copyright notice.
- *
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *****************************************************************************/
-
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated January 1, 2020. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2020, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
+ * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
#include "VertexEffectDelegate.h"
-namespace spine {
-VertexEffectDelegate::VertexEffectDelegate() {
-}
-
-VertexEffectDelegate::~VertexEffectDelegate() {
- clear();
-}
-
-void VertexEffectDelegate::clear() {
- if (_interpolation) {
- delete _interpolation;
- _interpolation = nullptr;
- }
- if (_vertexEffect) {
- delete _vertexEffect;
- _vertexEffect = nullptr;
- }
- _effectType = "none";
-}
-
-JitterVertexEffect *VertexEffectDelegate::initJitter(float jitterX, float jitterY) {
- clear();
- _vertexEffect = new JitterVertexEffect(jitterX, jitterY);
- _effectType = "jitter";
- return (JitterVertexEffect *)_vertexEffect;
-}
-
-SwirlVertexEffect *VertexEffectDelegate::initSwirlWithPow(float radius, int power) {
- clear();
- _interpolation = new PowInterpolation(power);
- _vertexEffect = new SwirlVertexEffect(radius, *_interpolation);
- _effectType = "swirl";
- return (SwirlVertexEffect *)_vertexEffect;
-}
-
-SwirlVertexEffect *VertexEffectDelegate::initSwirlWithPowOut(float radius, int power) {
- clear();
- _interpolation = new PowOutInterpolation(power);
- _vertexEffect = new SwirlVertexEffect(radius, *_interpolation);
- _effectType = "swirl";
- return (SwirlVertexEffect *)_vertexEffect;
-}
-
-JitterVertexEffect *VertexEffectDelegate::getJitterVertexEffect() {
- JitterVertexEffect *jitter = dynamic_cast(_vertexEffect);
- return jitter;
-}
-
-SwirlVertexEffect *VertexEffectDelegate::getSwirlVertexEffect() {
- SwirlVertexEffect *swirl = dynamic_cast(_vertexEffect);
- return swirl;
-}
-} // namespace spine
+namespace cc {
+
+VertexEffectDelegate::VertexEffectDelegate() {
+}
+
+VertexEffectDelegate::~VertexEffectDelegate() {
+ clear();
+}
+
+void VertexEffectDelegate::clear() {
+ if (_interpolation) {
+ delete _interpolation;
+ _interpolation = nullptr;
+ }
+ if (_vertexEffect) {
+ delete _vertexEffect;
+ _vertexEffect = nullptr;
+ }
+ _effectType = "none";
+}
+
+JitterVertexEffect *VertexEffectDelegate::initJitter(float jitterX, float jitterY) {
+ clear();
+ _vertexEffect = new spine::JitterVertexEffect(jitterX, jitterY);
+ _effectType = "jitter";
+ return (JitterVertexEffect *)_vertexEffect;
+}
+
+SwirlVertexEffect *VertexEffectDelegate::initSwirlWithPow(float radius, int power) {
+ clear();
+ _interpolation = new spine::PowInterpolation(power);
+ _vertexEffect = new spine::SwirlVertexEffect(radius, *_interpolation);
+ _effectType = "swirl";
+ return (SwirlVertexEffect *)_vertexEffect;
+}
+
+SwirlVertexEffect *VertexEffectDelegate::initSwirlWithPowOut(float radius, int power) {
+ clear();
+ _interpolation = new spine::PowOutInterpolation(power);
+ _vertexEffect = new spine::SwirlVertexEffect(radius, *_interpolation);
+ _effectType = "swirl";
+ return (SwirlVertexEffect *)_vertexEffect;
+}
+
+JitterVertexEffect *VertexEffectDelegate::getJitterVertexEffect() {
+ JitterVertexEffect *jitter = dynamic_cast(_vertexEffect);
+ return jitter;
+}
+
+SwirlVertexEffect *VertexEffectDelegate::getSwirlVertexEffect() {
+ SwirlVertexEffect *swirl = dynamic_cast(_vertexEffect);
+ return swirl;
+}
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.h b/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.h
index a4a077cf93..2ab10813a2 100644
--- a/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.h
+++ b/native/cocos/editor-support/spine-creator-support/VertexEffectDelegate.h
@@ -1,59 +1,60 @@
-/******************************************************************************
- * Spine Runtimes License Agreement
- * Last updated January 1, 2020. Replaces all prior versions.
- *
- * Copyright (c) 2013-2020, Esoteric Software LLC
- *
- * Integration of the Spine Runtimes into software or otherwise creating
- * derivative works of the Spine Runtimes is permitted under the terms and
- * conditions of Section 2 of the Spine Editor License Agreement:
- * http://esotericsoftware.com/spine-editor-license
- *
- * Otherwise, it is permitted to integrate the Spine Runtimes into software
- * or otherwise create derivative works of the Spine Runtimes (collectively,
- * "Products"), provided that each user of the Products must obtain their own
- * Spine Editor license and redistribution of the Products in any form must
- * include this license and copyright notice.
- *
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *****************************************************************************/
-
-#pragma once
-
-#include
-#include "base/RefCounted.h"
-#include "spine/spine.h"
-
-namespace spine {
-class VertexEffectDelegate : public cc::RefCounted {
-public:
- VertexEffectDelegate();
- ~VertexEffectDelegate() override;
- JitterVertexEffect *initJitter(float jitterX, float jitterY);
- SwirlVertexEffect *initSwirlWithPow(float radius, int power);
- SwirlVertexEffect *initSwirlWithPowOut(float radius, int power);
- VertexEffect *getVertexEffect() {
- return _vertexEffect;
- }
- JitterVertexEffect *getJitterVertexEffect();
- SwirlVertexEffect *getSwirlVertexEffect();
- const std::string &getEffectType() const {
- return _effectType;
- }
- void clear();
-
-private:
- VertexEffect *_vertexEffect = nullptr;
- Interpolation *_interpolation = nullptr;
- std::string _effectType = "none";
-};
-} // namespace spine
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated January 1, 2020. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2020, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
+ * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#pragma once
+
+#include
+#include "base/RefCounted.h"
+#include "spine/spine.h"
+using namespace spine;
+namespace cc {
+
+class VertexEffectDelegate : public cc::RefCounted {
+public:
+ VertexEffectDelegate();
+ ~VertexEffectDelegate() override;
+ JitterVertexEffect *initJitter(float jitterX, float jitterY);
+ SwirlVertexEffect *initSwirlWithPow(float radius, int power);
+ SwirlVertexEffect *initSwirlWithPowOut(float radius, int power);
+ VertexEffect *getVertexEffect() {
+ return _vertexEffect;
+ }
+ JitterVertexEffect *getJitterVertexEffect();
+ SwirlVertexEffect *getSwirlVertexEffect();
+ const std::string &getEffectType() const {
+ return _effectType;
+ }
+ void clear();
+
+private:
+ VertexEffect *_vertexEffect = nullptr;
+ Interpolation *_interpolation = nullptr;
+ std::string _effectType = "none";
+};
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp b/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp
index 85cd0f5c8c..f3b01a027f 100644
--- a/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp
+++ b/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp
@@ -33,7 +33,7 @@
#include "platform/FileUtils.h"
#include "spine-creator-support/AttachmentVertices.h"
-namespace spine {
+namespace cc {
static CustomTextureLoader customTextureLoader = nullptr;
void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader) {
customTextureLoader = texLoader;
@@ -43,7 +43,7 @@ static SpineObjectDisposeCallback spineObjectDisposeCallback = nullptr;
void setSpineObjectDisposeCallback(SpineObjectDisposeCallback callback) {
spineObjectDisposeCallback = callback;
}
-} // namespace spine
+} // namespace cc
USING_NS_MW; // NOLINT(google-build-using-namespace)
using namespace cc; // NOLINT(google-build-using-namespace)
@@ -56,26 +56,45 @@ static void deleteAttachmentVertices(void *vertices) {
static uint16_t quadTriangles[6] = {0, 1, 2, 2, 3, 0};
static void setAttachmentVertices(RegionAttachment *attachment) {
+#if CC_USE_SPINE_3_8
auto *region = static_cast(attachment->getRendererObject());
auto *attachmentVertices = new AttachmentVertices(static_cast(region->page->getRendererObject()), 4, quadTriangles, 6);
+#else
+ auto *region = static_cast(attachment->getRegion());
+ auto *attachmentVertices = new AttachmentVertices(static_cast(region->page->texture), 4, quadTriangles, 6);
+#endif
V3F_T2F_C4B *vertices = attachmentVertices->_triangles->verts;
for (int i = 0, ii = 0; i < 4; ++i, ii += 2) {
vertices[i].texCoord.u = attachment->getUVs()[ii];
vertices[i].texCoord.v = attachment->getUVs()[ii + 1];
}
+#if CC_USE_SPINE_3_8
attachment->setRendererObject(attachmentVertices, deleteAttachmentVertices);
+#else
+ attachment->getRegion()->rendererObject = attachmentVertices;
+#endif
}
static void setAttachmentVertices(MeshAttachment *attachment) {
+#if CC_USE_SPINE_3_8
auto *region = static_cast(attachment->getRendererObject());
auto *attachmentVertices = new AttachmentVertices(static_cast(region->page->getRendererObject()),
static_cast(attachment->getWorldVerticesLength() >> 1), attachment->getTriangles().buffer(), static_cast(attachment->getTriangles().size()));
+#else
+ auto *region = static_cast(attachment->getRegion());
+ auto *attachmentVertices = new AttachmentVertices(static_cast(region->page->texture),
+ static_cast(attachment->getWorldVerticesLength() >> 1), attachment->getTriangles().buffer(), static_cast(attachment->getTriangles().size()));
+#endif
V3F_T2F_C4B *vertices = attachmentVertices->_triangles->verts;
for (size_t i = 0, ii = 0, nn = attachment->getWorldVerticesLength(); ii < nn; ++i, ii += 2) {
vertices[i].texCoord.u = attachment->getUVs()[ii];
vertices[i].texCoord.v = attachment->getUVs()[ii + 1];
}
+#if CC_USE_SPINE_3_8
attachment->setRendererObject(attachmentVertices, deleteAttachmentVertices);
+#else
+ attachment->getRegion()->rendererObject = attachmentVertices;
+#endif
}
Cocos2dAtlasAttachmentLoader::Cocos2dAtlasAttachmentLoader(Atlas *atlas) : AtlasAttachmentLoader(atlas) {
@@ -104,8 +123,8 @@ Cocos2dTextureLoader::~Cocos2dTextureLoader() = default;
void Cocos2dTextureLoader::load(AtlasPage &page, const spine::String &path) {
middleware::Texture2D *texture = nullptr;
- if (spine::customTextureLoader) {
- texture = spine::customTextureLoader(path.buffer());
+ if (customTextureLoader) {
+ texture = customTextureLoader(path.buffer());
}
CC_ASSERT_NOT_NULL(texture);
@@ -115,7 +134,11 @@ void Cocos2dTextureLoader::load(AtlasPage &page, const spine::String &path) {
middleware::Texture2D::TexParams textureParams = {filter(page.minFilter), filter(page.magFilter), wrap(page.uWrap), wrap(page.vWrap)};
texture->setTexParameters(textureParams);
+#if CC_USE_SPINE_3_8
page.setRendererObject(texture);
+#else
+ page.texture = texture;
+#endif
page.width = texture->getPixelsWide();
page.height = texture->getPixelsHigh();
}
diff --git a/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.h b/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.h
index 56ddce2781..4928c7106b 100644
--- a/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.h
+++ b/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.h
@@ -37,7 +37,7 @@
#include "spine-creator-support/SkeletonRenderer.h"
#include "spine/spine.h"
-namespace spine {
+namespace cc {
typedef cc::middleware::Texture2D *(*CustomTextureLoader)(const char *path);
// set custom texture loader for _spAtlasPage_createTexture
void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader);
@@ -74,4 +74,4 @@ protected:
typedef void (*SpineObjectDisposeCallback)(void *);
void setSpineObjectDisposeCallback(SpineObjectDisposeCallback callback);
-} // namespace spine
+} // namespace cc
diff --git a/native/cocos/editor-support/spine-wasm/spine-type-export.cpp b/native/cocos/editor-support/spine-wasm/3.8/spine-type-export.cpp
similarity index 99%
rename from native/cocos/editor-support/spine-wasm/spine-type-export.cpp
rename to native/cocos/editor-support/spine-wasm/3.8/spine-type-export.cpp
index de2af5ebbf..1b60e13cfb 100644
--- a/native/cocos/editor-support/spine-wasm/spine-type-export.cpp
+++ b/native/cocos/editor-support/spine-wasm/3.8/spine-type-export.cpp
@@ -2,9 +2,9 @@
#include
#include
#include
-#include "spine-skeleton-instance.h"
-#include "spine-wasm.h"
-#include "Vector2.h"
+#include "../spine-skeleton-instance.h"
+#include "../spine-wasm.h"
+#include "../Vector2.h"
using namespace spine;
diff --git a/native/cocos/editor-support/spine-wasm/4.2/spine-type-export.cpp b/native/cocos/editor-support/spine-wasm/4.2/spine-type-export.cpp
new file mode 100644
index 0000000000..3f508c71f8
--- /dev/null
+++ b/native/cocos/editor-support/spine-wasm/4.2/spine-type-export.cpp
@@ -0,0 +1,1417 @@
+#include
+#include
+#include
+#include
+#include "../spine-skeleton-instance.h"
+#include "../spine-wasm.h"
+#include "../Vector2.h"
+#include "spine/Vector.h"
+
+using namespace spine;
+
+using SPVectorFloat = Vector;
+using SPVectorVectorFloat = Vector>;
+using SPVectorInt = Vector;
+using SPVectorUint = Vector;
+using SPVectorVectorInt = Vector>;
+using SPVectorSize_t = Vector;
+using SPVectorBonePtr = Vector;
+using SPVectorBoneDataPtr = Vector;
+using SPVectorSlotDataPtr = Vector;
+using SPVectorTransformConstraintDataPtr = Vector;
+using SPVectorPathConstraintDataPtr = Vector;
+using SPVectorPhysicsConstraintDataPtr = Vector;
+using SPVectorUnsignedShort = Vector;
+using SPVectorSPString = Vector;
+using SPVectorConstraintDataPtr = Vector;
+using SPVectorSlotPtr = Vector;
+using SPVectorSkinPtr = Vector;
+using SPVectorEventDataPtr = Vector;
+using SPVectorEventPtr = Vector;
+using SPVectorAnimationPtr = Vector;
+using SPVectorIkConstraintPtr = Vector;
+using SPVectorIkConstraintDataPtr = Vector;
+using SPVectorTransformConstraintPtr = Vector;
+using SPVectorPathConstraintPtr = Vector;
+using SPVectorTimelinePtr = Vector;
+using SPVectorTrackEntryPtr = Vector;
+using SPVectorUpdatablePtr = Vector;
+using SPVectorSkinEntryPtr = Vector;
+using SPVectorVectorSkinEntryPtr = Vector;
+using SPVectorDebugShape = Vector;
+
+#define DEFINE_ALLOW_RAW_POINTER(type) \
+namespace emscripten { namespace internal { \
+ template<> \
+ struct TypeID { \
+ static constexpr TYPEID get() { \
+ return TypeID::get(); \
+ } \
+ }; \
+ template<> \
+ struct TypeID { \
+ static constexpr TYPEID get() { \
+ return TypeID::get(); \
+ } \
+ }; \
+}}
+
+
+#define DEFINE_SPINE_CLASS_TYPEID(cls) \
+namespace emscripten { namespace internal { \
+ template<> \
+ constexpr TYPEID getLightTypeID(const cls& value) { \
+ return value.getRTTI().getClassName(); \
+ } \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return #cls "*"; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return #cls "*"; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return #cls "*"; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return #cls "*"; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return "const " #cls "*"; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return "const " #cls "*"; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return "const " #cls "*"; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return "const " #cls "*"; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return #cls; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return #cls; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return #cls; \
+ } \
+ }; \
+ template<> \
+ struct LightTypeID { \
+ static constexpr TYPEID get() { \
+ return #cls; \
+ } \
+ }; \
+}}
+
+#define GETTER_RVAL_TO_PTR(ClassType, Method, ReturnType) \
+ optional_override([](ClassType &obj) { return const_cast(&obj.Method()); })
+
+
+DEFINE_SPINE_CLASS_TYPEID(ConstraintData)
+DEFINE_SPINE_CLASS_TYPEID(IkConstraintData)
+DEFINE_SPINE_CLASS_TYPEID(PathConstraintData)
+DEFINE_SPINE_CLASS_TYPEID(Attachment)
+DEFINE_SPINE_CLASS_TYPEID(VertexAttachment)
+DEFINE_SPINE_CLASS_TYPEID(BoundingBoxAttachment)
+DEFINE_SPINE_CLASS_TYPEID(ClippingAttachment)
+DEFINE_SPINE_CLASS_TYPEID(MeshAttachment)
+DEFINE_SPINE_CLASS_TYPEID(PathAttachment)
+DEFINE_SPINE_CLASS_TYPEID(PointAttachment)
+DEFINE_SPINE_CLASS_TYPEID(RegionAttachment)
+DEFINE_SPINE_CLASS_TYPEID(AttachmentLoader)
+DEFINE_SPINE_CLASS_TYPEID(AtlasAttachmentLoader)
+DEFINE_SPINE_CLASS_TYPEID(Interpolation)
+DEFINE_SPINE_CLASS_TYPEID(PowInterpolation)
+DEFINE_SPINE_CLASS_TYPEID(PowOutInterpolation)
+DEFINE_SPINE_CLASS_TYPEID(Updatable)
+DEFINE_SPINE_CLASS_TYPEID(IkConstraint)
+DEFINE_SPINE_CLASS_TYPEID(PathConstraint)
+DEFINE_SPINE_CLASS_TYPEID(TransformConstraintData)
+DEFINE_SPINE_CLASS_TYPEID(TransformConstraint)
+DEFINE_SPINE_CLASS_TYPEID(Bone)
+DEFINE_SPINE_CLASS_TYPEID(Timeline)
+DEFINE_SPINE_CLASS_TYPEID(CurveTimeline)
+DEFINE_SPINE_CLASS_TYPEID(CurveTimeline1)
+DEFINE_SPINE_CLASS_TYPEID(CurveTimeline2)
+DEFINE_SPINE_CLASS_TYPEID(TranslateTimeline)
+DEFINE_SPINE_CLASS_TYPEID(ScaleTimeline)
+DEFINE_SPINE_CLASS_TYPEID(ShearTimeline)
+DEFINE_SPINE_CLASS_TYPEID(RotateTimeline)
+DEFINE_SPINE_CLASS_TYPEID(InheritTimeline)
+DEFINE_SPINE_CLASS_TYPEID(RGBATimeline)
+DEFINE_SPINE_CLASS_TYPEID(RGBTimeline)
+DEFINE_SPINE_CLASS_TYPEID(RGBA2Timeline)
+DEFINE_SPINE_CLASS_TYPEID(RGB2Timeline)
+DEFINE_SPINE_CLASS_TYPEID(AlphaTimeline)
+DEFINE_SPINE_CLASS_TYPEID(AttachmentTimeline)
+DEFINE_SPINE_CLASS_TYPEID(DeformTimeline)
+DEFINE_SPINE_CLASS_TYPEID(EventTimeline)
+DEFINE_SPINE_CLASS_TYPEID(DrawOrderTimeline)
+DEFINE_SPINE_CLASS_TYPEID(IkConstraintTimeline)
+DEFINE_SPINE_CLASS_TYPEID(TransformConstraintTimeline)
+DEFINE_SPINE_CLASS_TYPEID(PathConstraintPositionTimeline)
+DEFINE_SPINE_CLASS_TYPEID(PathConstraintMixTimeline)
+DEFINE_SPINE_CLASS_TYPEID(PhysicsConstraintData)
+DEFINE_SPINE_CLASS_TYPEID(PhysicsConstraint)
+
+
+
+DEFINE_ALLOW_RAW_POINTER(BoneData)
+DEFINE_ALLOW_RAW_POINTER(Bone)
+DEFINE_ALLOW_RAW_POINTER(Slot)
+DEFINE_ALLOW_RAW_POINTER(SlotData)
+DEFINE_ALLOW_RAW_POINTER(Attachment)
+DEFINE_ALLOW_RAW_POINTER(VertexAttachment)
+DEFINE_ALLOW_RAW_POINTER(Color)
+DEFINE_ALLOW_RAW_POINTER(EventData)
+DEFINE_ALLOW_RAW_POINTER(Skeleton)
+DEFINE_ALLOW_RAW_POINTER(SkeletonData)
+DEFINE_ALLOW_RAW_POINTER(Skin)
+DEFINE_ALLOW_RAW_POINTER(Animation)
+DEFINE_ALLOW_RAW_POINTER(AnimationStateData)
+DEFINE_ALLOW_RAW_POINTER(TrackEntry)
+DEFINE_ALLOW_RAW_POINTER(IkConstraintData)
+DEFINE_ALLOW_RAW_POINTER(PathConstraintData)
+DEFINE_ALLOW_RAW_POINTER(TransformConstraintData)
+DEFINE_ALLOW_RAW_POINTER(SPVectorUnsignedShort)
+DEFINE_ALLOW_RAW_POINTER(SPVectorFloat)
+DEFINE_ALLOW_RAW_POINTER(SPVectorEventPtr)
+
+
+namespace {
+
+template
+void registerSpineInteger(const char* name) {
+ using namespace emscripten::internal;
+ using UnderlyingType = typename std::underlying_type::type;
+ _embind_register_integer(TypeID::get(), name, sizeof(T), std::numeric_limits::min(),
+ std::numeric_limits::max());
+}
+
+#define REGISTER_SPINE_ENUM(name) \
+ registerSpineInteger("spine::" #name)
+
+
+template
+struct SpineVectorTrait {};
+
+template
+struct SpineVectorTrait {
+ static emscripten::class_> register_spine_vector(const char* name) {
+ typedef spine::Vector VecType;
+
+ void (VecType::*setSize)(const size_t, const T&) = &VecType::setSize;
+ size_t (VecType::*size)() const = &VecType::size;
+ T& (VecType::*get)(size_t) = &VecType::operator[];
+ return emscripten::class_>(name)
+ .template constructor<>()
+ .function("resize", setSize)
+ .function("size", size)
+ .function("get", get, emscripten::allow_raw_pointers());
+ }
+};
+
+template
+struct SpineVectorTrait {
+ static emscripten::class_> register_spine_vector(const char* name) {
+ typedef spine::Vector VecType;
+
+ void (VecType::*setSize)(const size_t, const T&) = &VecType::setSize;
+ size_t (VecType::*size)() const = &VecType::size;
+ T& (VecType::*get)(size_t) = &VecType::operator[];
+ return emscripten::class_>(name)
+ .template constructor<>()
+ .function("resize", setSize)
+ .function("size", size)
+ .function("get", get)
+ .function("set", emscripten::optional_override([](VecType& obj, int index, const T& value){
+ obj[index] = value;
+ }), emscripten::allow_raw_pointers());
+ }
+};
+
+#define REGISTER_SPINE_VECTOR(name, needSetter) \
+ SpineVectorTrait::register_spine_vector(#name)
+
+
+} // namespace
+
+namespace emscripten { namespace internal {
+
+template
+struct GetterPolicy {
+ using ReturnType = GetterReturnType;
+ using Context = GetterReturnType (GetterThisType::*)();
+
+ using Binding = internal::BindingType;
+ using WireType = typename Binding::WireType;
+
+ // template
+ template
+ static WireType get(const Context& context, ClassType& ptr) {
+ // return Binding::toWireType(((ptr.*context)()), ReturnPolicy{});
+ return Binding::toWireType(((ptr.*context)()));
+ }
+
+ static void* getContext(Context context) {
+ return internal::getContext(context);
+ }
+};
+
+// Non-const version
+template
+struct GetterPolicy {
+ using ReturnType = GetterReturnType;
+ using Context = GetterReturnType (*)(GetterThisType &);
+
+ using Binding = internal::BindingType;
+ using WireType = typename Binding::WireType;
+
+ template
+ static WireType get(const Context& context, ClassType& ptr) {
+ return Binding::toWireType(context(ptr));
+ }
+
+ static void* getContext(Context context) {
+ return internal::getContext(context);
+ }
+};
+
+template<>
+struct BindingType {
+ using T = char;
+ static_assert(std::is_trivially_copyable::value, "basic_string elements are memcpy'd");
+ using WireType = struct {
+ size_t length;
+ T data[1]; // trailing data
+ } *;
+ static WireType toWireType(const String& v) {
+ auto* wt = static_cast(malloc(sizeof(size_t) + v.length() * sizeof(T)));
+ wt->length = v.length();
+ memcpy(wt->data, v.buffer(), v.length() * sizeof(T));
+ return wt;
+ }
+ static String fromWireType(WireType v) {
+ return String(v->data, v->length, false);
+ }
+};
+
+} // namespace internal
+} // namespace emscripten
+
+#define ENABLE_EMBIND_TEST 0
+
+#if ENABLE_EMBIND_TEST
+
+class TestBase {
+ RTTI_DECL
+public:
+ virtual void hello(const String& msg) {
+ printf("TestBase::hello: %s\n", msg.buffer());
+ }
+};
+
+RTTI_IMPL_NOPARENT(TestBase)
+
+class TestFoo: public TestBase {
+ RTTI_DECL
+public:
+ TestFoo() {
+ printf("TestFoo::TestFoo: %p\n", this);
+ }
+
+ TestFoo(const TestFoo& o) {
+ printf("TestFoo copy constructor %p, %p, o.x=%d\n", this, &o, o._x);
+ *this = o;
+ }
+
+ ~TestFoo() {
+ printf("TestFoo::~TestFoo: %p\n", this);
+ }
+
+ TestFoo &operator=(const TestFoo& o) {
+ printf("TestFoo::operator=: %p\n", this);
+ if (this != &o) {
+ _x = o._x;
+ printf("TestFoo::operator=, _x=%d\n", _x);
+ } else {
+ printf("TestFoo::operator=, same address\n");
+ }
+ return *this;
+ }
+
+ virtual void hello(const String& msg) override {
+ printf("TestFoo::hello: %s\n", msg.buffer());
+ }
+
+ void setX(int x) {
+ _x = x;
+ }
+ int getX() const {
+ return _x;
+ }
+
+ static void apply(int a, int b) {
+ printf("apply1, a: %d, b: %d\n", a, b);
+ }
+ static void apply(const Vector& a, bool b) {
+ printf("apply2, a, size: %d, b: %d\n", (int)a.size(), b);
+ for (int i = 0; i < a.size(); ++i) {
+ printf("apply2, aaa: [%d]=%d\n", i, a[i]);
+ }
+ }
+private:
+ int _x = 0;
+};
+
+RTTI_IMPL(TestFoo, TestBase)
+
+DEFINE_SPINE_CLASS_TYPEID(TestBase)
+DEFINE_SPINE_CLASS_TYPEID(TestFoo)
+
+DEFINE_ALLOW_RAW_POINTER(TestBase)
+DEFINE_ALLOW_RAW_POINTER(TestFoo)
+
+class TestBar {
+public:
+ RTTI_DECL
+ TestBar() {
+ printf("TestBar::TestBar: %p\n", this);
+ }
+
+ TestBar(const TestBar& o) {
+ printf("TestBar copy constructor %p\n", this);
+ *this = o;
+ }
+
+ ~TestBar() {
+ printf("TestBar::~TestBar: %p\n", this);
+ delete _foo;
+ }
+
+ TestBar &operator=(const TestBar& o) {
+ printf("TestBar::operator=: %p\n", this);
+ if (this != &o) {
+ _foo = o._foo;
+ }
+ return *this;
+ }
+
+ const TestFoo* getFoo() const {
+ return _foo;
+ }
+
+ void setFoo(TestFoo *foo) {
+ if (_foo != foo) {
+ delete _foo;
+ _foo = foo;
+ }
+ }
+
+ const TestBase* getBase() const {
+ return _foo;
+ }
+
+ const TestFoo& getFooConst() {
+ return *_foo;
+ }
+
+ void setFooConst(const TestFoo& foo) {
+ _foo = &foo;
+ }
+
+ Vector getNames() {
+ Vector ret;
+ ret.add(String("你好"));
+ ret.add(String("World"));
+ return ret;
+ }
+
+private:
+ const TestFoo *_foo = new TestFoo();
+};
+
+RTTI_IMPL_NOPARENT(TestBar)
+
+
+#endif // ENABLE_EMBIND_TEST
+
+
+EMSCRIPTEN_BINDINGS(spine) {
+ using namespace emscripten;
+ using namespace emscripten::internal;
+
+#if ENABLE_EMBIND_TEST
+ class_("TestBase")
+ .constructor()
+ .function("hello", &TestBase::hello);
+
+ class_>("TestFoo")
+ .constructor()
+ .property("x", &TestFoo::getX, &TestFoo::setX)
+ .class_function("apply1", select_overload(&TestFoo::apply))
+ .class_function("apply2", select_overload &, bool)>(&TestFoo::apply))
+ ;
+
+ class_("TestBar")
+ .constructor()
+ .property("foo", &TestBar::getFoo, &TestBar::setFoo)
+ .property("base", &TestBar::getBase)
+ .function("getBase", &TestBar::getBase, allow_raw_pointers())
+ .function("getFooConst", &TestBar::getFooConst, allow_raw_pointers())
+ .function("setFooConst", &TestBar::setFooConst, allow_raw_pointers())
+ .function("getNames", &TestBar::getNames)
+ .property("names", &TestBar::getNames)
+ ;
+
+ Json json(R"({"smile": "\uD83D\uDE0A🇨🇳 \uD83D\uDE00 \uD83D\uDE02 \uD83D\uDE21 "})");
+ const char *smileValue = Json::getString(&json, R"(smile)", "");
+ printf(">>> smile value: %s\n", smileValue);
+
+#endif // ENABLE_EMBIND_TEST
+
+ _embind_register_std_string(TypeID::get(), "std::string");
+
+ REGISTER_SPINE_ENUM(MixDirection);
+ REGISTER_SPINE_ENUM(MixBlend);
+ REGISTER_SPINE_ENUM(EventType);
+ REGISTER_SPINE_ENUM(BlendMode);
+ REGISTER_SPINE_ENUM(PositionMode);
+ REGISTER_SPINE_ENUM(SpacingMode);
+ REGISTER_SPINE_ENUM(RotateMode);
+ REGISTER_SPINE_ENUM(TextureFilter);
+ REGISTER_SPINE_ENUM(TextureWrap);
+ REGISTER_SPINE_ENUM(AttachmentType);
+
+
+ REGISTER_SPINE_VECTOR(SPVectorDebugShape, false);
+
+ REGISTER_SPINE_VECTOR(SPVectorFloat, true);
+ REGISTER_SPINE_VECTOR(SPVectorVectorFloat, true);
+ REGISTER_SPINE_VECTOR(SPVectorInt, true);
+ REGISTER_SPINE_VECTOR(SPVectorUint, true);
+ REGISTER_SPINE_VECTOR(SPVectorVectorInt, true);
+ REGISTER_SPINE_VECTOR(SPVectorSize_t, true);
+ REGISTER_SPINE_VECTOR(SPVectorUnsignedShort, true);
+
+ REGISTER_SPINE_VECTOR(SPVectorSPString, true);
+ REGISTER_SPINE_VECTOR(SPVectorBonePtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorBoneDataPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorSlotDataPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorTransformConstraintDataPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorPathConstraintDataPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorConstraintDataPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorSlotPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorSkinPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorEventDataPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorEventPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorAnimationPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorIkConstraintPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorIkConstraintDataPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorTransformConstraintPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorPathConstraintPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorTimelinePtr, true); // .set used in Animation constructor
+ REGISTER_SPINE_VECTOR(SPVectorTrackEntryPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorUpdatablePtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorSkinEntryPtr, false);
+ REGISTER_SPINE_VECTOR(SPVectorVectorSkinEntryPtr, false);
+
+ class_("TextureRegion")
+ .property("u", &TextureRegion::u)
+ .property("v", &TextureRegion::v)
+ .property("u2", &TextureRegion::u2)
+ .property("v2", &TextureRegion::v2)
+ .property("degrees", &TextureRegion::degrees)
+ .property("offsetX", &TextureRegion::offsetX)
+ .property("offsetY", &TextureRegion::offsetY)
+ .property("width", &TextureRegion::width)
+ .property("height", &TextureRegion::height)
+ .property("originalWidth", &TextureRegion::originalWidth)
+ .property("originalHeight", &TextureRegion::originalHeight);
+
+ class_("Vector2")
+ .constructor<>()
+ .constructor()
+ .property("x", &Vector2::x)
+ .property("y", &Vector2::y)
+ .function("set", &Vector2::set)
+ .function("length", &Vector2::length)
+ .function("normalize", &Vector2::normalize);
+
+ class_("Color")
+ .constructor<>()
+ .constructor()
+ .function("set", select_overload(&Color::set))
+ .function("add", select_overload(&Color::add))
+ .function("clamp", &Color::clamp)
+ .property("r", &Color::r)
+ .property("g", &Color::g)
+ .property("b", &Color::b)
+ .property("a", &Color::a);
+
+ class_("Interpolation")
+ .function("apply", &Interpolation::apply, pure_virtual());
+
+ class_("HasRendererObject")
+ .constructor<>();
+
+ // class_("Triangulator")
+ // .constructor<>()
+ // .function("triangulate", &Triangulator::triangulate)
+ // .function("decompose", &Triangulator::decompose, allow_raw_pointers());
+
+ class_("ConstraintData")
+ .constructor()
+ .property("name", &ConstraintData::getName)
+ .property("order", &ConstraintData::_order)
+ .property("skinRequired", &ConstraintData::_skinRequired);
+
+ class_>("IkConstraintData")
+ .constructor()
+ .function("getBones", optional_override([](IkConstraintData &obj) {
+ return &obj.getBones(); }), allow_raw_pointer())
+ .property("target", &IkConstraintData::_target)
+ .property("bendDirection", &IkConstraintData::_bendDirection)
+ .property("compress", &IkConstraintData::_compress)
+ .property("stretch", &IkConstraintData::_stretch)
+ .property("uniform", &IkConstraintData::_uniform)
+ .property("mix", &IkConstraintData::_mix)
+ .property("softness", &IkConstraintData::_softness);
+
+ class_>("PathConstraintData")
+ .constructor()
+ .function("getBones",optional_override([](PathConstraintData &obj) {
+ return obj.getBones(); }), allow_raw_pointer())
+ .property("target", &PathConstraintData::_target)
+ .property("positionMode", &PathConstraintData::_positionMode)
+ .property("spacingMode", &PathConstraintData::_spacingMode)
+ .property("rotateMode", &PathConstraintData::_rotateMode)
+ .property("offsetRotation", &PathConstraintData::_offsetRotation)
+ .property("position", &PathConstraintData::_position)
+ .property("spacing", &PathConstraintData::_spacing)
+ .property("mixRotate", &PathConstraintData::getMixRotate)
+ .property("mixX", &PathConstraintData::getMixX)
+ .property("mixY", &PathConstraintData::getMixY);
+
+
+ class_("SkeletonBounds")
+ .constructor<>()
+ .function("update", &SkeletonBounds::update)
+ .function("aabbContainsPoint", &SkeletonBounds::aabbcontainsPoint)
+ .function("aabbIntersectsSegment", &SkeletonBounds::aabbintersectsSegment)
+ .function("aabbIntersectsSkeleton", &SkeletonBounds::aabbIntersectsSkeleton)
+ .function("containsPoint", optional_override([](SkeletonBounds &obj, float x, float y) {
+ return obj.containsPoint(x, y); }),allow_raw_pointers())
+ // .function("containsPointPolygon", optional_override([](SkeletonBounds &obj,Polygon* polygon, float x, float y) {
+ // return obj.containsPoint(polygon, x, y); }),allow_raw_pointers())
+ .function("intersectsSegment", optional_override([](SkeletonBounds &obj, float x1, float y1, float x2, float y2){
+ return obj.intersectsSegment(x1, y1, x2, y2); }),allow_raw_pointers())
+ // .function("intersectsSegmentPolygon", optional_override([](SkeletonBounds &obj,Polygon* polygon,
+ // float x1, float y1, float x2, float y2){
+ // return obj.intersectsSegment(polygon, x1, y1, x2, y2); }),allow_raw_pointers())
+ // .function("getPolygon", &SkeletonBounds::getPolygon, allow_raw_pointers())
+ .function("getWidth", &SkeletonBounds::getWidth)
+ .function("getHeight", &SkeletonBounds::getHeight);
+
+ class_("Event")
+ .constructor()
+ .property("data", GETTER_RVAL_TO_PTR(Event, getData, EventData*))
+ .property("intValue", &Event::_intValue)
+ .property("floatValue", &Event::_floatValue)
+ .property("stringValue", &Event::_stringValue)
+ .property("time", &Event::_time)
+ .property("volume", &Event::_volume)
+ .property("balance", &Event::_balance);
+
+ class_("EventData")
+ .constructor()
+ .property("name", &EventData::getName)
+ .property("intValue", &EventData::_intValue)
+ .property("floatValue", &EventData::_floatValue)
+ .property("stringValue", &EventData::_stringValue)
+ .property("audioPath", &EventData::_audioPath)
+ .property("volume", &EventData::_volume)
+ .property("balance", &EventData::_balance);
+
+ class_("Attachment")
+ .property("name", &Attachment::getName);
+
+ // pure_virtual and raw pointer
+ class_>("VertexAttachment")
+ .property("id", &VertexAttachment::getId)
+ .function("getBones", optional_override([](VertexAttachment &obj){
+ return &obj.getBones(); }), allow_raw_pointer())
+ .function("getVertices", optional_override([](VertexAttachment &obj){
+ return &obj.getVertices(); }), allow_raw_pointer