Compare commits
122 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 68552314c0 | |||
| 550eb15641 | |||
| c438c2d3f8 | |||
| f5eaf97ce7 | |||
| 69d3d6033a | |||
| 469614cf0b | |||
| f81094f226 | |||
| 825362fac1 | |||
| 609512f8da | |||
| 09b63786f4 | |||
| 2b7b438768 | |||
| 6b5c8556a2 | |||
| ff436d6a27 | |||
| 09c38ea03f | |||
| 926bd5b619 | |||
| e317c04512 | |||
| 140068ddb1 | |||
| 80a9d0619e | |||
| a01046e391 | |||
| 2b6ec3b4f0 | |||
| 6060f58d1a | |||
| 18456b6706 | |||
| 62b55a0c48 | |||
| 0eac18be1a | |||
| 01983b75f2 | |||
| 2d003cc616 | |||
| b710cb6e9b | |||
| f948b5900e | |||
| b7883f18ba | |||
| 3ab299035a | |||
| c2ab919e9d | |||
| 5690d1b8a5 | |||
| ed0751652b | |||
| 97e402c3dc | |||
| f378a866cb | |||
| 7253ee4a7f | |||
| db5462603e | |||
| 9f0e30acb3 | |||
| a0a2e97c00 | |||
| 90e551b4a1 | |||
| 0a21bb9397 | |||
| 2c91155928 | |||
| 6f90cec3d4 | |||
| 4992692780 | |||
| d5f24e6170 | |||
| e778833d15 | |||
| c3a8a72f63 | |||
| 2c0e75059f | |||
| 19f4bd5b16 | |||
| 085d05928d | |||
| fb4d586629 | |||
| 620d38cf42 | |||
| d2713fe00e | |||
| 3aeb193d42 | |||
| c4e4790ee6 | |||
| 143af30cf2 | |||
| d6ff23fed4 | |||
| 84e8d4ebf7 | |||
| f2b9936033 | |||
| 129eb437ad | |||
| c58c893334 | |||
| ab982aec68 | |||
| 2d2bbe6731 | |||
| 187387b03f | |||
| 661253a521 | |||
| b6d0f02e88 | |||
| dd1b155d3a | |||
| df96ee85f3 | |||
| 708a343ce8 | |||
| 393203c2f8 | |||
| f3d11f017b | |||
| 09c201017c | |||
| ce6107d930 | |||
| ab8792686b | |||
| 44ef76855b | |||
| 8878e7aade | |||
| 621880a123 | |||
| 2eb268bf9a | |||
| 2e6cc9b127 | |||
| 98917ff2a7 | |||
| dc29d2f8f8 | |||
| eec2a1693b | |||
| 632f9b442f | |||
| 8ce19b658e | |||
| 07f2c5fb43 | |||
| 9b17fd6165 | |||
| e2795f9ecd | |||
| 89a412e0d6 | |||
| aef31099d8 | |||
| 89f8768e57 | |||
| 424be5d0b2 | |||
| e5183b796a | |||
| 32478c1a9c | |||
| 74e632a3d6 | |||
| 26883ba6f4 | |||
| 055c70f8d2 | |||
| 99f6db401c | |||
| 9390ee6bc0 | |||
| 7f258dac58 | |||
| 5c99570616 | |||
| 821928733b | |||
| f567861ff6 | |||
| a7a20b64ab | |||
| 7c75834010 | |||
| 8fd985af75 | |||
| cc97bc8af4 | |||
| 92124590fe | |||
| 822ac6026c | |||
| 4a6f83bd6d | |||
| 04f063eb2b | |||
| 910865bd8b | |||
| e384f54ed2 | |||
| 5964835c83 | |||
| f4ae16247c | |||
| 4b4a3ca13f | |||
| f1c5d21be6 | |||
| da75e89f4a | |||
| aba27a715d | |||
| 62c1eb58c3 | |||
| 5b09978eb1 | |||
| 1b8da1df9b | |||
| ea6ff53aad |
@@ -20,8 +20,14 @@ if ($env:GITHUB_BASE_REF) {
|
|||||||
# Push
|
# Push
|
||||||
$gitHubEvent = Get-Content $env:GITHUB_EVENT_PATH | ConvertFrom-Json
|
$gitHubEvent = Get-Content $env:GITHUB_EVENT_PATH | ConvertFrom-Json
|
||||||
Write-Host "GitHub event: $gitHubEvent"
|
Write-Host "GitHub event: $gitHubEvent"
|
||||||
git fetch origin $gitHubEvent.before --depth=1
|
$beforeSha = $gitHubEvent.before
|
||||||
$diffFiles = git diff --name-only --diff-filter=$diffFilter $gitHubEvent.before $env:GITHUB_SHA
|
# On tag creation or initial push, before is all zeros - skip diff in that case
|
||||||
|
if ($beforeSha -match '^0+$') {
|
||||||
|
Write-Host "No previous commit (tag creation or initial push). Skipping diff."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
git fetch origin $beforeSha --depth=1
|
||||||
|
$diffFiles = git diff --name-only --diff-filter=$diffFilter $beforeSha $env:GITHUB_SHA
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Diff files: $diffFiles"
|
Write-Host "Diff files: $diffFiles"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
ref: ${{ github.head_sha }}
|
ref: ${{ github.head_sha }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- id: get_change_files
|
- id: get_change_files
|
||||||
uses: fish9167/file-changes-action@v1.2.3
|
uses: fish9167/file-changes-action@v1.2.3
|
||||||
@@ -25,18 +26,13 @@ jobs:
|
|||||||
output: ' '
|
output: ' '
|
||||||
fileOutput: ' '
|
fileOutput: ' '
|
||||||
|
|
||||||
- name: Echo change files
|
- uses: DoozyX/clang-format-lint-action@v0.18
|
||||||
run: |
|
|
||||||
cat $HOME/files.txt
|
|
||||||
mv $HOME/files.txt ${{github.workspace}}/files.txt
|
|
||||||
|
|
||||||
- uses: fish9167/clang-format-lint-action@master
|
|
||||||
with:
|
with:
|
||||||
source: ./native
|
source: ./native
|
||||||
exclude: ./native/cocos/bindings/auto
|
exclude: ./native/cocos/bindings/auto ./native/cocos/base/std ./native/cocos/editor-support/spine-wasm ./native/cocos/editor-support/spine ./native/cocos/gi/light-probe/predicates.cpp ./native/cocos/gi/light-probe/tetgen.cpp ./native/cocos/gi/light-probe/tetgen.h ./native/cocos/platform/openharmony/napi ./native/tools ./native/vendor ./native/cocos/cocos-version.h
|
||||||
extensions: 'c,h,hpp,cpp,cxx'
|
extensions: 'c,h,hpp,cpp,cxx'
|
||||||
style: file
|
style: file
|
||||||
inplace: True
|
inplace: true
|
||||||
clangFormatVersion: 12
|
clangFormatVersion: 12
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
|
|||||||
@@ -483,8 +483,8 @@ jobs:
|
|||||||
echo "set(CC_USE_GLES3 OFF)" >> build-mac/proj/cfg.cmake
|
echo "set(CC_USE_GLES3 OFF)" >> build-mac/proj/cfg.cmake
|
||||||
echo "set(CC_USE_METAL ON)" >> build-mac/proj/cfg.cmake
|
echo "set(CC_USE_METAL ON)" >> build-mac/proj/cfg.cmake
|
||||||
# Test JSVM v8 backend on macOS.
|
# Test JSVM v8 backend on macOS.
|
||||||
echo "set(USE_SE_V8 OFF)" >> build-mac/proj/cfg.cmake
|
echo "set(USE_SE_V8 ON)" >> build-mac/proj/cfg.cmake
|
||||||
echo "set(USE_SE_JSVM ON)" >> build-mac/proj/cfg.cmake
|
echo "set(USE_SE_JSVM OFF)" >> build-mac/proj/cfg.cmake
|
||||||
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-mac/proj/cfg.cmake
|
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-mac/proj/cfg.cmake
|
||||||
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-mac/proj/cfg.cmake
|
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-mac/proj/cfg.cmake
|
||||||
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-mac/proj/cfg.cmake
|
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-mac/proj/cfg.cmake
|
||||||
@@ -493,7 +493,6 @@ jobs:
|
|||||||
RES_DIR=$GITHUB_WORKSPACE/templates/mac/build-mac
|
RES_DIR=$GITHUB_WORKSPACE/templates/mac/build-mac
|
||||||
cd build-mac
|
cd build-mac
|
||||||
cmake ../ -GXcode -DCMAKE_OSX_ARCHITECTURES=${{ matrix.config.arch }} -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$NATIVE_ROOT
|
cmake ../ -GXcode -DCMAKE_OSX_ARCHITECTURES=${{ matrix.config.arch }} -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$NATIVE_ROOT
|
||||||
set +e
|
|
||||||
cmake --build . --config Release -- -jobs $NUM_OF_CORES -arch ${{ matrix.config.arch }}
|
cmake --build . --config Release -- -jobs $NUM_OF_CORES -arch ${{ matrix.config.arch }}
|
||||||
echo "Compile MacOSX Release Done!"
|
echo "Compile MacOSX Release Done!"
|
||||||
|
|
||||||
@@ -534,7 +533,7 @@ jobs:
|
|||||||
echo "set(CC_USE_VULKAN OFF)" >> build-ios/proj/cfg.cmake
|
echo "set(CC_USE_VULKAN OFF)" >> build-ios/proj/cfg.cmake
|
||||||
echo "set(CC_USE_GLES2 OFF)" >> build-ios/proj/cfg.cmake
|
echo "set(CC_USE_GLES2 OFF)" >> build-ios/proj/cfg.cmake
|
||||||
echo "set(CC_USE_METAL ON)" >> build-ios/proj/cfg.cmake
|
echo "set(CC_USE_METAL ON)" >> build-ios/proj/cfg.cmake
|
||||||
echo "set(TARGET_IOS_VERSION 12.0)" >> build-ios/proj/cfg.cmake
|
echo "set(TARGET_IOS_VERSION 13.0)" >> build-ios/proj/cfg.cmake
|
||||||
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-ios/proj/cfg.cmake
|
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-ios/proj/cfg.cmake
|
||||||
echo "set(USE_DRAGONBONES OFF)" >> build-ios/proj/cfg.cmake
|
echo "set(USE_DRAGONBONES OFF)" >> build-ios/proj/cfg.cmake
|
||||||
echo "set(CMAKE_CXX_STANDARD_REQUIRED OFF)" >> build-ios/proj/cfg.cmake
|
echo "set(CMAKE_CXX_STANDARD_REQUIRED OFF)" >> build-ios/proj/cfg.cmake
|
||||||
@@ -548,7 +547,6 @@ jobs:
|
|||||||
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.config.arch }} \
|
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.config.arch }} \
|
||||||
-DRES_DIR=$RES_DIR \
|
-DRES_DIR=$RES_DIR \
|
||||||
-DCOCOS_X_PATH=$NATIVE_ROOT
|
-DCOCOS_X_PATH=$NATIVE_ROOT
|
||||||
set +e
|
|
||||||
#cmake --build . --config Debug -- -quiet -jobs $NUM_OF_CORES -allowProvisioningUpdates CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
|
#cmake --build . --config Debug -- -quiet -jobs $NUM_OF_CORES -allowProvisioningUpdates CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
|
||||||
cmake --build . --config Debug -- -jobs $NUM_OF_CORES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
|
cmake --build . --config Debug -- -jobs $NUM_OF_CORES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
|
||||||
echo "Compile iOS Done!"
|
echo "Compile iOS Done!"
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- run: npm ci --ignore-scripts
|
- run: npm ci --ignore-scripts
|
||||||
|
- run: node scripts/spread-pal.cjs
|
||||||
- run: npm run build:debug-infos
|
- run: npm run build:debug-infos
|
||||||
- name: Download external
|
- name: Download external
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -46,3 +46,11 @@ platforms/runtime/platforms/vivo-mini-game/ral.min.js
|
|||||||
@types/consts.d.ts
|
@types/consts.d.ts
|
||||||
|
|
||||||
__TS_ENGINE__/
|
__TS_ENGINE__/
|
||||||
|
|
||||||
|
# pal 由 @cocos/engine-pal 在 postinstall 挂载(软链/复制),不入库
|
||||||
|
/pal
|
||||||
|
|
||||||
|
# platforms 源码已抽到 @cocos/engine-platforms;其预打包 adapter 由 postinstall 的
|
||||||
|
# spread-adapter.cjs 复制到 bin/adapter(/bin 已忽略)。platforms 源码不再入库。
|
||||||
|
/platforms
|
||||||
|
|
||||||
|
|||||||
@@ -3980,3 +3980,7 @@ Debug bones or slots is invalid in cached mode.
|
|||||||
### 16419
|
### 16419
|
||||||
|
|
||||||
Spine version not supported.
|
Spine version not supported.
|
||||||
|
|
||||||
|
### 16420
|
||||||
|
|
||||||
|
End time must bigger than start time.
|
||||||
|
|||||||
@@ -382,70 +382,70 @@
|
|||||||
"test": "context.buildTimeConstants && context.buildTimeConstants.HTML5",
|
"test": "context.buildTimeConstants && context.buildTimeConstants.HTML5",
|
||||||
"isVirtualModule": true,
|
"isVirtualModule": true,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"pal/minigame": "pal/minigame/non-minigame.ts",
|
"pal/minigame": "pal/minigame/non-minigame.js",
|
||||||
"pal/audio": "pal/audio/web/player.ts",
|
"pal/audio": "pal/audio/web/player.js",
|
||||||
"pal/system-info": "pal/system-info/web/system-info.ts",
|
"pal/system-info": "pal/system-info/web/system-info.js",
|
||||||
"pal/screen-adapter": "pal/screen-adapter/web/screen-adapter.ts",
|
"pal/screen-adapter": "pal/screen-adapter/web/screen-adapter.js",
|
||||||
"pal/input": "pal/input/web/index.ts",
|
"pal/input": "pal/input/web/index.js",
|
||||||
"pal/env": "pal/env/web/env.ts",
|
"pal/env": "pal/env/web/env.js",
|
||||||
"pal/pacer": "pal/pacer/pacer-web.ts",
|
"pal/pacer": "pal/pacer/pacer-web.js",
|
||||||
"pal/wasm": "pal/wasm/wasm-web.ts"
|
"pal/wasm": "pal/wasm/wasm-web.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test": "context.buildTimeConstants && context.buildTimeConstants.NATIVE",
|
"test": "context.buildTimeConstants && context.buildTimeConstants.NATIVE",
|
||||||
"isVirtualModule": true,
|
"isVirtualModule": true,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"pal/minigame": "pal/minigame/non-minigame.ts",
|
"pal/minigame": "pal/minigame/non-minigame.js",
|
||||||
"pal/audio": "pal/audio/native/player.ts",
|
"pal/audio": "pal/audio/native/player.js",
|
||||||
"pal/system-info": "pal/system-info/native/system-info.ts",
|
"pal/system-info": "pal/system-info/native/system-info.js",
|
||||||
"pal/screen-adapter": "pal/screen-adapter/native/screen-adapter.ts",
|
"pal/screen-adapter": "pal/screen-adapter/native/screen-adapter.js",
|
||||||
"pal/input": "pal/input/native/index.ts",
|
"pal/input": "pal/input/native/index.js",
|
||||||
"pal/env": "pal/env/native/env.ts",
|
"pal/env": "pal/env/native/env.js",
|
||||||
"pal/pacer": "pal/pacer/pacer-native.ts",
|
"pal/pacer": "pal/pacer/pacer-native.js",
|
||||||
"pal/wasm": "pal/wasm/wasm-native.ts"
|
"pal/wasm": "pal/wasm/wasm-native.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test": "context.buildTimeConstants && context.buildTimeConstants.MINIGAME",
|
"test": "context.buildTimeConstants && context.buildTimeConstants.MINIGAME",
|
||||||
"isVirtualModule": true,
|
"isVirtualModule": true,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"pal/minigame": "pal/minigame/{{context.platform.toLowerCase()}}.ts",
|
"pal/minigame": "pal/minigame/{{context.platform.toLowerCase()}}.js",
|
||||||
"pal/audio": "pal/audio/minigame/player.ts",
|
"pal/audio": "pal/audio/minigame/player.js",
|
||||||
"pal/system-info": "pal/system-info/minigame/system-info.ts",
|
"pal/system-info": "pal/system-info/minigame/system-info.js",
|
||||||
"pal/screen-adapter": "pal/screen-adapter/minigame/screen-adapter.ts",
|
"pal/screen-adapter": "pal/screen-adapter/minigame/screen-adapter.js",
|
||||||
"pal/input": "pal/input/minigame/index.ts",
|
"pal/input": "pal/input/minigame/index.js",
|
||||||
"pal/env": "pal/env/minigame/env.ts",
|
"pal/env": "pal/env/minigame/env.js",
|
||||||
"pal/pacer": "pal/pacer/pacer-minigame.ts",
|
"pal/pacer": "pal/pacer/pacer-minigame.js",
|
||||||
"pal/wasm": "pal/wasm/wasm-minigame.ts"
|
"pal/wasm": "pal/wasm/wasm-minigame.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test": "context.buildTimeConstants && context.buildTimeConstants.RUNTIME_BASED",
|
"test": "context.buildTimeConstants && context.buildTimeConstants.RUNTIME_BASED",
|
||||||
"isVirtualModule": true,
|
"isVirtualModule": true,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"pal/minigame": "pal/minigame/runtime.ts",
|
"pal/minigame": "pal/minigame/runtime.js",
|
||||||
"pal/audio": "pal/audio/minigame/player.ts",
|
"pal/audio": "pal/audio/minigame/player.js",
|
||||||
"pal/system-info": "pal/system-info/minigame/system-info.ts",
|
"pal/system-info": "pal/system-info/minigame/system-info.js",
|
||||||
"pal/screen-adapter": "pal/screen-adapter/minigame/screen-adapter.ts",
|
"pal/screen-adapter": "pal/screen-adapter/minigame/screen-adapter.js",
|
||||||
"pal/input": "pal/input/minigame/index.ts",
|
"pal/input": "pal/input/minigame/index.js",
|
||||||
"pal/env": "pal/env/runtime/env.ts",
|
"pal/env": "pal/env/runtime/env.js",
|
||||||
"pal/pacer": "pal/pacer/pacer-minigame.ts",
|
"pal/pacer": "pal/pacer/pacer-minigame.js",
|
||||||
"pal/wasm": "pal/wasm/wasm-minigame.ts"
|
"pal/wasm": "pal/wasm/wasm-minigame.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test": "context.buildTimeConstants && context.buildTimeConstants.NODEJS",
|
"test": "context.buildTimeConstants && context.buildTimeConstants.NODEJS",
|
||||||
"isVirtualModule": true,
|
"isVirtualModule": true,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"pal/minigame": "pal/minigame/non-minigame.ts",
|
"pal/minigame": "pal/minigame/non-minigame.js",
|
||||||
"pal/audio": "pal/audio/nodejs/player.ts",
|
"pal/audio": "pal/audio/nodejs/player.js",
|
||||||
"pal/system-info": "pal/system-info/nodejs/system-info.ts",
|
"pal/system-info": "pal/system-info/nodejs/system-info.js",
|
||||||
"pal/screen-adapter": "pal/screen-adapter/nodejs/screen-adapter.ts",
|
"pal/screen-adapter": "pal/screen-adapter/nodejs/screen-adapter.js",
|
||||||
"pal/input": "pal/input/nodejs/index.ts",
|
"pal/input": "pal/input/nodejs/index.js",
|
||||||
"pal/env": "pal/env/nodejs/env.ts",
|
"pal/env": "pal/env/nodejs/env.js",
|
||||||
"pal/pacer": "pal/pacer/pacer-nodejs.ts",
|
"pal/pacer": "pal/pacer/pacer-nodejs.js",
|
||||||
"pal/wasm": "pal/wasm/wasm-nodejs.ts"
|
"pal/wasm": "pal/wasm/wasm-nodejs.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -470,7 +470,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test": "context.buildTimeConstants.SPINE_3_8",
|
"test": "context.buildTimeConstants.SPINE_3_8 && context.buildTimeConstants.SPINE_4_2",
|
||||||
|
"isVirtualModule": false,
|
||||||
|
"overrides": {
|
||||||
|
"cocos/spine/lib/spine-version.ts": "cocos/spine/lib/spine-version-dynamic.ts",
|
||||||
|
"cocos/spine/lib/spine-instantiate.ts": "cocos/spine/lib/spine-instantiate-dynamic.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "context.buildTimeConstants.SPINE_3_8 && !context.buildTimeConstants.SPINE_4_2",
|
||||||
"isVirtualModule": false,
|
"isVirtualModule": false,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"cocos/spine/lib/spine-version.ts": "cocos/spine/lib/spine-version-3.8.ts",
|
"cocos/spine/lib/spine-version.ts": "cocos/spine/lib/spine-version-3.8.ts",
|
||||||
@@ -478,7 +486,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test": "context.buildTimeConstants.SPINE_4_2",
|
"test": "context.buildTimeConstants.SPINE_4_2 && !context.buildTimeConstants.SPINE_3_8",
|
||||||
"isVirtualModule": false,
|
"isVirtualModule": false,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"cocos/spine/lib/spine-version.ts": "cocos/spine/lib/spine-version-4.2.ts",
|
"cocos/spine/lib/spine-version.ts": "cocos/spine/lib/spine-version-4.2.ts",
|
||||||
@@ -877,10 +885,10 @@
|
|||||||
"cocos/asset/asset-manager/weak-cache.ts",
|
"cocos/asset/asset-manager/weak-cache.ts",
|
||||||
"cocos/2d/framework/ui-skew-utils.ts",
|
"cocos/2d/framework/ui-skew-utils.ts",
|
||||||
"cocos/spine/lib/spine-binary.ts",
|
"cocos/spine/lib/spine-binary.ts",
|
||||||
"pal/input/minigame/gamepad-input.ts",
|
"pal/input/minigame/gamepad-input.js",
|
||||||
"pal/input/minigame/handheld-input.ts",
|
"pal/input/minigame/handheld-input.js",
|
||||||
"pal/input/minigame/handle-input.ts",
|
"pal/input/minigame/handle-input.js",
|
||||||
"pal/input/minigame/hmd-input.ts"
|
"pal/input/minigame/hmd-input.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,6 +266,15 @@ export class Graphics extends UIRenderer {
|
|||||||
this._updateMtlForGraphics();
|
this._updateMtlForGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override get _keepRenderData (): boolean {
|
||||||
|
// Graphics is a retained-mode renderer: its MeshRenderData is the result of the
|
||||||
|
// user's previous fill()/stroke() calls. Destroying it here would leave Impl's
|
||||||
|
// render-data list pointing at cleared geometry, so re-enabling the node on native
|
||||||
|
// platforms would require the user to draw the paths again. Keep it attached to the
|
||||||
|
// disabled RenderEntity; clear() and onDestroy() remain the owning release points.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public onDestroy (): void {
|
public onDestroy (): void {
|
||||||
this._sceneGetter = null;
|
this._sceneGetter = null;
|
||||||
if (JSB) {
|
if (JSB) {
|
||||||
@@ -637,13 +646,13 @@ export class Graphics extends UIRenderer {
|
|||||||
const vertexBuffer = gfxDevice.createBuffer(new BufferInfo(
|
const vertexBuffer = gfxDevice.createBuffer(new BufferInfo(
|
||||||
BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST,
|
BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST,
|
||||||
MemoryUsageBit.DEVICE,
|
MemoryUsageBit.DEVICE,
|
||||||
65535 * stride,
|
65536 * stride, // Uint16 can address 65536 vertices (indices 0–65535)
|
||||||
stride,
|
stride,
|
||||||
));
|
));
|
||||||
const indexBuffer = gfxDevice.createBuffer(new BufferInfo(
|
const indexBuffer = gfxDevice.createBuffer(new BufferInfo(
|
||||||
BufferUsageBit.INDEX | BufferUsageBit.TRANSFER_DST,
|
BufferUsageBit.INDEX | BufferUsageBit.TRANSFER_DST,
|
||||||
MemoryUsageBit.DEVICE,
|
MemoryUsageBit.DEVICE,
|
||||||
65535 * Uint16Array.BYTES_PER_ELEMENT * 2,
|
65536 * Uint16Array.BYTES_PER_ELEMENT * 2, // Uint16 can address 65536 vertices (indices 0–65535)
|
||||||
Uint16Array.BYTES_PER_ELEMENT,
|
Uint16Array.BYTES_PER_ELEMENT,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -64,10 +64,10 @@ function _calculateCircle (center: Vec3, radius: Vec3, segments: number): Vec3[]
|
|||||||
*/
|
*/
|
||||||
export enum MaskType {
|
export enum MaskType {
|
||||||
/**
|
/**
|
||||||
* @en Rect mask.
|
* @en Rect mask, supports rounded corners by setting radius.
|
||||||
*
|
*
|
||||||
* @zh
|
* @zh
|
||||||
* 使用矩形作为遮罩。
|
* 使用矩形作为遮罩,可通过 radius 设置圆角。
|
||||||
*/
|
*/
|
||||||
GRAPHICS_RECT = 0,
|
GRAPHICS_RECT = 0,
|
||||||
|
|
||||||
@@ -215,6 +215,32 @@ export class Mask extends Component {
|
|||||||
this._updateGraphics();
|
this._updateGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @en
|
||||||
|
* The radius for rounded corners of rect mask.
|
||||||
|
*
|
||||||
|
* @zh
|
||||||
|
* 矩形遮罩的圆角半径。
|
||||||
|
*/
|
||||||
|
@visible(function (this: Mask) {
|
||||||
|
return this.type === MaskType.GRAPHICS_RECT;
|
||||||
|
})
|
||||||
|
@tooltip('i18n:mask.radius')
|
||||||
|
@range([0, Number.POSITIVE_INFINITY])
|
||||||
|
get radius (): number {
|
||||||
|
return this._radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
set radius (value) {
|
||||||
|
const radius = clamp(value, 0, Number.POSITIVE_INFINITY);
|
||||||
|
if (this._radius === radius) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._radius = radius;
|
||||||
|
this._updateGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @en
|
* @en
|
||||||
* The mask image.
|
* The mask image.
|
||||||
@@ -289,6 +315,9 @@ export class Mask extends Component {
|
|||||||
@serializable
|
@serializable
|
||||||
protected _segments = 64;
|
protected _segments = 64;
|
||||||
|
|
||||||
|
@serializable
|
||||||
|
protected _radius = 0;
|
||||||
|
|
||||||
@serializable
|
@serializable
|
||||||
protected _alphaThreshold = 0.1;
|
protected _alphaThreshold = 0.1;
|
||||||
|
|
||||||
@@ -350,7 +379,25 @@ export class Mask extends Component {
|
|||||||
testPt.y += ap.y * h;
|
testPt.y += ap.y * h;
|
||||||
|
|
||||||
let result = false;
|
let result = false;
|
||||||
if (this.type === MaskType.GRAPHICS_RECT || this.type === MaskType.GRAPHICS_STENCIL || this.type === MaskType.SPRITE_STENCIL) {
|
if (this.type === MaskType.GRAPHICS_RECT) {
|
||||||
|
result = testPt.x >= 0 && testPt.y >= 0 && testPt.x <= w && testPt.y <= h;
|
||||||
|
const radius = Math.min(this._radius, w / 2, h / 2);
|
||||||
|
if (result && radius > 0) {
|
||||||
|
let dx = 0;
|
||||||
|
let dy = 0;
|
||||||
|
if (testPt.x < radius) {
|
||||||
|
dx = testPt.x - radius;
|
||||||
|
} else if (testPt.x > w - radius) {
|
||||||
|
dx = testPt.x - (w - radius);
|
||||||
|
}
|
||||||
|
if (testPt.y < radius) {
|
||||||
|
dy = testPt.y - radius;
|
||||||
|
} else if (testPt.y > h - radius) {
|
||||||
|
dy = testPt.y - (h - radius);
|
||||||
|
}
|
||||||
|
result = dx * dx + dy * dy <= radius * radius;
|
||||||
|
}
|
||||||
|
} else if (this.type === MaskType.GRAPHICS_STENCIL || this.type === MaskType.SPRITE_STENCIL) {
|
||||||
result = testPt.x >= 0 && testPt.y >= 0 && testPt.x <= w && testPt.y <= h;
|
result = testPt.x >= 0 && testPt.y >= 0 && testPt.x <= w && testPt.y <= h;
|
||||||
} else if (this.type === MaskType.GRAPHICS_ELLIPSE) {
|
} else if (this.type === MaskType.GRAPHICS_ELLIPSE) {
|
||||||
const rx = w / 2;
|
const rx = w / 2;
|
||||||
@@ -423,7 +470,12 @@ export class Mask extends Component {
|
|||||||
const x = -width * ap.x;
|
const x = -width * ap.x;
|
||||||
const y = -height * ap.y;
|
const y = -height * ap.y;
|
||||||
if (this._type === MaskType.GRAPHICS_RECT) {
|
if (this._type === MaskType.GRAPHICS_RECT) {
|
||||||
graphics.rect(x, y, width, height);
|
const radius = Math.min(this._radius, width / 2, height / 2);
|
||||||
|
if (radius > 0) {
|
||||||
|
graphics.roundRect(x, y, width, height, radius);
|
||||||
|
} else {
|
||||||
|
graphics.rect(x, y, width, height);
|
||||||
|
}
|
||||||
} else if (this._type === MaskType.GRAPHICS_ELLIPSE) {
|
} else if (this._type === MaskType.GRAPHICS_ELLIPSE) {
|
||||||
const center = new Vec3(x + width / 2, y + height / 2, 0);
|
const center = new Vec3(x + width / 2, y + height / 2, 0);
|
||||||
const radius = new Vec3(width / 2, height / 2, 0);
|
const radius = new Vec3(width / 2, height / 2, 0);
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ export class Sprite extends UIRenderer {
|
|||||||
if (this.spriteFrame && this.spriteFrame.texture instanceof RenderTexture) {
|
if (this.spriteFrame && this.spriteFrame.texture instanceof RenderTexture) {
|
||||||
const rtMatName = `rt-${mat.name}`;
|
const rtMatName = `rt-${mat.name}`;
|
||||||
let rtMat = builtinResMgr.get(rtMatName) as Material | null;
|
let rtMat = builtinResMgr.get(rtMatName) as Material | null;
|
||||||
if (!rtMat) {
|
if (!rtMat || !rtMat.passes.length) {
|
||||||
rtMat = new Material(rtMatName);
|
rtMat = new Material(rtMatName);
|
||||||
rtMat.copy(mat, { defines: { SAMPLE_FROM_RT: true } });
|
rtMat.copy(mat, { defines: { SAMPLE_FROM_RT: true } });
|
||||||
builtinResMgr.addAsset(rtMatName, rtMat);
|
builtinResMgr.addAsset(rtMatName, rtMat);
|
||||||
|
|||||||
@@ -398,12 +398,23 @@ export class UIRenderer extends Renderer {
|
|||||||
this.node.off(NodeEventType.ANCHOR_CHANGED, this._nodeStateChange, this);
|
this.node.off(NodeEventType.ANCHOR_CHANGED, this._nodeStateChange, this);
|
||||||
this.node.off(NodeEventType.SIZE_CHANGED, this._nodeStateChange, this);
|
this.node.off(NodeEventType.SIZE_CHANGED, this._nodeStateChange, this);
|
||||||
this.node.off(NodeEventType.PARENT_CHANGED, this._colorDirty, this);
|
this.node.off(NodeEventType.PARENT_CHANGED, this._colorDirty, this);
|
||||||
this.destroyRenderData();
|
if (!this._keepRenderData) {
|
||||||
|
this.destroyRenderData();
|
||||||
|
}
|
||||||
uiRendererManager.removeRenderer(this);
|
uiRendererManager.removeRenderer(this);
|
||||||
this._renderFlag = false;
|
this._renderFlag = false;
|
||||||
this._renderEntity.enabled = false;
|
this._renderEntity.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to keep render data when the component leaves the active hierarchy.
|
||||||
|
* Retained-mode renderers may override this policy and keep their render data until
|
||||||
|
* the content is explicitly cleared or the component is destroyed.
|
||||||
|
*/
|
||||||
|
protected get _keepRenderData (): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public onDestroy (): void {
|
public onDestroy (): void {
|
||||||
this._renderEntity.setNode(null);
|
this._renderEntity.setNode(null);
|
||||||
if (this.node._uiProps.uiComp === this) {
|
if (this.node._uiProps.uiComp === this) {
|
||||||
@@ -536,7 +547,7 @@ export class UIRenderer extends Renderer {
|
|||||||
const mat = this._updateBuiltinMaterial();
|
const mat = this._updateBuiltinMaterial();
|
||||||
this.setSharedMaterial(mat, 0);
|
this.setSharedMaterial(mat, 0);
|
||||||
if (this.stencilStage === Stage.ENTER_LEVEL || this.stencilStage === Stage.ENTER_LEVEL_INVERTED) {
|
if (this.stencilStage === Stage.ENTER_LEVEL || this.stencilStage === Stage.ENTER_LEVEL_INVERTED) {
|
||||||
this.getMaterialInstance(0)!.recompileShaders({ USE_ALPHA_TEST: true });
|
this.getMaterialInstance(0)?.recompileShaders({ USE_ALPHA_TEST: true });
|
||||||
}
|
}
|
||||||
this._updateBlendFunc();
|
this._updateBlendFunc();
|
||||||
}
|
}
|
||||||
@@ -600,16 +611,24 @@ export class UIRenderer extends Renderer {
|
|||||||
*/
|
*/
|
||||||
public _updateBlendFunc (): void {
|
public _updateBlendFunc (): void {
|
||||||
// todo: Not only Pass[0].target[0]
|
// todo: Not only Pass[0].target[0]
|
||||||
let target = this.getRenderMaterial(0)!.passes[0].blendState.targets[0];
|
const renderMat = this.getRenderMaterial(0);
|
||||||
|
if (!renderMat || !renderMat.passes[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let target = renderMat.passes[0].blendState.targets[0];
|
||||||
this._dstBlendFactorCache = target.blendDst;
|
this._dstBlendFactorCache = target.blendDst;
|
||||||
this._srcBlendFactorCache = target.blendSrc;
|
this._srcBlendFactorCache = target.blendSrc;
|
||||||
if (this._dstBlendFactorCache !== this._dstBlendFactor || this._srcBlendFactorCache !== this._srcBlendFactor) {
|
if (this._dstBlendFactorCache !== this._dstBlendFactor || this._srcBlendFactorCache !== this._srcBlendFactor) {
|
||||||
target = this.getMaterialInstance(0)!.passes[0].blendState.targets[0];
|
const matInstance = this.getMaterialInstance(0);
|
||||||
|
if (!matInstance || !matInstance.passes[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
target = matInstance.passes[0].blendState.targets[0];
|
||||||
target.blend = true;
|
target.blend = true;
|
||||||
target.blendDstAlpha = BlendFactor.ONE_MINUS_SRC_ALPHA;
|
target.blendDstAlpha = BlendFactor.ONE_MINUS_SRC_ALPHA;
|
||||||
target.blendDst = this._dstBlendFactor;
|
target.blendDst = this._dstBlendFactor;
|
||||||
target.blendSrc = this._srcBlendFactor;
|
target.blendSrc = this._srcBlendFactor;
|
||||||
const targetPass = this.getMaterialInstance(0)!.passes[0];
|
const targetPass = matInstance.passes[0];
|
||||||
targetPass.blendState.setTarget(0, target);
|
targetPass.blendState.setTarget(0, target);
|
||||||
targetPass._updatePassHash();
|
targetPass._updatePassHash();
|
||||||
this._dstBlendFactorCache = this._dstBlendFactor;
|
this._dstBlendFactorCache = this._dstBlendFactor;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { JSB } from 'internal:constants';
|
import { JSB } from 'internal:constants';
|
||||||
import { Device, BufferUsageBit, MemoryUsageBit, Attribute, Buffer, BufferInfo, InputAssembler, InputAssemblerInfo, Feature, API } from '../../gfx';
|
import { Device, BufferUsageBit, MemoryUsageBit, Attribute, Buffer, BufferInfo, InputAssembler, InputAssemblerInfo, Feature } from '../../gfx';
|
||||||
import { getAttributeStride } from './vertex-format';
|
import { getAttributeStride } from './vertex-format';
|
||||||
import { sys, getError, warnID, assertIsTrue } from '../../core';
|
import { sys, getError, warnID, assertIsTrue } from '../../core';
|
||||||
import { NativeUIMeshBuffer } from './native-2d';
|
import { NativeUIMeshBuffer } from './native-2d';
|
||||||
@@ -251,11 +251,10 @@ export class MeshBuffer {
|
|||||||
|
|
||||||
this.floatsPerVertex = getAttributeStride(attrs) >> 2;
|
this.floatsPerVertex = getAttributeStride(attrs) >> 2;
|
||||||
|
|
||||||
var vDataCountLimit = 65536; // 2^16 - 1
|
// Use the GPU's actual reported capability to determine max addressable vertex count.
|
||||||
const glApi = device.gfxAPI;
|
// Feature.ELEMENT_INDEX_UINT is set to true in: WebGL2, WebGPU, Vulkan, Metal, GLES3, GLES2+ext.
|
||||||
if (glApi === API.WEBGPU || glApi === API.WEBGL2 || glApi === API.WEBGL && device.hasFeature(Feature.ELEMENT_INDEX_UINT)) {
|
// vDataCountLimit is a vertex COUNT limit (max index value + 1), not the max index value itself.
|
||||||
vDataCountLimit = 4294967295; // 2^32 - 1
|
const vDataCountLimit = device.hasFeature(Feature.ELEMENT_INDEX_UINT) ? 4294967296 : 65536; // Uint32 or Uint16 can address 2^32 or 2^16 vertices (indices 0–2^32-1 or 0–2^16-1)
|
||||||
}
|
|
||||||
assertIsTrue(this._initVDataCount / this._floatsPerVertex < vDataCountLimit, getError(9005));
|
assertIsTrue(this._initVDataCount / this._floatsPerVertex < vDataCountLimit, getError(9005));
|
||||||
|
|
||||||
if (!this.vData || !this.iData) {
|
if (!this.vData || !this.iData) {
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ export class MeshRenderData extends BaseRenderData {
|
|||||||
const newVBytes = this._byteLength + vertexCount * this.stride;
|
const newVBytes = this._byteLength + vertexCount * this.stride;
|
||||||
const newICount = this.indexCount + indexCount;
|
const newICount = this.indexCount + indexCount;
|
||||||
|
|
||||||
if (vertexCount + this.vertexCount > 65535) {
|
if (vertexCount + this.vertexCount > 65536) { // Uint16 can address 65536 vertices (indices 0–65535)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,13 +697,13 @@ export class MeshRenderData extends BaseRenderData {
|
|||||||
if (this._byteLength > vertexBuffer.size) {
|
if (this._byteLength > vertexBuffer.size) {
|
||||||
vertexBuffer.resize(this._byteLength);
|
vertexBuffer.resize(this._byteLength);
|
||||||
}
|
}
|
||||||
vertexBuffer.update(verticesData);
|
vertexBuffer.update(verticesData.buffer as ArrayBuffer, this._byteLength);
|
||||||
|
|
||||||
const indexBytes = indexCount << 1;
|
const indexBytes = indexCount << 1;
|
||||||
if (indexBytes > this._indexBuffer.size) {
|
if (indexBytes > this._indexBuffer.size) {
|
||||||
this._indexBuffer.resize(indexBytes);
|
this._indexBuffer.resize(indexBytes);
|
||||||
}
|
}
|
||||||
this._indexBuffer.update(indicesData);
|
this._indexBuffer.update(indicesData.buffer as ArrayBuffer, indexBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public freeIAPool (): void {
|
public freeIAPool (): void {
|
||||||
|
|||||||
@@ -165,6 +165,10 @@ export class StaticVBAccessor extends BufferAccessor {
|
|||||||
errorID(9004, byteLength);
|
errorID(9004, byteLength);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (vertexCount > 65536) { // Vertex count must less than 65536 for index is uint16 (0 to 65535)
|
||||||
|
errorID(9004, byteLength);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let buf: MeshBuffer = null!;
|
let buf: MeshBuffer = null!;
|
||||||
let freeList: IFreeEntry[];
|
let freeList: IFreeEntry[];
|
||||||
let bid = 0;
|
let bid = 0;
|
||||||
@@ -176,9 +180,11 @@ export class StaticVBAccessor extends BufferAccessor {
|
|||||||
freeList = this._freeLists[i];
|
freeList = this._freeLists[i];
|
||||||
// Loop entries
|
// Loop entries
|
||||||
for (let e = 0; e < freeList.length; ++e) {
|
for (let e = 0; e < freeList.length; ++e) {
|
||||||
|
const freeEntry = freeList[e];
|
||||||
|
const vertexOffset: number = freeEntry.offset / this.vertexFormatBytes;
|
||||||
// Found suitable free entry
|
// Found suitable free entry
|
||||||
if (freeList[e].length >= byteLength) {
|
if (freeEntry.length >= byteLength && vertexOffset + (vertexCount - 1) <= 65535) {
|
||||||
entry = freeList[e];
|
entry = freeEntry;
|
||||||
bid = i;
|
bid = i;
|
||||||
eid = e;
|
eid = e;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ export class Mesh extends Asset {
|
|||||||
let dstSize = idxView.length;
|
let dstSize = idxView.length;
|
||||||
if (dstStride === 4 && !gfxDevice.hasFeature(Feature.ELEMENT_INDEX_UINT)) {
|
if (dstStride === 4 && !gfxDevice.hasFeature(Feature.ELEMENT_INDEX_UINT)) {
|
||||||
const vertexCount = this._struct.vertexBundles[prim.vertexBundelIndices[0]].view.count;
|
const vertexCount = this._struct.vertexBundles[prim.vertexBundelIndices[0]].view.count;
|
||||||
if (vertexCount >= 65536) {
|
if (vertexCount > 65536) { // Uint16 can address 65536 vertices (indices 0–65535)
|
||||||
warnID(10001, vertexCount, 65536);
|
warnID(10001, vertexCount, 65536);
|
||||||
continue; // Ignore this primitive
|
continue; // Ignore this primitive
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
import { CULL_MESHOPT, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
|
import { CULL_MESHOPT, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
|
||||||
import { ensureWasmModuleReady, instantiateWasm } from 'pal/wasm';
|
import { ensureWasmModuleReady, instantiateWasm } from 'pal/wasm';
|
||||||
|
|
||||||
import { sys, logID, error } from '../../core';
|
import { sys, error, debugID } from '../../core';
|
||||||
|
|
||||||
import { game } from '../../game';
|
import { game } from '../../game';
|
||||||
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
|
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
|
||||||
@@ -53,7 +53,7 @@ function initDecoderASM (asm_factory: any): Promise<void> {
|
|||||||
MeshoptDecoder.decodeGltfBuffer = asm_factory.decodeGltfBuffer;
|
MeshoptDecoder.decodeGltfBuffer = asm_factory.decodeGltfBuffer;
|
||||||
MeshoptDecoder.useWorkers = asm_factory.useWorkers;
|
MeshoptDecoder.useWorkers = asm_factory.useWorkers;
|
||||||
MeshoptDecoder.decodeGltfBufferAsync = asm_factory.decodeGltfBufferAsync;
|
MeshoptDecoder.decodeGltfBufferAsync = asm_factory.decodeGltfBufferAsync;
|
||||||
logID(14202);
|
debugID(14202);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ function initDecoderWASM (wasm_factory: any, wasm_url: string): Promise<void> {
|
|||||||
MeshoptDecoder.decodeGltfBuffer = wasm_factory.decodeGltfBuffer;
|
MeshoptDecoder.decodeGltfBuffer = wasm_factory.decodeGltfBuffer;
|
||||||
MeshoptDecoder.useWorkers = wasm_factory.useWorkers;
|
MeshoptDecoder.useWorkers = wasm_factory.useWorkers;
|
||||||
MeshoptDecoder.decodeGltfBufferAsync = wasm_factory.decodeGltfBufferAsync;
|
MeshoptDecoder.decodeGltfBufferAsync = wasm_factory.decodeGltfBufferAsync;
|
||||||
logID(14203);
|
debugID(14203);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -384,10 +384,10 @@ export class ReflectionProbe extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.probeType === ProbeType.PLANAR && this.sourceCamera) {
|
if (!EDITOR_NOT_IN_PREVIEW && this.probeType === ProbeType.PLANAR && this.sourceCamera) {
|
||||||
if ((this.sourceCamera.node.hasChangedFlags & TransformBit.TRS)
|
if ((this.sourceCamera.node.hasChangedFlags & TransformBit.TRS)
|
||||||
|| !this._sourceCameraPos.equals(this.sourceCamera.node.getWorldPosition())) {
|
|| !this._sourceCameraPos.equals(this.sourceCamera.node.getWorldPosition())) {
|
||||||
this._sourceCameraPos = this.sourceCamera.node.getWorldPosition();
|
this._sourceCameraPos.set(this.sourceCamera.node.getWorldPosition());
|
||||||
this.probe.renderPlanarReflection(this.sourceCamera.camera);
|
this.probe.renderPlanarReflection(this.sourceCamera.camera);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,8 @@ class ClipMotionEval implements MotionEval {
|
|||||||
|
|
||||||
public overrideClips (context: AnimationGraphBindingContext): void {
|
public overrideClips (context: AnimationGraphBindingContext): void {
|
||||||
const { _originalClip: originalClip } = this;
|
const { _originalClip: originalClip } = this;
|
||||||
const overriding = context.clipOverrides?.get(originalClip);
|
const clipOverrides: any = context.clipOverrides;
|
||||||
|
const overriding: AnimationClip | null = clipOverrides && clipOverrides.get ? clipOverrides.get(originalClip) : null;
|
||||||
if (overriding) {
|
if (overriding) {
|
||||||
this._setClip(overriding, context);
|
this._setClip(overriding, context);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,10 +76,11 @@ simpleTextureProto._onGFXTextureUpdated = function (gfxTexture) {
|
|||||||
simpleTextureProto._onAfterAssignImage = function (image) {
|
simpleTextureProto._onAfterAssignImage = function (image) {
|
||||||
if (macro.CLEANUP_IMAGE_CACHE) {
|
if (macro.CLEANUP_IMAGE_CACHE) {
|
||||||
const deps = dependUtil.getDeps(this._uuid);
|
const deps = dependUtil.getDeps(this._uuid);
|
||||||
const index = deps.indexOf(image._uuid);
|
let index = deps.indexOf(image._uuid);
|
||||||
if (index !== -1) {
|
while (index !== -1) {
|
||||||
js.array.fastRemoveAt(deps, index);
|
js.array.fastRemoveAt(deps, index);
|
||||||
image.decRef();
|
image.decRef();
|
||||||
|
index = deps.indexOf(image._uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -194,10 +194,12 @@ export class SimpleTexture extends TextureBase {
|
|||||||
|
|
||||||
if (macro.CLEANUP_IMAGE_CACHE) {
|
if (macro.CLEANUP_IMAGE_CACHE) {
|
||||||
const deps = dependUtil.getDeps(this._uuid);
|
const deps = dependUtil.getDeps(this._uuid);
|
||||||
const index = deps.indexOf(image._uuid);
|
let index = deps.indexOf(image._uuid);
|
||||||
if (index !== -1) {
|
while (index !== -1) {
|
||||||
js.array.fastRemoveAt(deps, index);
|
js.array.fastRemoveAt(deps, index);
|
||||||
image.decRef();
|
image.decRef();
|
||||||
|
// The same UUID may occur more than once; find the next dependency edge.
|
||||||
|
index = deps.indexOf(image._uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,8 +195,9 @@ function define (className, baseClass, options): any {
|
|||||||
renderName = 'render_stage';
|
renderName = 'render_stage';
|
||||||
}
|
}
|
||||||
// 增加了 hidden: 开头标识,使它最终不会显示在 Editor inspector 的添加组件列表里
|
// 增加了 hidden: 开头标识,使它最终不会显示在 Editor inspector 的添加组件列表里
|
||||||
|
if (window.EditorExtends) {
|
||||||
window.EditorExtends && window.EditorExtends.Component.addMenu(cls, `hidden:${renderName}/${className}`, -1);
|
window.EditorExtends.Component.addMenu(cls, `hidden:${renderName}/${className}`, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: `options.ctor` should be the same as `cls` except if
|
// Note: `options.ctor` should be the same as `cls` except if
|
||||||
|
|||||||
@@ -69,6 +69,58 @@ export function approx (a: number, b: number, maxDiff?: number): boolean {
|
|||||||
return mathAbs(a - b) <= maxDiff;
|
return mathAbs(a - b) <= maxDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @en Tests whether or not the first argument is approximately greater than or equal to the second
|
||||||
|
* @zh 测试第一个参数是否近似大于或等于第二个参数
|
||||||
|
* @param a The first number to test
|
||||||
|
* @param b The second number to test
|
||||||
|
* @param maxDiff Maximum difference (default: EPSILON)
|
||||||
|
* @return True if a is approximately greater than or equal to b, false otherwise
|
||||||
|
*/
|
||||||
|
export function approxGE (a: number, b: number, maxDiff?: number): boolean {
|
||||||
|
maxDiff = maxDiff || EPSILON;
|
||||||
|
return a >= b - maxDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @en Tests whether or not the first argument is approximately less than or equal to the second
|
||||||
|
* @zh 测试第一个参数是否近似小于或等于第二个参数
|
||||||
|
* @param a The first number to test
|
||||||
|
* @param b The second number to test
|
||||||
|
* @param maxDiff Maximum difference (default: EPSILON)
|
||||||
|
* @return True if a is approximately less than or equal to b, false otherwise
|
||||||
|
*/
|
||||||
|
export function approxLE (a: number, b: number, maxDiff?: number): boolean {
|
||||||
|
maxDiff = maxDiff || EPSILON;
|
||||||
|
return a <= b + maxDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @en Tests whether or not the first argument is approximately greater than the second
|
||||||
|
* @zh 测试第一个参数是否近似大于第二个参数
|
||||||
|
* @param a The first number to test
|
||||||
|
* @param b The second number to test
|
||||||
|
* @param maxDiff Maximum difference (default: EPSILON)
|
||||||
|
* @return True if a is approximately greater than b, false otherwise
|
||||||
|
*/
|
||||||
|
export function approxGT (a: number, b: number, maxDiff?: number): boolean {
|
||||||
|
maxDiff = maxDiff || EPSILON;
|
||||||
|
return a > b + maxDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @en Tests whether or not the first argument is approximately less than the second
|
||||||
|
* @zh 测试第一个参数是否近似小于第二个参数
|
||||||
|
* @param a The first number to test
|
||||||
|
* @param b The second number to test
|
||||||
|
* @param maxDiff Maximum difference (default: EPSILON)
|
||||||
|
* @return True if a is approximately less than b, false otherwise
|
||||||
|
*/
|
||||||
|
export function approxLT (a: number, b: number, maxDiff?: number): boolean {
|
||||||
|
maxDiff = maxDiff || EPSILON;
|
||||||
|
return a < b - maxDiff;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @en Clamps a value between a minimum float and maximum float value.<br/>
|
* @en Clamps a value between a minimum float and maximum float value.<br/>
|
||||||
* @zh 返回最小浮点数和最大浮点数之间的一个数值。可以使用 clamp 函数将不断变化的数值限制在范围内。
|
* @zh 返回最小浮点数和最大浮点数之间的一个数值。可以使用 clamp 函数将不断变化的数值限制在范围内。
|
||||||
|
|||||||
@@ -2702,7 +2702,7 @@ export function WebGLCmdFuncCopyBuffersToTexture (
|
|||||||
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
||||||
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
||||||
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
||||||
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentWidth
|
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentHeight
|
||||||
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
||||||
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
||||||
stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height;
|
stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height;
|
||||||
@@ -2773,7 +2773,7 @@ export function WebGLCmdFuncCopyBuffersToTexture (
|
|||||||
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
||||||
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
||||||
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
||||||
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentWidth
|
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentHeight
|
||||||
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
||||||
stride.width = region.buffStride > 0 ? region.buffStride : extent.width;
|
stride.width = region.buffStride > 0 ? region.buffStride : extent.width;
|
||||||
stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height;
|
stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height;
|
||||||
|
|||||||
@@ -2811,7 +2811,7 @@ export function WebGL2CmdFuncCopyBuffersToTexture (
|
|||||||
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
||||||
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
||||||
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
||||||
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentWidth
|
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentHeight
|
||||||
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
||||||
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
||||||
stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height;
|
stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height;
|
||||||
@@ -2883,7 +2883,7 @@ export function WebGL2CmdFuncCopyBuffersToTexture (
|
|||||||
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
||||||
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
||||||
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
||||||
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentWidth
|
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentHeight
|
||||||
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
||||||
extent.depth = 1;
|
extent.depth = 1;
|
||||||
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
||||||
@@ -2965,7 +2965,7 @@ export function WebGL2CmdFuncCopyBuffersToTexture (
|
|||||||
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
||||||
offset.z = regionTexOffset.z;
|
offset.z = regionTexOffset.z;
|
||||||
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
||||||
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentWidth
|
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentHeight
|
||||||
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
||||||
extent.depth = regionTexExtent.depth;
|
extent.depth = regionTexExtent.depth;
|
||||||
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
||||||
@@ -3043,7 +3043,7 @@ export function WebGL2CmdFuncCopyBuffersToTexture (
|
|||||||
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
offset.x = regionTexOffset.x === 0 ? 0 : alignTo(regionTexOffset.x, blockSizeWidth);
|
||||||
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
offset.y = regionTexOffset.y === 0 ? 0 : alignTo(regionTexOffset.y, blockSizeHeight);
|
||||||
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
extent.width = regionTexExtentWidth < blockSizeWidth ? regionTexExtentWidth : alignTo(regionTexExtentWidth, blockSizeWidth);
|
||||||
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentWidth
|
extent.height = regionTexExtentHeight < blockSizeHeight ? regionTexExtentHeight
|
||||||
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
: alignTo(regionTexExtentHeight, blockSizeHeight);
|
||||||
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
stride.width = regionBuffStride > 0 ? regionBuffStride : extent.width;
|
||||||
stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height;
|
stride.height = region.buffTexHeight > 0 ? region.buffTexHeight : extent.height;
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ export class WebGL2Swapchain extends Swapchain {
|
|||||||
self._canvas = info.windowHandle;
|
self._canvas = info.windowHandle;
|
||||||
|
|
||||||
self._webGL2ContextLostHandler = self._onWebGLContextLost.bind(self);
|
self._webGL2ContextLostHandler = self._onWebGLContextLost.bind(self);
|
||||||
self._canvas.addEventListener(eventWebGLContextLost, self._onWebGLContextLost);
|
self._canvas.addEventListener(eventWebGLContextLost, self._webGL2ContextLostHandler);
|
||||||
|
|
||||||
const { instance } = WebGL2DeviceManager;
|
const { instance } = WebGL2DeviceManager;
|
||||||
const { gl, capabilities } = instance;
|
const { gl, capabilities } = instance;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class Particle {
|
|||||||
public pos = new Vec2(0, 0);
|
public pos = new Vec2(0, 0);
|
||||||
public startPos = new Vec2(0, 0);
|
public startPos = new Vec2(0, 0);
|
||||||
public color = new Color(0, 0, 0, 255);
|
public color = new Color(0, 0, 0, 255);
|
||||||
|
public curColor = { r: 0, g: 0, b: 0, a: 255 };
|
||||||
public deltaColor = { r: 0, g: 0, b: 0, a: 255 };
|
public deltaColor = { r: 0, g: 0, b: 0, a: 255 };
|
||||||
public size = 0;
|
public size = 0;
|
||||||
public deltaSize = 0;
|
public deltaSize = 0;
|
||||||
@@ -81,6 +82,8 @@ const pool = new ParticlePool((par: Particle): void => {
|
|||||||
par.pos.set(Vec2.ZERO);
|
par.pos.set(Vec2.ZERO);
|
||||||
par.startPos.set(Vec2.ZERO);
|
par.startPos.set(Vec2.ZERO);
|
||||||
par.color.set(0, 0, 0, 255);
|
par.color.set(0, 0, 0, 255);
|
||||||
|
par.curColor.r = par.curColor.g = par.curColor.b = 0;
|
||||||
|
par.curColor.a = 255;
|
||||||
par.deltaColor.r = par.deltaColor.g = par.deltaColor.b = 0;
|
par.deltaColor.r = par.deltaColor.g = par.deltaColor.b = 0;
|
||||||
par.deltaColor.a = 255;
|
par.deltaColor.a = 255;
|
||||||
par.size = 0;
|
par.size = 0;
|
||||||
@@ -111,6 +114,7 @@ export class Simulator {
|
|||||||
private elapsed = 0;
|
private elapsed = 0;
|
||||||
private emitCounter = 0;
|
private emitCounter = 0;
|
||||||
private _worldRotation = 0;
|
private _worldRotation = 0;
|
||||||
|
private _parentAlpha = 0.0;
|
||||||
private declare sys: ParticleSystem2D;
|
private declare sys: ParticleSystem2D;
|
||||||
|
|
||||||
constructor (system) {
|
constructor (system) {
|
||||||
@@ -169,10 +173,10 @@ export class Simulator {
|
|||||||
const endColor = psys.endColor;
|
const endColor = psys.endColor;
|
||||||
const endColorVar = psys.endColorVar;
|
const endColorVar = psys.endColorVar;
|
||||||
|
|
||||||
particle.color.r = sr = clamp(startColor.r + startColorVar.r * (random() - 0.5) * 2, 0, 255);
|
particle.curColor.r = sr = clamp(startColor.r + startColorVar.r * (random() - 0.5) * 2, 0, 255);
|
||||||
particle.color.g = sg = clamp(startColor.g + startColorVar.g * (random() - 0.5) * 2, 0, 255);
|
particle.curColor.g = sg = clamp(startColor.g + startColorVar.g * (random() - 0.5) * 2, 0, 255);
|
||||||
particle.color.b = sb = clamp(startColor.b + startColorVar.b * (random() - 0.5) * 2, 0, 255);
|
particle.curColor.b = sb = clamp(startColor.b + startColorVar.b * (random() - 0.5) * 2, 0, 255);
|
||||||
particle.color.a = sa = clamp(startColor.a + startColorVar.a * (random() - 0.5) * 2, 0, 255);
|
particle.curColor.a = sa = clamp(startColor.a + startColorVar.a * (random() - 0.5) * 2, 0, 255);
|
||||||
particle.deltaColor.r = (clamp(endColor.r + endColorVar.r * (random() - 0.5) * 2, 0, 255) - sr) / timeToLive;
|
particle.deltaColor.r = (clamp(endColor.r + endColorVar.r * (random() - 0.5) * 2, 0, 255) - sr) / timeToLive;
|
||||||
particle.deltaColor.g = (clamp(endColor.g + endColorVar.g * (random() - 0.5) * 2, 0, 255) - sg) / timeToLive;
|
particle.deltaColor.g = (clamp(endColor.g + endColorVar.g * (random() - 0.5) * 2, 0, 255) - sg) / timeToLive;
|
||||||
particle.deltaColor.b = (clamp(endColor.b + endColorVar.b * (random() - 0.5) * 2, 0, 255) - sb) / timeToLive;
|
particle.deltaColor.b = (clamp(endColor.b + endColorVar.b * (random() - 0.5) * 2, 0, 255) - sb) / timeToLive;
|
||||||
@@ -329,6 +333,14 @@ export class Simulator {
|
|||||||
Vec4.toArray(vbuf, _col, offset + 32);
|
Vec4.toArray(vbuf, _col, offset + 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _updateColor (): void {
|
||||||
|
const selfNode = this.sys.node;
|
||||||
|
const parentNode = selfNode.parent;
|
||||||
|
const uiProps = selfNode._uiProps;
|
||||||
|
const parentOpacity = parentNode ? parentNode._uiProps.opacity : 1.0;
|
||||||
|
this._parentAlpha = uiProps.localOpacity * parentOpacity;
|
||||||
|
}
|
||||||
|
|
||||||
public step (dt: number): void {
|
public step (dt: number): void {
|
||||||
const assembler = this.sys.assembler as Particle2DAssembler;
|
const assembler = this.sys.assembler as Particle2DAssembler;
|
||||||
const psys = this.sys;
|
const psys = this.sys;
|
||||||
@@ -379,6 +391,8 @@ export class Simulator {
|
|||||||
this.updateUVs();
|
this.updateUVs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._updateColor();
|
||||||
|
|
||||||
// Used to reduce memory allocation / creation within the loop
|
// Used to reduce memory allocation / creation within the loop
|
||||||
let particleIdx = 0;
|
let particleIdx = 0;
|
||||||
while (particleIdx < particles.length) {
|
while (particleIdx < particles.length) {
|
||||||
@@ -431,10 +445,15 @@ export class Simulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// color
|
// color
|
||||||
particle.color.r += particle.deltaColor.r * dt;
|
particle.curColor.r += particle.deltaColor.r * dt;
|
||||||
particle.color.g += particle.deltaColor.g * dt;
|
particle.curColor.g += particle.deltaColor.g * dt;
|
||||||
particle.color.b += particle.deltaColor.b * dt;
|
particle.curColor.b += particle.deltaColor.b * dt;
|
||||||
particle.color.a += particle.deltaColor.a * dt;
|
particle.curColor.a += particle.deltaColor.a * dt;
|
||||||
|
|
||||||
|
particle.color.r = particle.curColor.r;
|
||||||
|
particle.color.g = particle.curColor.g;
|
||||||
|
particle.color.b = particle.curColor.b;
|
||||||
|
particle.color.a = particle.curColor.a * this._parentAlpha;
|
||||||
|
|
||||||
// size
|
// size
|
||||||
particle.size += particle.deltaSize * dt;
|
particle.size += particle.deltaSize * dt;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ccclass, type, serializable, editable, range } from 'cc.decorator';
|
import { ccclass, type, serializable, editable, range } from 'cc.decorator';
|
||||||
import { repeat } from '../core/math';
|
import { approxGE, approxLT, repeat } from '../core/math';
|
||||||
import CurveRange from './animator/curve-range';
|
import CurveRange from './animator/curve-range';
|
||||||
import type { ParticleSystem } from './particle-system';
|
import type { ParticleSystem } from './particle-system';
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ export default class Burst {
|
|||||||
let preFrameTime = repeat(psys.time - psys.startDelay.evaluate(0, 1), psys.duration) - dt;
|
let preFrameTime = repeat(psys.time - psys.startDelay.evaluate(0, 1), psys.duration) - dt;
|
||||||
preFrameTime = (preFrameTime > 0.0) ? preFrameTime : 0.0;
|
preFrameTime = (preFrameTime > 0.0) ? preFrameTime : 0.0;
|
||||||
const curFrameTime = repeat(psys.time - psys.startDelay.evaluate(0, 1), psys.duration);
|
const curFrameTime = repeat(psys.time - psys.startDelay.evaluate(0, 1), psys.duration);
|
||||||
if (this._curTime >= preFrameTime && this._curTime < curFrameTime) {
|
if (approxGE(this._curTime, preFrameTime) && approxLT(this._curTime, curFrameTime)) {
|
||||||
psys.emit(this.count.evaluate(this._curTime / psys.duration, 1), dt - (curFrameTime - this._curTime));
|
psys.emit(this.count.evaluate(this._curTime / psys.duration, 1), dt - (curFrameTime - this._curTime));
|
||||||
this._curTime += this.repeatInterval;
|
this._curTime += this.repeatInterval;
|
||||||
--this._remainingCount;
|
--this._remainingCount;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
import { ccclass, help, executeInEditMode, menu, tooltip, displayOrder, type, serializable,
|
import { ccclass, help, executeInEditMode, menu, tooltip, displayOrder, type, serializable,
|
||||||
range, visible, override, displayName } from 'cc.decorator';
|
range, visible, override, displayName } from 'cc.decorator';
|
||||||
import { Material, Texture2D } from '../asset/assets';
|
import { Material, Texture2D } from '../asset/assets';
|
||||||
import { Vec3, cclegacy, Vec4, Vec2, CCBoolean } from '../core';
|
import { Vec3, cclegacy, Vec4, Vec2, CCBoolean, Color } from '../core';
|
||||||
import { LineModel } from './models/line-model';
|
import { LineModel } from './models/line-model';
|
||||||
import { builtinResMgr } from '../asset/asset-manager';
|
import { builtinResMgr } from '../asset/asset-manager';
|
||||||
import CurveRange from './animator/curve-range';
|
import CurveRange from './animator/curve-range';
|
||||||
@@ -296,6 +296,15 @@ export class Line extends ModelRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public updateColor (): void {
|
||||||
|
if (this._color) {
|
||||||
|
if (this._models[0]) {
|
||||||
|
const lineModel = this._models[0] as LineModel;
|
||||||
|
lineModel.addLineVertexData(this._positions, this._width, this._color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected _onMaterialModified (index: number, material: Material | null): void {
|
protected _onMaterialModified (index: number, material: Material | null): void {
|
||||||
super._onMaterialModified(index, material);
|
super._onMaterialModified(index, material);
|
||||||
const matIns = this.getMaterialInstance(0);
|
const matIns = this.getMaterialInstance(0);
|
||||||
|
|||||||
@@ -233,8 +233,8 @@ export class ParticleSystem extends ModelRenderer {
|
|||||||
public startLifetime = new CurveRange();
|
public startLifetime = new CurveRange();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @en Particle system duration time.
|
* @en Particle system emitter duration time.
|
||||||
* @zh 粒子系统运行时间。
|
* @zh 粒子系统发射器运行时间。
|
||||||
*/
|
*/
|
||||||
@serializable
|
@serializable
|
||||||
@displayOrder(0)
|
@displayOrder(0)
|
||||||
|
|||||||
@@ -747,6 +747,12 @@ export default class ParticleSystemRendererCPU extends ParticleSystemRendererBas
|
|||||||
this._defines[ROTATION_OVER_TIME_MODULE_ENABLE] = enable;
|
this._defines[ROTATION_OVER_TIME_MODULE_ENABLE] = enable;
|
||||||
this._defines[INSTANCE_PARTICLE] = this._useInstance;
|
this._defines[INSTANCE_PARTICLE] = this._useInstance;
|
||||||
|
|
||||||
|
const matIns: MaterialInstance | null = ps.getMaterialInstance(0);
|
||||||
|
if (matIns === null || matIns === undefined) {
|
||||||
|
ps.setSharedMaterial(mat.parent, 0); // set material[0] as material for ui-mesh-renderer to use
|
||||||
|
ps.setMaterialInstance(mat, 0);
|
||||||
|
}
|
||||||
|
|
||||||
mat.recompileShaders(this._defines);
|
mat.recompileShaders(this._defines);
|
||||||
if (this._model) {
|
if (this._model) {
|
||||||
this._model.updateMaterial(mat);
|
this._model.updateMaterial(mat);
|
||||||
@@ -776,6 +782,13 @@ export default class ParticleSystemRendererCPU extends ParticleSystemRendererBas
|
|||||||
_matInsInfo.subModelIdx = 0;
|
_matInsInfo.subModelIdx = 0;
|
||||||
}
|
}
|
||||||
mat = mat || this._defaultTrailMat!;
|
mat = mat || this._defaultTrailMat!;
|
||||||
|
|
||||||
|
const matIns: MaterialInstance | null = ps.getMaterialInstance(1);
|
||||||
|
if (matIns === null || matIns === undefined) {
|
||||||
|
ps.setSharedMaterial(mat.parent, 1); // set material[1] as trail material for ui-mesh-renderer to use
|
||||||
|
ps.setMaterialInstance(mat, 1);
|
||||||
|
}
|
||||||
|
|
||||||
const texture = mat.getProperty('mainTexture', 0) as Texture2D | null;
|
const texture = mat.getProperty('mainTexture', 0) as Texture2D | null;
|
||||||
if (texture && texture.isAlphaAtlas) {
|
if (texture && texture.isAlphaAtlas) {
|
||||||
this._trailDefines[CC_USE_EMBEDDED_ALPHA] = true;
|
this._trailDefines[CC_USE_EMBEDDED_ALPHA] = true;
|
||||||
|
|||||||
@@ -377,7 +377,10 @@ export default class TrailModule {
|
|||||||
if (this.lifeTime.getMax() < 1.0) {
|
if (this.lifeTime.getMax() < 1.0) {
|
||||||
warnID(6036);
|
warnID(6036);
|
||||||
}
|
}
|
||||||
this._trailNum = Math.ceil(psTime * Math.ceil(this.lifeTime.getMax()) * 60 * (psRate * duration + burstCount));
|
let pCount: number = psRate * duration; // potential particle count
|
||||||
|
pCount = ps.prewarm ? pCount * 2 : pCount; // if prewarm we need double space
|
||||||
|
pCount = pCount > ps.capacity ? ps.capacity : pCount; // max particle count is less/equal than capacity
|
||||||
|
this._trailNum = Math.ceil(psTime * Math.ceil(this.lifeTime.getMax()) * 60 * (pCount + burstCount));
|
||||||
this._trailSegments = new Pool(
|
this._trailSegments = new Pool(
|
||||||
(): TrailSegment => new TrailSegment(10),
|
(): TrailSegment => new TrailSegment(10),
|
||||||
Math.ceil(psRate * duration),
|
Math.ceil(psRate * duration),
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export class b2PhysicsWorld implements IPhysicsWorld {
|
|||||||
|
|
||||||
if (!v) {
|
if (!v) {
|
||||||
if (this._debugGraphics) {
|
if (this._debugGraphics) {
|
||||||
this._debugGraphics.node.parent = null;
|
this._debugGraphics.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ export class b2CircleShape extends b2Shape2D implements ICircleShape {
|
|||||||
|
|
||||||
_worldPosition = new Vec2();
|
_worldPosition = new Vec2();
|
||||||
get worldPosition (): Vec2 {
|
get worldPosition (): Vec2 {
|
||||||
const p = (this._shapes[0] as b2jsb.CircleShape).m_p;
|
const comp = this.collider as CircleCollider2D;
|
||||||
return this._worldPosition.set(p.x * PHYSICS_2D_PTM_RATIO, p.y * PHYSICS_2D_PTM_RATIO);
|
return Vec2.transformMat4(this._worldPosition, comp.offset, comp.node.worldMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
_createShapes (scaleX: number, scaleY: number, relativePositionX: number, relativePositionY: number): any[] {
|
_createShapes (scaleX: number, scaleY: number, relativePositionX: number, relativePositionY: number): any[] {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import { instantiateWasm, ensureWasmModuleReady } from 'pal/wasm';
|
|||||||
import { BUILD, LOAD_BOX2D_MANUALLY, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
|
import { BUILD, LOAD_BOX2D_MANUALLY, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
|
||||||
|
|
||||||
import { game } from '../../game';
|
import { game } from '../../game';
|
||||||
import { error, sys, IVec2Like, log } from '../../core';
|
import { error, sys, IVec2Like, log, debug } from '../../core';
|
||||||
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
|
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-mutable-exports
|
// eslint-disable-next-line import/no-mutable-exports
|
||||||
@@ -148,7 +148,7 @@ function initWasm (wasmFactory, wasmUrl: string): Promise<void> {
|
|||||||
}).catch((err) => reject(errorMessage(err)));
|
}).catch((err) => reject(errorMessage(err)));
|
||||||
},
|
},
|
||||||
}).then((Instance: any) => {
|
}).then((Instance: any) => {
|
||||||
log('[box2d]:box2d wasm lib loaded.');
|
debug('[box2d]:box2d wasm lib loaded.');
|
||||||
B2 = Instance;
|
B2 = Instance;
|
||||||
}).then(resolve).catch((err: any) => reject(errorMessage(err)));
|
}).then(resolve).catch((err: any) => reject(errorMessage(err)));
|
||||||
});
|
});
|
||||||
@@ -158,7 +158,7 @@ function initAsm (asmFactory): Promise<void> {
|
|||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
const errorMessage = (err: any): string => `[box2d]: box2d asm lib load failed: ${err}`;
|
const errorMessage = (err: any): string => `[box2d]: box2d asm lib load failed: ${err}`;
|
||||||
asmFactory().then((instance: any) => {
|
asmFactory().then((instance: any) => {
|
||||||
log('[box2d]:box2d asm lib loaded.');
|
debug('[box2d]:box2d asm lib loaded.');
|
||||||
B2 = instance;
|
B2 = instance;
|
||||||
}).then(resolve).catch((err: any) => reject(errorMessage(err)));
|
}).then(resolve).catch((err: any) => reject(errorMessage(err)));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export class B2PhysicsWorld implements IPhysicsWorld {
|
|||||||
|
|
||||||
if (!v) {
|
if (!v) {
|
||||||
if (this._debugGraphics) {
|
if (this._debugGraphics) {
|
||||||
this._debugGraphics.node.parent = null;
|
this._debugGraphics.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ export class B2CircleShape extends B2Shape2D implements ICircleShape {
|
|||||||
|
|
||||||
_worldPosition = new Vec2();
|
_worldPosition = new Vec2();
|
||||||
get worldPosition (): Vec2 {
|
get worldPosition (): Vec2 {
|
||||||
const p = B2.CircleShapeGetPosition(this._shapes[0]) as B2.Vec2;
|
const comp = this.collider as CircleCollider2D;
|
||||||
return this._worldPosition.set(p.x * PHYSICS_2D_PTM_RATIO, p.y * PHYSICS_2D_PTM_RATIO);
|
return Vec2.transformMat4(this._worldPosition, comp.offset, comp.node.worldMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
_createShapes (scaleX: number, scaleY: number, relativePositionX: number, relativePositionY: number): number[] { //B2.CircleShape[]
|
_createShapes (scaleX: number, scaleY: number, relativePositionX: number, relativePositionY: number): number[] { //B2.CircleShape[]
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export class b2PhysicsWorld implements IPhysicsWorld {
|
|||||||
|
|
||||||
if (!v) {
|
if (!v) {
|
||||||
if (this._debugGraphics) {
|
if (this._debugGraphics) {
|
||||||
this._debugGraphics.node.parent = null;
|
this._debugGraphics.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ export class b2CircleShape extends b2Shape2D implements ICircleShape {
|
|||||||
|
|
||||||
_worldPosition = new Vec2();
|
_worldPosition = new Vec2();
|
||||||
get worldPosition (): Vec2 {
|
get worldPosition (): Vec2 {
|
||||||
const p = (this._shapes[0] as b2.CircleShape).m_p;
|
const comp = this.collider as CircleCollider2D;
|
||||||
return this._worldPosition.set(p.x * PHYSICS_2D_PTM_RATIO, p.y * PHYSICS_2D_PTM_RATIO);
|
return Vec2.transformMat4(this._worldPosition, comp.offset, comp.node.worldMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
_createShapes (scaleX: number, scaleY: number, relativePositionX: number, relativePositionY: number): any[] {
|
_createShapes (scaleX: number, scaleY: number, relativePositionX: number, relativePositionY: number): any[] {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { EDITOR, DEBUG, TEST, EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
|
|||||||
import { IRigidBody2D } from '../spec/i-rigid-body';
|
import { IRigidBody2D } from '../spec/i-rigid-body';
|
||||||
import { IBoxShape, ICircleShape, IPolygonShape, IBaseShape } from '../spec/i-physics-shape';
|
import { IBoxShape, ICircleShape, IPolygonShape, IBaseShape } from '../spec/i-physics-shape';
|
||||||
import { IPhysicsWorld } from '../spec/i-physics-world';
|
import { IPhysicsWorld } from '../spec/i-physics-world';
|
||||||
import { errorID, log } from '../../core';
|
import { debug, errorID, log } from '../../core';
|
||||||
import { ECollider2DType, EJoint2DType } from './physics-types';
|
import { ECollider2DType, EJoint2DType } from './physics-types';
|
||||||
import { IJoint2D, IDistanceJoint, ISpringJoint, IFixedJoint, IMouseJoint,
|
import { IJoint2D, IDistanceJoint, ISpringJoint, IFixedJoint, IMouseJoint,
|
||||||
IRelativeJoint, ISliderJoint, IWheelJoint, IHingeJoint } from '../spec/i-physics-joint';
|
IRelativeJoint, ISliderJoint, IWheelJoint, IHingeJoint } from '../spec/i-physics-joint';
|
||||||
@@ -110,7 +110,7 @@ export interface IPhysicsSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function register (id: IPhysicsEngineId, wrapper: IPhysicsWrapperObject): void {
|
function register (id: IPhysicsEngineId, wrapper: IPhysicsWrapperObject): void {
|
||||||
if (!EDITOR && !TEST) log(`[PHYSICS2D]: register ${id}.`);
|
if (!EDITOR && !TEST) debug(`[PHYSICS2D]: register ${id}.`);
|
||||||
selector.backend[id] = wrapper;
|
selector.backend[id] = wrapper;
|
||||||
if (!selector.physicsWorld || selector.id === id) {
|
if (!selector.physicsWorld || selector.id === id) {
|
||||||
const mutableSelector = selector as Mutable<IPhysicsSelector>;
|
const mutableSelector = selector as Mutable<IPhysicsSelector>;
|
||||||
@@ -124,12 +124,12 @@ function switchTo (id: IPhysicsEngineId): void {
|
|||||||
const mutableSelector = selector as Mutable<IPhysicsSelector>;
|
const mutableSelector = selector as Mutable<IPhysicsSelector>;
|
||||||
if (selector.physicsWorld && id !== selector.id && selector.backend[id] != null) {
|
if (selector.physicsWorld && id !== selector.id && selector.backend[id] != null) {
|
||||||
//selector.physicsWorld.destroy();//todo
|
//selector.physicsWorld.destroy();//todo
|
||||||
if (!TEST) log(`[PHYSICS2D]: switch from ${selector.id} to ${id}.`);
|
if (!TEST) debug(`[PHYSICS2D]: switch from ${selector.id} to ${id}.`);
|
||||||
mutableSelector.id = id;
|
mutableSelector.id = id;
|
||||||
mutableSelector.wrapper = selector.backend[id];
|
mutableSelector.wrapper = selector.backend[id];
|
||||||
mutableSelector.physicsWorld = createPhysicsWorld();
|
mutableSelector.physicsWorld = createPhysicsWorld();
|
||||||
} else {
|
} else {
|
||||||
if (!EDITOR && !TEST) log(`[PHYSICS2D]: using ${mutableSelector.id}.`);
|
if (!EDITOR && !TEST) debug(`[PHYSICS2D]: using ${mutableSelector.id}.`);
|
||||||
mutableSelector.physicsWorld = createPhysicsWorld();
|
mutableSelector.physicsWorld = createPhysicsWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
import { ensureWasmModuleReady, instantiateWasm } from 'pal/wasm';
|
import { ensureWasmModuleReady, instantiateWasm } from 'pal/wasm';
|
||||||
import { BUILD, LOAD_BULLET_MANUALLY, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
|
import { BUILD, LOAD_BULLET_MANUALLY, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
|
||||||
import { game } from '../../game';
|
import { game } from '../../game';
|
||||||
import { error, log, sys } from '../../core';
|
import { debug, error, sys } from '../../core';
|
||||||
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
|
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
|
||||||
import type { BulletCache } from './bullet-cache';
|
import type { BulletCache } from './bullet-cache';
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ function initWASM (wasmFactory, wasmUrl: string): Promise<void> {
|
|||||||
}).catch((err) => reject(errorMessage(err)));
|
}).catch((err) => reject(errorMessage(err)));
|
||||||
},
|
},
|
||||||
}).then((instance: any) => {
|
}).then((instance: any) => {
|
||||||
log('[bullet]:bullet wasm lib loaded.');
|
debug('[bullet]:bullet wasm lib loaded.');
|
||||||
bt = instance as Bullet.instance;
|
bt = instance as Bullet.instance;
|
||||||
globalThis.Bullet = bt as any;
|
globalThis.Bullet = bt as any;
|
||||||
}).then(resolve).catch((err: any) => reject(errorMessage(err)));
|
}).then(resolve).catch((err: any) => reject(errorMessage(err)));
|
||||||
@@ -117,7 +117,7 @@ function initASM (asmFactory): Promise<void> {
|
|||||||
if (asmFactory != null) {
|
if (asmFactory != null) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||||
return asmFactory().then((instance: any) => {
|
return asmFactory().then((instance: any) => {
|
||||||
log('[bullet]:bullet asm lib loaded.');
|
debug('[bullet]:bullet asm lib loaded.');
|
||||||
bt = instance as Bullet.instance;
|
bt = instance as Bullet.instance;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
import { IPhysicsWorld } from '../spec/i-physics-world';
|
import { IPhysicsWorld } from '../spec/i-physics-world';
|
||||||
import { IRigidBody } from '../spec/i-rigid-body';
|
import { IRigidBody } from '../spec/i-rigid-body';
|
||||||
import { IBoxCharacterController, ICapsuleCharacterController } from '../spec/i-character-controller';
|
import { IBoxCharacterController, ICapsuleCharacterController } from '../spec/i-character-controller';
|
||||||
import { errorID, IVec3Like, warn, cclegacy, log } from '../../core';
|
import { errorID, IVec3Like, warn, cclegacy, debug } from '../../core';
|
||||||
import { EColliderType, EConstraintType, ECharacterControllerType } from './physics-enum';
|
import { EColliderType, EConstraintType, ECharacterControllerType } from './physics-enum';
|
||||||
import { PhysicsMaterial } from '.';
|
import { PhysicsMaterial } from '.';
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ function updateLegacyMacro (id: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function register (id: IPhysicsEngineId, wrapper: IPhysicsWrapperObject): void {
|
function register (id: IPhysicsEngineId, wrapper: IPhysicsWrapperObject): void {
|
||||||
if (!EDITOR && !TEST) log(`[PHYSICS]: register ${id}.`);
|
if (!EDITOR && !TEST) debug(`[PHYSICS]: register ${id}.`);
|
||||||
selector.backend[id] = wrapper;
|
selector.backend[id] = wrapper;
|
||||||
if (!selector.physicsWorld || selector.id === id) {
|
if (!selector.physicsWorld || selector.id === id) {
|
||||||
updateLegacyMacro(id);
|
updateLegacyMacro(id);
|
||||||
@@ -147,13 +147,13 @@ function switchTo (id: IPhysicsEngineId): void {
|
|||||||
const mutableSelector = selector as Mutable<IPhysicsSelector>;
|
const mutableSelector = selector as Mutable<IPhysicsSelector>;
|
||||||
if (selector.physicsWorld && id !== selector.id && selector.backend[id] != null) {
|
if (selector.physicsWorld && id !== selector.id && selector.backend[id] != null) {
|
||||||
selector.physicsWorld.destroy();
|
selector.physicsWorld.destroy();
|
||||||
if (!TEST) log(`[PHYSICS]: switch from ${selector.id} to ${id}.`);
|
if (!TEST) debug(`[PHYSICS]: switch from ${selector.id} to ${id}.`);
|
||||||
updateLegacyMacro(id);
|
updateLegacyMacro(id);
|
||||||
mutableSelector.id = id;
|
mutableSelector.id = id;
|
||||||
mutableSelector.wrapper = selector.backend[id];
|
mutableSelector.wrapper = selector.backend[id];
|
||||||
mutableSelector.physicsWorld = createPhysicsWorld();
|
mutableSelector.physicsWorld = createPhysicsWorld();
|
||||||
} else {
|
} else {
|
||||||
if (!EDITOR && !TEST) log(`[PHYSICS]: using ${id}.`);
|
if (!EDITOR && !TEST) debug(`[PHYSICS]: using ${id}.`);
|
||||||
mutableSelector.physicsWorld = createPhysicsWorld();
|
mutableSelector.physicsWorld = createPhysicsWorld();
|
||||||
}
|
}
|
||||||
if (worldInitData) {
|
if (worldInitData) {
|
||||||
@@ -185,7 +185,7 @@ export function constructDefaultWorld (data: IWorldInitData): void {
|
|||||||
if (!worldInitData) worldInitData = data;
|
if (!worldInitData) worldInitData = data;
|
||||||
if (!selector.runInEditor) return;
|
if (!selector.runInEditor) return;
|
||||||
if (!selector.physicsWorld) {
|
if (!selector.physicsWorld) {
|
||||||
if (!TEST) log(`[PHYSICS]: using ${selector.id}.`);
|
if (!TEST) debug(`[PHYSICS]: using ${selector.id}.`);
|
||||||
const mutableSelector = selector as Mutable<IPhysicsSelector>;
|
const mutableSelector = selector as Mutable<IPhysicsSelector>;
|
||||||
const world = mutableSelector.physicsWorld = createPhysicsWorld();
|
const world = mutableSelector.physicsWorld = createPhysicsWorld();
|
||||||
world.setGravity(worldInitData.gravity);
|
world.setGravity(worldInitData.gravity);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import { murmurhash2_32_gc, errorID, assertID, cclegacy, warnID } from '../../co
|
|||||||
import {
|
import {
|
||||||
BufferUsageBit, DynamicStateFlagBit, DynamicStateFlags, Feature, GetTypeSize, MemoryUsageBit, PrimitiveMode, Type, Color,
|
BufferUsageBit, DynamicStateFlagBit, DynamicStateFlags, Feature, GetTypeSize, MemoryUsageBit, PrimitiveMode, Type, Color,
|
||||||
BlendState, BlendTarget, Buffer, BufferInfo, BufferViewInfo, DepthStencilState, DescriptorSet,
|
BlendState, BlendTarget, Buffer, BufferInfo, BufferViewInfo, DepthStencilState, DescriptorSet,
|
||||||
DescriptorSetInfo, DescriptorSetLayout, Device, RasterizerState, Sampler, Texture, Shader, PipelineLayout, deviceManager, UniformBlock,
|
DescriptorSetInfo, DescriptorSetLayout, Device, RasterizerState, Sampler, SampleCount, Texture, Shader, PipelineLayout, deviceManager, UniformBlock,
|
||||||
} from '../../gfx';
|
} from '../../gfx';
|
||||||
import { EffectAsset } from '../../asset/assets/effect-asset';
|
import { EffectAsset } from '../../asset/assets/effect-asset';
|
||||||
import { IProgramInfo, programLib } from './program-lib';
|
import { IProgramInfo, programLib } from './program-lib';
|
||||||
@@ -139,6 +139,28 @@ export class Pass {
|
|||||||
if (bsInfo.isA2C !== undefined) { bs.isA2C = bsInfo.isA2C; }
|
if (bsInfo.isA2C !== undefined) { bs.isA2C = bsInfo.isA2C; }
|
||||||
if (bsInfo.isIndepend !== undefined) { bs.isIndepend = bsInfo.isIndepend; }
|
if (bsInfo.isIndepend !== undefined) { bs.isIndepend = bsInfo.isIndepend; }
|
||||||
if (bsInfo.blendColor !== undefined) { bs.blendColor = bsInfo.blendColor as Color; }
|
if (bsInfo.blendColor !== undefined) { bs.blendColor = bsInfo.blendColor as Color; }
|
||||||
|
|
||||||
|
// A2C (Alpha to Coverage) requires MSAA to be effective.
|
||||||
|
// Without multiple subsamples, A2C behaves like alpha-test at ~0.5 and should be disabled.
|
||||||
|
// Disable A2C when neither the pass nor the global framebuffer has MSAA enabled:
|
||||||
|
// - passWantsMultisample: pass explicitly requests isMultisample
|
||||||
|
// - globalMsaaEnabled: swapchain has MSAA (native: colorTexture.samples > X1;
|
||||||
|
// WebGL: antialias from gl.getContextAttributes(), since WebGL
|
||||||
|
// MSAA is controlled at context level, not texture level)
|
||||||
|
if (bs.isA2C) {
|
||||||
|
const gfxDevice = deviceManager.gfxDevice as any;
|
||||||
|
const gl: WebGL2RenderingContext | WebGLRenderingContext | null = gfxDevice.gl || null;
|
||||||
|
const ctxAttrs = gl && gl.getContextAttributes();
|
||||||
|
const antialias: boolean = !!(ctxAttrs && ctxAttrs.antialias);
|
||||||
|
const passWantsMultisample = (info.rasterizerState && info.rasterizerState.isMultisample === true);
|
||||||
|
const swapchain = deviceManager.swapchain;
|
||||||
|
const colorTex = swapchain && swapchain.colorTexture;
|
||||||
|
const msaaDisabled = (!colorTex || (colorTex && colorTex.samples <= SampleCount.X1))
|
||||||
|
|| !antialias || !passWantsMultisample;
|
||||||
|
if (msaaDisabled) {
|
||||||
|
bs.isA2C = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pass._rs.assign(info.rasterizerState as RasterizerState);
|
pass._rs.assign(info.rasterizerState as RasterizerState);
|
||||||
pass._dss.assign(info.depthStencilState as DepthStencilState);
|
pass._dss.assign(info.depthStencilState as DepthStencilState);
|
||||||
|
|||||||
@@ -21,12 +21,14 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
import { DEBUG } from 'internal:constants';
|
||||||
import { screenAdapter } from 'pal/screen-adapter';
|
import { screenAdapter } from 'pal/screen-adapter';
|
||||||
import { Orientation } from '../../../pal/screen-adapter/enum-type';
|
import { Orientation } from '../../../pal/screen-adapter/enum-type';
|
||||||
import {
|
import {
|
||||||
TextureType, TextureUsageBit, Format, RenderPass, Texture, Framebuffer,
|
TextureType, TextureUsageBit, Format, RenderPass, Texture, Framebuffer,
|
||||||
RenderPassInfo, Device, TextureInfo, FramebufferInfo, Swapchain, SurfaceTransform, TextureFlagBit, TextureFlags,
|
RenderPassInfo, Device, TextureInfo, FramebufferInfo, Swapchain, SurfaceTransform, TextureFlagBit, TextureFlags,
|
||||||
} from '../../gfx';
|
} from '../../gfx';
|
||||||
|
import { warn } from '../../core/platform/debug';
|
||||||
import { Root } from '../../root';
|
import { Root } from '../../root';
|
||||||
import { Camera } from '../scene';
|
import { Camera } from '../scene';
|
||||||
|
|
||||||
@@ -41,7 +43,10 @@ export interface IRenderWindowInfo {
|
|||||||
externalFlag?: TextureFlags; // external texture type normal or oes
|
externalFlag?: TextureFlags; // external texture type normal or oes
|
||||||
}
|
}
|
||||||
|
|
||||||
const orientationMap: Record<Orientation, SurfaceTransform> = {
|
// NOTE: `Orientation` is a flag enum whose composite members (LANDSCAPE, AUTO) are never
|
||||||
|
// actual runtime orientations, so this map intentionally only covers the physical ones.
|
||||||
|
// It is therefore typed as Partial rather than a total Record<Orientation, ...>.
|
||||||
|
const orientationMap: Partial<Record<Orientation, SurfaceTransform>> = {
|
||||||
[Orientation.PORTRAIT]: SurfaceTransform.IDENTITY,
|
[Orientation.PORTRAIT]: SurfaceTransform.IDENTITY,
|
||||||
[Orientation.LANDSCAPE_RIGHT]: SurfaceTransform.ROTATE_90,
|
[Orientation.LANDSCAPE_RIGHT]: SurfaceTransform.ROTATE_90,
|
||||||
[Orientation.PORTRAIT_UPSIDE_DOWN]: SurfaceTransform.ROTATE_180,
|
[Orientation.PORTRAIT_UPSIDE_DOWN]: SurfaceTransform.ROTATE_180,
|
||||||
@@ -253,7 +258,11 @@ export class RenderWindow {
|
|||||||
*/
|
*/
|
||||||
public resize (width: number, height: number): void {
|
public resize (width: number, height: number): void {
|
||||||
if (this._swapchain) {
|
if (this._swapchain) {
|
||||||
this._swapchain.resize(width, height, orientationMap[screenAdapter.orientation]);
|
const surfaceTransform = orientationMap[screenAdapter.orientation];
|
||||||
|
if (DEBUG && surfaceTransform === undefined) {
|
||||||
|
warn(`Unexpected screen orientation: ${screenAdapter.orientation}`);
|
||||||
|
}
|
||||||
|
this._swapchain.resize(width, height, surfaceTransform || SurfaceTransform.IDENTITY);
|
||||||
this._width = this._swapchain.width;
|
this._width = this._swapchain.width;
|
||||||
this._height = this._swapchain.height;
|
this._height = this._swapchain.height;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ export class PointLight extends Light {
|
|||||||
* @en The luminance of the light source in LDR mode.
|
* @en The luminance of the light source in LDR mode.
|
||||||
* @zh LDR 模式下光源的亮度。
|
* @zh LDR 模式下光源的亮度。
|
||||||
*/
|
*/
|
||||||
|
get luminanceLDR (): number {
|
||||||
|
return this._luminanceLDR;
|
||||||
|
}
|
||||||
set luminanceLDR (value: number) {
|
set luminanceLDR (value: number) {
|
||||||
this._luminanceLDR = value;
|
this._luminanceLDR = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,11 +67,13 @@ export class ReflectionProbe {
|
|||||||
protected readonly _size = v3(1, 1, 1);
|
protected readonly _size = v3(1, 1, 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @en Render cubemap's camera
|
* @en Camera used for probe rendering (cubemap capture or planar reflection).
|
||||||
* @zh 渲染cubemap的相机
|
* @zh 用于探针渲染的相机(cubemap 采集或平面反射)
|
||||||
*/
|
*/
|
||||||
private _camera: Camera | null = null;
|
private _camera: Camera | null = null;
|
||||||
|
|
||||||
|
private _previewCamera: Camera | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @en Unique id of probe.
|
* @en Unique id of probe.
|
||||||
* @zh probe的唯一id
|
* @zh probe的唯一id
|
||||||
@@ -184,6 +186,9 @@ export class ReflectionProbe {
|
|||||||
set visibility (val) {
|
set visibility (val) {
|
||||||
this._visibility = val;
|
this._visibility = val;
|
||||||
this._camera!.visibility = this._visibility;
|
this._camera!.visibility = this._visibility;
|
||||||
|
if (this._previewCamera) {
|
||||||
|
this._previewCamera.visibility = this._visibility;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,6 +325,21 @@ export class ReflectionProbe {
|
|||||||
this._needRender = true;
|
this._needRender = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @engineInternal
|
||||||
|
* @mangle
|
||||||
|
*/
|
||||||
|
public renderPreviewPlanarReflection (sourceCamera: Camera): Camera {
|
||||||
|
if (!this._previewCamera) {
|
||||||
|
this._createCamera(new Node(`${this.cameraNode.name} Preview Reflection`), true);
|
||||||
|
}
|
||||||
|
const previewCamera = this._previewCamera!;
|
||||||
|
this._syncCameraParams(sourceCamera, previewCamera);
|
||||||
|
this._transformReflectionCamera(sourceCamera, previewCamera);
|
||||||
|
this._needRender = true;
|
||||||
|
return previewCamera;
|
||||||
|
}
|
||||||
|
|
||||||
public switchProbeType (type: ProbeType, sourceCamera: Camera | null): void {
|
public switchProbeType (type: ProbeType, sourceCamera: Camera | null): void {
|
||||||
if (type === ProbeType.CUBE) {
|
if (type === ProbeType.CUBE) {
|
||||||
this._needRender = false;
|
this._needRender = false;
|
||||||
@@ -357,6 +377,12 @@ export class ReflectionProbe {
|
|||||||
this._camera.destroy();
|
this._camera.destroy();
|
||||||
this._camera = null;
|
this._camera = null;
|
||||||
}
|
}
|
||||||
|
if (this._previewCamera) {
|
||||||
|
const cameraNode = this._previewCamera.node;
|
||||||
|
this._previewCamera.destroy();
|
||||||
|
this._previewCamera = null;
|
||||||
|
cameraNode.destroy();
|
||||||
|
}
|
||||||
for (let i = 0; i < this.bakedCubeTextures.length; i++) {
|
for (let i = 0; i < this.bakedCubeTextures.length; i++) {
|
||||||
this.bakedCubeTextures[i].destroy();
|
this.bakedCubeTextures[i].destroy();
|
||||||
}
|
}
|
||||||
@@ -410,48 +436,54 @@ export class ReflectionProbe {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _syncCameraParams (camera: Camera): void {
|
private _syncCameraParams (camera: Camera, targetCamera: Camera = this.camera): void {
|
||||||
this.camera.projectionType = camera.projectionType;
|
targetCamera.projectionType = camera.projectionType;
|
||||||
this.camera.orthoHeight = camera.orthoHeight;
|
targetCamera.orthoHeight = camera.orthoHeight;
|
||||||
this.camera.nearClip = camera.nearClip;
|
targetCamera.nearClip = camera.nearClip;
|
||||||
this.camera.farClip = camera.farClip;
|
targetCamera.farClip = camera.farClip;
|
||||||
this.camera.fov = camera.fov;
|
targetCamera.fov = camera.fov;
|
||||||
this.camera.clearFlag = camera.clearFlag;
|
targetCamera.clearFlag = camera.clearFlag;
|
||||||
this.camera.clearColor = camera.clearColor;
|
targetCamera.clearColor = camera.clearColor;
|
||||||
this.camera.priority = camera.priority - 1;
|
targetCamera.priority = camera.priority - 1;
|
||||||
this.camera.resize(camera.width, camera.height);
|
targetCamera.resize(camera.width, camera.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createCamera (cameraNode: Node): Camera | null {
|
private _createCamera (cameraNode: Node, preview = false): Camera | null {
|
||||||
const root = cclegacy.director.root;
|
const root = cclegacy.director.root;
|
||||||
if (!this._camera) {
|
let camera = preview ? this._previewCamera : this._camera;
|
||||||
this._camera = root.createCamera();
|
if (!camera) {
|
||||||
if (!this._camera) return null;
|
camera = root.createCamera();
|
||||||
this._camera.initialize({
|
if (!camera) return null;
|
||||||
|
camera.initialize({
|
||||||
name: cameraNode.name,
|
name: cameraNode.name,
|
||||||
node: cameraNode,
|
node: cameraNode,
|
||||||
projection: CameraProjection.PERSPECTIVE,
|
projection: CameraProjection.PERSPECTIVE,
|
||||||
window: EDITOR ? root && root.mainWindow : root && root.tempWindow,
|
window: preview || EDITOR ? root.mainWindow : root.tempWindow,
|
||||||
priority: 0,
|
priority: 0,
|
||||||
cameraType: CameraType.DEFAULT,
|
cameraType: CameraType.DEFAULT,
|
||||||
trackingType: TrackingType.NO_TRACKING,
|
trackingType: TrackingType.NO_TRACKING,
|
||||||
});
|
});
|
||||||
|
if (preview) {
|
||||||
|
this._previewCamera = camera;
|
||||||
|
} else {
|
||||||
|
this._camera = camera;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this._camera.setViewportInOrientedSpace(new Rect(0, 0, 1, 1));
|
camera.setViewportInOrientedSpace(new Rect(0, 0, 1, 1));
|
||||||
this._camera.fovAxis = CameraFOVAxis.VERTICAL;
|
camera.fovAxis = CameraFOVAxis.VERTICAL;
|
||||||
this._camera.fov = toRadian(90);
|
camera.fov = toRadian(90);
|
||||||
this._camera.orthoHeight = 10;
|
camera.orthoHeight = 10;
|
||||||
this._camera.nearClip = 1;
|
camera.nearClip = 1;
|
||||||
this._camera.farClip = 1000;
|
camera.farClip = 1000;
|
||||||
this._camera.clearColor = this._backgroundColor;
|
camera.clearColor = this._backgroundColor;
|
||||||
this._camera.clearDepth = 1.0;
|
camera.clearDepth = 1.0;
|
||||||
this._camera.clearStencil = 0.0;
|
camera.clearStencil = 0.0;
|
||||||
this._camera.clearFlag = this._clearFlag;
|
camera.clearFlag = this._clearFlag;
|
||||||
this._camera.visibility = this._visibility;
|
camera.visibility = this._visibility;
|
||||||
this._camera.aperture = CameraAperture.F16_0;
|
camera.aperture = CameraAperture.F16_0;
|
||||||
this._camera.shutter = CameraShutter.D125;
|
camera.shutter = CameraShutter.D125;
|
||||||
this._camera.iso = CameraISO.ISO100;
|
camera.iso = CameraISO.ISO100;
|
||||||
return this._camera;
|
return camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _resetCameraParams (): void {
|
private _resetCameraParams (): void {
|
||||||
@@ -478,10 +510,10 @@ export class ReflectionProbe {
|
|||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _transformReflectionCamera (sourceCamera: Camera): void {
|
private _transformReflectionCamera (sourceCamera: Camera, targetCamera: Camera = this.camera): void {
|
||||||
const offset = Vec3.dot(this.node.worldPosition, this.node.up);
|
const offset = Vec3.dot(this.node.worldPosition, this.node.up);
|
||||||
this._reflect(this._cameraWorldPos, sourceCamera.node.worldPosition, this.node.up, offset);
|
this._reflect(this._cameraWorldPos, sourceCamera.node.worldPosition, this.node.up, offset);
|
||||||
this.cameraNode.worldPosition = this._cameraWorldPos;
|
targetCamera.node.worldPosition = this._cameraWorldPos;
|
||||||
|
|
||||||
Vec3.transformQuat(this._forward, Vec3.FORWARD, sourceCamera.node.worldRotation);
|
Vec3.transformQuat(this._forward, Vec3.FORWARD, sourceCamera.node.worldRotation);
|
||||||
this._reflect(this._forward, this._forward, this.node.up, 0);
|
this._reflect(this._forward, this._forward, this.node.up, 0);
|
||||||
@@ -494,14 +526,14 @@ export class ReflectionProbe {
|
|||||||
|
|
||||||
Quat.fromViewUp(this._cameraWorldRotation, this._forward, this._up);
|
Quat.fromViewUp(this._cameraWorldRotation, this._forward, this._up);
|
||||||
|
|
||||||
this.cameraNode.worldRotation = this._cameraWorldRotation;
|
targetCamera.node.worldRotation = this._cameraWorldRotation;
|
||||||
|
|
||||||
this.camera.update(true);
|
targetCamera.update(true);
|
||||||
|
|
||||||
// Transform the plane from world space to reflection camera space use the inverse transpose matrix
|
// Transform the plane from world space to reflection camera space use the inverse transpose matrix
|
||||||
const viewSpaceProbe = new Vec4(this.node.up.x, this.node.up.y, this.node.up.z, -Vec3.dot(this.node.up, this.node.worldPosition));
|
const viewSpaceProbe = new Vec4(this.node.up.x, this.node.up.y, this.node.up.z, -Vec3.dot(this.node.up, this.node.worldPosition));
|
||||||
viewSpaceProbe.transformMat4(this.camera.matView.clone().invert().transpose());
|
viewSpaceProbe.transformMat4(targetCamera.matView.clone().invert().transpose());
|
||||||
this.camera.calculateObliqueMat(viewSpaceProbe);
|
targetCamera.calculateObliqueMat(viewSpaceProbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _reflect (out: Vec3, point: Vec3, normal: Vec3, offset: number): Vec3 {
|
private _reflect (out: Vec3, point: Vec3, normal: Vec3, offset: number): Vec3 {
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ export class SphereLight extends Light {
|
|||||||
* @en The luminance of the light source in LDR mode
|
* @en The luminance of the light source in LDR mode
|
||||||
* @zh LDR 模式下光源的亮度
|
* @zh LDR 模式下光源的亮度
|
||||||
*/
|
*/
|
||||||
|
get luminanceLDR (): number {
|
||||||
|
return this._luminanceLDR;
|
||||||
|
}
|
||||||
set luminanceLDR (value: number) {
|
set luminanceLDR (value: number) {
|
||||||
this._luminanceLDR = value;
|
this._luminanceLDR = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import { Buffer, Framebuffer, Texture, Viewport } from '../../gfx';
|
import { Buffer, Framebuffer, Texture, Viewport } from '../../gfx';
|
||||||
import { genHashValue } from './define';
|
|
||||||
import { VectorGraphColorMap } from './effect';
|
import { VectorGraphColorMap } from './effect';
|
||||||
import { DefaultVisitor, depthFirstSearch, ReferenceGraphView } from './graph';
|
import { DefaultVisitor, depthFirstSearch, ReferenceGraphView } from './graph';
|
||||||
import { LayoutGraphData } from './layout-graph';
|
import { LayoutGraphData } from './layout-graph';
|
||||||
@@ -199,7 +198,6 @@ class PassVisitor implements RenderGraphVisitor {
|
|||||||
resourceGraph.visitVertex(this._resVisitor, vertID);
|
resourceGraph.visitVertex(this._resVisitor, vertID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
genHashValue(pass);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
applyID (id: number, resId: number): void {
|
applyID (id: number, resId: number): void {
|
||||||
|
|||||||
@@ -615,10 +615,17 @@ class DeviceRenderQueue implements RecordingInterface {
|
|||||||
this._devicePass = devicePass;
|
this._devicePass = devicePass;
|
||||||
this._phaseID = cclegacy.rendering.getPhaseID(devicePass.passID, context.renderGraph.getLayout(id));
|
this._phaseID = cclegacy.rendering.getPhaseID(devicePass.passID, context.renderGraph.getLayout(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @en Creates a blit descriptor for the given blit operation.
|
||||||
|
* @zh 为给定的 blit 操作创建一个 blit 描述符。
|
||||||
|
* @param blit @en The blit operation to create a descriptor for. @zh 要为其创建描述符的 blit 操作。
|
||||||
|
*/
|
||||||
createBlitDesc (blit: Blit): void {
|
createBlitDesc (blit: Blit): void {
|
||||||
if (!this._blitDesc) {
|
if (!this._blitDesc) {
|
||||||
this._blitDesc = new BlitDesc(blit);
|
this._blitDesc = new BlitDesc(blit);
|
||||||
}
|
}
|
||||||
|
this._blitDesc.blit = blit;
|
||||||
this._blitDesc.createScreenQuad();
|
this._blitDesc.createScreenQuad();
|
||||||
this._blitDesc.createStageDescriptor();
|
this._blitDesc.createStageDescriptor();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,10 +195,13 @@ function sceneCulling (
|
|||||||
}
|
}
|
||||||
models.push(model);
|
models.push(model);
|
||||||
} else if (probe.probeType === ProbeType.CUBE) {
|
} else if (probe.probeType === ProbeType.CUBE) {
|
||||||
|
if (!wBounds || !model.bakeToReflectionProbe) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!isVisible(model, visibility)) {
|
if (!isVisible(model, visibility)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (wBounds && isIntersectAABB(wBounds, probe.boundingBox!)) {
|
if (isIntersectAABB(wBounds, probe.boundingBox!)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
models.push(model);
|
models.push(model);
|
||||||
@@ -475,7 +478,8 @@ export class SceneCulling {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Get or create render queue
|
// Get or create render queue
|
||||||
const renderQueueID = this.getOrCreateRenderQueue(renderQueueKey, sceneData.flags, sceneData.camera);
|
const renderCamera = sceneData.light.probe ? sceneData.light.probe.camera : sceneData.camera;
|
||||||
|
const renderQueueID = this.getOrCreateRenderQueue(renderQueueKey, sceneData.flags, renderCamera);
|
||||||
|
|
||||||
// add render queue query
|
// add render queue query
|
||||||
const renderQueueQuery = this.cullingPools.renderQueueQueryRecycle.add();
|
const renderQueueQuery = this.cullingPools.renderQueueQueryRecycle.add();
|
||||||
@@ -556,7 +560,11 @@ export class SceneCulling {
|
|||||||
|
|
||||||
private executeSphereLightCulling (light: SphereLight, frustumCullingResult: Array<Model>, lightBoundsCullingResult: Array<Model>): void {
|
private executeSphereLightCulling (light: SphereLight, frustumCullingResult: Array<Model>, lightBoundsCullingResult: Array<Model>): void {
|
||||||
const lightAABB = light.aabb;
|
const lightAABB = light.aabb;
|
||||||
|
const visibility = light.visibility;
|
||||||
for (const model of frustumCullingResult) {
|
for (const model of frustumCullingResult) {
|
||||||
|
if (!isVisible(model, visibility)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const modelBounds = model.worldBounds;
|
const modelBounds = model.worldBounds;
|
||||||
if (!modelBounds || intersect.aabbWithAABB(modelBounds, lightAABB)) {
|
if (!modelBounds || intersect.aabbWithAABB(modelBounds, lightAABB)) {
|
||||||
lightBoundsCullingResult.push(model);
|
lightBoundsCullingResult.push(model);
|
||||||
@@ -567,7 +575,11 @@ export class SceneCulling {
|
|||||||
private executeSpotLightCulling (light: SpotLight, frustumCullingResult: Array<Model>, lightBoundsCullingResult: Array<Model>): void {
|
private executeSpotLightCulling (light: SpotLight, frustumCullingResult: Array<Model>, lightBoundsCullingResult: Array<Model>): void {
|
||||||
const lightAABB = light.aabb;
|
const lightAABB = light.aabb;
|
||||||
const lightFrustum: Frustum = light.frustum;
|
const lightFrustum: Frustum = light.frustum;
|
||||||
|
const visibility = light.visibility;
|
||||||
for (const model of frustumCullingResult) {
|
for (const model of frustumCullingResult) {
|
||||||
|
if (!isVisible(model, visibility)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const modelBounds = model.worldBounds;
|
const modelBounds = model.worldBounds;
|
||||||
if (!modelBounds || (intersect.aabbWithAABB(lightAABB, modelBounds) && intersect.aabbFrustum(modelBounds, lightFrustum))) {
|
if (!modelBounds || (intersect.aabbWithAABB(lightAABB, modelBounds) && intersect.aabbFrustum(modelBounds, lightFrustum))) {
|
||||||
lightBoundsCullingResult.push(model);
|
lightBoundsCullingResult.push(model);
|
||||||
@@ -577,7 +589,11 @@ export class SceneCulling {
|
|||||||
|
|
||||||
private executePointLightCulling (light: PointLight, frustumCullingResult: Array<Model>, lightBoundsCullingResult: Array<Model>): void {
|
private executePointLightCulling (light: PointLight, frustumCullingResult: Array<Model>, lightBoundsCullingResult: Array<Model>): void {
|
||||||
const lightAABB = light.aabb;
|
const lightAABB = light.aabb;
|
||||||
|
const visibility = light.visibility;
|
||||||
for (const model of frustumCullingResult) {
|
for (const model of frustumCullingResult) {
|
||||||
|
if (!isVisible(model, visibility)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const modelBounds = model.worldBounds;
|
const modelBounds = model.worldBounds;
|
||||||
if (!modelBounds || intersect.aabbWithAABB(lightAABB, modelBounds)) {
|
if (!modelBounds || intersect.aabbWithAABB(lightAABB, modelBounds)) {
|
||||||
lightBoundsCullingResult.push(model);
|
lightBoundsCullingResult.push(model);
|
||||||
@@ -590,8 +606,12 @@ export class SceneCulling {
|
|||||||
frustumCullingResult: Array<Model>,
|
frustumCullingResult: Array<Model>,
|
||||||
lightBoundsCullingResult: Array<Model>,
|
lightBoundsCullingResult: Array<Model>,
|
||||||
): void {
|
): void {
|
||||||
|
const visibility = light.visibility;
|
||||||
rangedDirLightBoundingBox.transform(light.node!.worldMatrix, null, null, null, lightAABB);
|
rangedDirLightBoundingBox.transform(light.node!.worldMatrix, null, null, null, lightAABB);
|
||||||
for (const model of frustumCullingResult) {
|
for (const model of frustumCullingResult) {
|
||||||
|
if (!isVisible(model, visibility)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const modelBounds = model.worldBounds;
|
const modelBounds = model.worldBounds;
|
||||||
if (!modelBounds || intersect.aabbWithAABB(lightAABB, modelBounds)) {
|
if (!modelBounds || intersect.aabbWithAABB(lightAABB, modelBounds)) {
|
||||||
lightBoundsCullingResult.push(model);
|
lightBoundsCullingResult.push(model);
|
||||||
@@ -817,11 +837,20 @@ export class LightResource {
|
|||||||
this.lightIndex.clear();
|
this.lightIndex.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @en Adds a light to the light buffer and returns its byte offset.
|
||||||
|
* @zh 将光源添加到光源缓冲区,并返回其字节偏移量。
|
||||||
|
* @param light @en The light to add. @zh 要添加的光源。
|
||||||
|
* @param bHDR @en Whether HDR rendering is enabled. @zh 是否启用 HDR 渲染。
|
||||||
|
* @param exposure @en The camera exposure value. @zh 相机曝光值。
|
||||||
|
* @param shadowInfo @en The shadow settings, or null if shadows are disabled. @zh 阴影设置,若禁用阴影则为 null。
|
||||||
|
* @returns @en The byte offset of the light in the light buffer. @zh 光源在光源缓冲区中的字节偏移量。
|
||||||
|
*/
|
||||||
addLight (light: Light, bHDR: boolean, exposure: number, shadowInfo: Shadows | null): number {
|
addLight (light: Light, bHDR: boolean, exposure: number, shadowInfo: Shadows | null): number {
|
||||||
// Already added
|
// Already added
|
||||||
const existingLightID = this.lightIndex.get(light);
|
const existingLightID = this.lightIndex.get(light);
|
||||||
if (existingLightID !== undefined) {
|
if (existingLightID !== undefined) {
|
||||||
return existingLightID;
|
return existingLightID * this.elementSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.lightBuffer) {
|
if (!this.lightBuffer) {
|
||||||
|
|||||||
@@ -258,9 +258,19 @@ export class WebRenderQueueBuilder extends WebSetter implements RenderQueueBuild
|
|||||||
|
|
||||||
addSceneOfCamera (camera: Camera, light: LightInfo, sceneFlags = SceneFlags.NONE, name = 'Camera'): void {
|
addSceneOfCamera (camera: Camera, light: LightInfo, sceneFlags = SceneFlags.NONE, name = 'Camera'): void {
|
||||||
const lightTarget = light.light;
|
const lightTarget = light.light;
|
||||||
this.addScene(camera, sceneFlags, lightTarget);
|
const scene = light.probe?.node?.scene?.renderScene || undefined;
|
||||||
|
this._addScene(camera, sceneFlags, lightTarget, scene, light);
|
||||||
}
|
}
|
||||||
addScene (camera: Camera, sceneFlags = SceneFlags.NONE, light: Light | undefined | null = null, scene: RenderScene | undefined = undefined): SceneBuilder {
|
addScene (camera: Camera, sceneFlags = SceneFlags.NONE, light: Light | undefined | null = null, scene: RenderScene | undefined = undefined): SceneBuilder {
|
||||||
|
return this._addScene(camera, sceneFlags, light, scene);
|
||||||
|
}
|
||||||
|
private _addScene (
|
||||||
|
camera: Camera,
|
||||||
|
sceneFlags: SceneFlags,
|
||||||
|
light: Light | undefined | null,
|
||||||
|
scene: RenderScene | undefined,
|
||||||
|
lightInfo: LightInfo | null = null,
|
||||||
|
): SceneBuilder {
|
||||||
const sceneData = renderGraphPool.createSceneData(
|
const sceneData = renderGraphPool.createSceneData(
|
||||||
scene || camera.scene,
|
scene || camera.scene,
|
||||||
camera,
|
camera,
|
||||||
@@ -268,6 +278,9 @@ export class WebRenderQueueBuilder extends WebSetter implements RenderQueueBuild
|
|||||||
light && !(sceneFlags & SceneFlags.SHADOW_CASTER) ? CullingFlags.CAMERA_FRUSTUM | CullingFlags.LIGHT_BOUNDS : CullingFlags.CAMERA_FRUSTUM,
|
light && !(sceneFlags & SceneFlags.SHADOW_CASTER) ? CullingFlags.CAMERA_FRUSTUM | CullingFlags.LIGHT_BOUNDS : CullingFlags.CAMERA_FRUSTUM,
|
||||||
light,
|
light,
|
||||||
);
|
);
|
||||||
|
if (lightInfo) {
|
||||||
|
sceneData.light.reset(lightInfo.light, lightInfo.level, lightInfo.culledByLight, lightInfo.probe);
|
||||||
|
}
|
||||||
const renderData = renderGraphPool.createRenderData();
|
const renderData = renderGraphPool.createRenderData();
|
||||||
const sceneId = this._renderGraph.addVertex<RenderGraphValue.Scene>(RenderGraphValue.Scene, sceneData, 'Scene', '', renderData, !DEBUG, this._vertID);
|
const sceneId = this._renderGraph.addVertex<RenderGraphValue.Scene>(RenderGraphValue.Scene, sceneData, 'Scene', '', renderData, !DEBUG, this._vertID);
|
||||||
if (!(sceneFlags & SceneFlags.NON_BUILTIN)) {
|
if (!(sceneFlags & SceneFlags.NON_BUILTIN)) {
|
||||||
@@ -1650,13 +1663,16 @@ export class WebPipeline extends WebSetter implements BasicPipeline {
|
|||||||
this._compiler = new Compiler(this, this._renderGraph, this._resourceGraph, this._lg);
|
this._compiler = new Compiler(this, this._renderGraph, this._resourceGraph, this._lg);
|
||||||
}
|
}
|
||||||
this._compiler.compile(this._renderGraph);
|
this._compiler.compile(this._renderGraph);
|
||||||
} else {
|
|
||||||
this._renderGraph.x.forEach((vert) => {
|
|
||||||
if (vert.t === RenderGraphValue.RasterPass) {
|
|
||||||
genHashValue(vert.j as RasterPass);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
this._renderGraph.x.forEach((vert, v) => {
|
||||||
|
if (vert.t !== RenderGraphValue.RasterPass) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (DEBUG && !this._renderGraph!.getValid(v)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
genHashValue(vert.j as RasterPass);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
execute (): void {
|
execute (): void {
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ import { UNIFORM_LIGHTMAP_TEXTURE_BINDING, UNIFORM_REFLECTION_PROBE_BLEND_CUBEMA
|
|||||||
UNIFORM_REFLECTION_PROBE_TEXTURE_BINDING, ENABLE_PROBE_BLEND,
|
UNIFORM_REFLECTION_PROBE_TEXTURE_BINDING, ENABLE_PROBE_BLEND,
|
||||||
IRenderPass,
|
IRenderPass,
|
||||||
getPassPool } from './define';
|
getPassPool } from './define';
|
||||||
import { BufferUsageBit, MemoryUsageBit, Device, Texture, InputAssembler, InputAssemblerInfo,
|
import { BufferUsageBit, MemoryUsageBit, Device, InputAssembler, InputAssemblerInfo,
|
||||||
Attribute, Buffer, BufferInfo, CommandBuffer, Shader, DescriptorSet } from '../gfx';
|
Attribute, Buffer, BufferInfo, CommandBuffer, Shader, DescriptorSet } from '../gfx';
|
||||||
|
import type { Texture } from '../gfx';
|
||||||
import { RecyclePool } from '../core/memop';
|
import { RecyclePool } from '../core/memop';
|
||||||
|
|
||||||
export function instancingCompareFn (l: InstancedBuffer, r: InstancedBuffer): number {
|
export function instancingCompareFn (l: InstancedBuffer, r: InstancedBuffer): number {
|
||||||
@@ -65,6 +66,7 @@ export class InstancedBuffer {
|
|||||||
public sortRender: IRenderPass;
|
public sortRender: IRenderPass;
|
||||||
private declare _passPool: RecyclePool<IRenderPass>;
|
private declare _passPool: RecyclePool<IRenderPass>;
|
||||||
private declare _device: Device;
|
private declare _device: Device;
|
||||||
|
private readonly _instanceMap = new Map<string, IInstancedItem[]>();
|
||||||
constructor (pass: Pass) {
|
constructor (pass: Pass) {
|
||||||
this._device = pass.device;
|
this._device = pass.device;
|
||||||
this.pass = pass;
|
this.pass = pass;
|
||||||
@@ -81,6 +83,7 @@ export class InstancedBuffer {
|
|||||||
});
|
});
|
||||||
this._passPool.reset();
|
this._passPool.reset();
|
||||||
this.instances.length = 0;
|
this.instances.length = 0;
|
||||||
|
this._instanceMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public merge (subModel: SubModel, passIdx: number, shaderImplant: Shader | null = null): void {
|
public merge (subModel: SubModel, passIdx: number, shaderImplant: Shader | null = null): void {
|
||||||
@@ -106,72 +109,109 @@ export class InstancedBuffer {
|
|||||||
this.sortRender.hash = hash;
|
this.sortRender.hash = hash;
|
||||||
this.sortRender.shaderId = shader.typedID;
|
this.sortRender.shaderId = shader.typedID;
|
||||||
this.sortRender.passIdx = passIdx;
|
this.sortRender.passIdx = passIdx;
|
||||||
for (let i = 0; i < this.instances.length; ++i) {
|
|
||||||
const instance = this.instances[i];
|
|
||||||
if (instance.ia.indexBuffer?.objectID !== sourceIA.indexBuffer?.objectID || instance.count >= MAX_CAPACITY) { continue; }
|
|
||||||
|
|
||||||
// check same binding
|
const key = `${sourceIA.indexBuffer?.objectID ?? 0}/${lightingMap.objectID}/${useReflectionProbeType}/`
|
||||||
if (instance.lightingMap.objectID !== lightingMap.objectID) {
|
+ `${reflectionProbeCubemap.objectID}/${reflectionProbePlanarMap.objectID}/`
|
||||||
continue;
|
+ `${ENABLE_PROBE_BLEND ? reflectionProbeBlendCubemap!.objectID : 0}/${stride}`;
|
||||||
|
const mappedInstances = this._instanceMap.get(key);
|
||||||
|
if (mappedInstances) {
|
||||||
|
for (let i = 0; i < mappedInstances.length; ++i) {
|
||||||
|
const instance = mappedInstances[i];
|
||||||
|
if (instance.count >= MAX_CAPACITY) { continue; }
|
||||||
|
this._appendInstance(instance, attrs.buffer, shader, descriptorSet);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance.useReflectionProbeType !== useReflectionProbeType) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (instance.reflectionProbeCubemap.objectID !== reflectionProbeCubemap.objectID) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (instance.reflectionProbePlanarMap.objectID !== reflectionProbePlanarMap.objectID) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (ENABLE_PROBE_BLEND && instance.reflectionProbeBlendCubemap!.objectID !== reflectionProbeBlendCubemap!.objectID) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instance.stride !== stride) {
|
|
||||||
// we allow this considering both baked and non-baked
|
|
||||||
// skinning models may be present in the same buffer
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (instance.count >= instance.capacity) { // resize buffers
|
|
||||||
instance.capacity <<= 1;
|
|
||||||
const newSize = instance.stride * instance.capacity;
|
|
||||||
const oldData = instance.data;
|
|
||||||
instance.data = new Uint8Array(newSize);
|
|
||||||
instance.data.set(oldData);
|
|
||||||
instance.vb.resize(newSize);
|
|
||||||
}
|
|
||||||
instance.shader = shader;
|
|
||||||
instance.descriptorSet = descriptorSet;
|
|
||||||
instance.data.set(attrs.buffer, instance.stride * instance.count++);
|
|
||||||
this.hasPendingModels = true;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new instance
|
this._createInstance(
|
||||||
|
key,
|
||||||
|
sourceIA,
|
||||||
|
attrs.attributes,
|
||||||
|
attrs.buffer,
|
||||||
|
stride,
|
||||||
|
shader,
|
||||||
|
descriptorSet,
|
||||||
|
lightingMap,
|
||||||
|
useReflectionProbeType,
|
||||||
|
reflectionProbeCubemap,
|
||||||
|
reflectionProbePlanarMap,
|
||||||
|
reflectionProbeBlendCubemap,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _appendInstance (instance: IInstancedItem, data: Uint8Array, shader: Shader, descriptorSet: DescriptorSet): void {
|
||||||
|
if (instance.count >= instance.capacity) { // resize buffers
|
||||||
|
instance.capacity = Math.min(instance.capacity << 1, MAX_CAPACITY);
|
||||||
|
const newSize = instance.stride * instance.capacity;
|
||||||
|
const oldData = instance.data;
|
||||||
|
instance.data = new Uint8Array(newSize);
|
||||||
|
instance.data.set(oldData);
|
||||||
|
instance.vb.resize(newSize);
|
||||||
|
}
|
||||||
|
instance.shader = shader;
|
||||||
|
instance.descriptorSet = descriptorSet;
|
||||||
|
instance.data.set(data, instance.stride * instance.count++);
|
||||||
|
this.hasPendingModels = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _createInstance (
|
||||||
|
key: string,
|
||||||
|
sourceIA: InputAssembler,
|
||||||
|
instancedAttributes: Attribute[],
|
||||||
|
instanceData: Uint8Array,
|
||||||
|
stride: number,
|
||||||
|
shader: Shader,
|
||||||
|
descriptorSet: DescriptorSet,
|
||||||
|
lightingMap: Texture,
|
||||||
|
useReflectionProbeType: number,
|
||||||
|
reflectionProbeCubemap: Texture,
|
||||||
|
reflectionProbePlanarMap: Texture,
|
||||||
|
reflectionProbeBlendCubemap: Texture | null,
|
||||||
|
): void {
|
||||||
|
const newSize = stride * INITIAL_CAPACITY;
|
||||||
const vb = this._device.createBuffer(new BufferInfo(
|
const vb = this._device.createBuffer(new BufferInfo(
|
||||||
BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST,
|
BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST,
|
||||||
MemoryUsageBit.HOST | MemoryUsageBit.DEVICE,
|
MemoryUsageBit.HOST | MemoryUsageBit.DEVICE,
|
||||||
stride * INITIAL_CAPACITY,
|
newSize,
|
||||||
stride,
|
stride,
|
||||||
));
|
));
|
||||||
const data = new Uint8Array(stride * INITIAL_CAPACITY);
|
const data = new Uint8Array(newSize);
|
||||||
const vertexBuffers = sourceIA.vertexBuffers.slice();
|
const vertexBuffers = sourceIA.vertexBuffers.slice();
|
||||||
const attributes = sourceIA.attributes.slice();
|
const attributes = sourceIA.attributes.slice();
|
||||||
const indexBuffer = sourceIA.indexBuffer;
|
const indexBuffer = sourceIA.indexBuffer;
|
||||||
|
|
||||||
for (let i = 0; i < attrs.attributes.length; i++) {
|
for (let i = 0; i < instancedAttributes.length; i++) {
|
||||||
const attr = attrs.attributes[i];
|
const attr = instancedAttributes[i];
|
||||||
const newAttr = new Attribute(attr.name, attr.format, attr.isNormalized, vertexBuffers.length, true);
|
const newAttr = new Attribute(attr.name, attr.format, attr.isNormalized, vertexBuffers.length, true);
|
||||||
attributes.push(newAttr);
|
attributes.push(newAttr);
|
||||||
}
|
}
|
||||||
data.set(attrs.buffer);
|
data.set(instanceData);
|
||||||
|
|
||||||
vertexBuffers.push(vb);
|
vertexBuffers.push(vb);
|
||||||
const iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer);
|
const iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer);
|
||||||
const ia = this._device.createInputAssembler(iaInfo);
|
const ia = this._device.createInputAssembler(iaInfo);
|
||||||
// eslint-disable-next-line max-len
|
const instance = {
|
||||||
this.instances.push({ count: 1, capacity: INITIAL_CAPACITY, vb, data, ia, stride, shader, descriptorSet, lightingMap, reflectionProbeCubemap, reflectionProbePlanarMap, useReflectionProbeType, reflectionProbeBlendCubemap });
|
count: 1,
|
||||||
|
capacity: INITIAL_CAPACITY,
|
||||||
|
vb,
|
||||||
|
data,
|
||||||
|
ia,
|
||||||
|
stride,
|
||||||
|
shader,
|
||||||
|
descriptorSet,
|
||||||
|
lightingMap,
|
||||||
|
reflectionProbeCubemap,
|
||||||
|
reflectionProbePlanarMap,
|
||||||
|
useReflectionProbeType,
|
||||||
|
reflectionProbeBlendCubemap,
|
||||||
|
} as IInstancedItem;
|
||||||
|
this.instances.push(instance);
|
||||||
|
let mappedInstances = this._instanceMap.get(key);
|
||||||
|
if (!mappedInstances) {
|
||||||
|
mappedInstances = [];
|
||||||
|
this._instanceMap.set(key, mappedInstances);
|
||||||
|
}
|
||||||
|
mappedInstances.push(instance);
|
||||||
this.hasPendingModels = true;
|
this.hasPendingModels = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +220,7 @@ export class InstancedBuffer {
|
|||||||
const instance = this.instances[i];
|
const instance = this.instances[i];
|
||||||
if (!instance.count) { continue; }
|
if (!instance.count) { continue; }
|
||||||
instance.ia.instanceCount = instance.count;
|
instance.ia.instanceCount = instance.count;
|
||||||
cmdBuff.updateBuffer(instance.vb, instance.data);
|
cmdBuff.updateBuffer(instance.vb, instance.data.buffer as ArrayBuffer, instance.count * instance.stride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import { PipelineStateManager } from './pipeline-state-manager';
|
|||||||
import { Model, Camera, SubModel } from '../render-scene/scene';
|
import { Model, Camera, SubModel } from '../render-scene/scene';
|
||||||
import { RenderInstancedQueue } from './render-instanced-queue';
|
import { RenderInstancedQueue } from './render-instanced-queue';
|
||||||
import { ShadowType } from '../render-scene/scene/shadows';
|
import { ShadowType } from '../render-scene/scene/shadows';
|
||||||
import { Layers } from '../scene-graph/layers';
|
|
||||||
import { PipelineRuntime } from './custom/pipeline';
|
import { PipelineRuntime } from './custom/pipeline';
|
||||||
import { BatchingSchemes, Pass } from '../render-scene/core/pass';
|
import { BatchingSchemes, Pass } from '../render-scene/core/pass';
|
||||||
import { getPhaseID } from './pass-phase';
|
import { getPhaseID } from './pass-phase';
|
||||||
@@ -83,18 +82,16 @@ export class PlanarShadowQueue {
|
|||||||
|
|
||||||
const scene = camera.scene!;
|
const scene = camera.scene!;
|
||||||
const frustum = camera.frustum;
|
const frustum = camera.frustum;
|
||||||
const shadowVisible = (camera.visibility & Layers.BitMask.DEFAULT) !== 0;
|
const shadowVisible = camera.visibility !== 0;
|
||||||
if (!scene.mainLight || !shadowVisible) { return; }
|
if (!scene.mainLight || !shadowVisible) { return; }
|
||||||
|
|
||||||
const models = scene.models;
|
const models = scene.models;
|
||||||
const visibility = camera.visibility;
|
|
||||||
for (let i = 0; i < models.length; i++) {
|
for (let i = 0; i < models.length; i++) {
|
||||||
const model = models[i];
|
const model = models[i];
|
||||||
if (scene.isCulledByLod(camera, model)) {
|
if (scene.isCulledByLod(camera, model)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (model.enabled && model.node && model.castShadow
|
if (model.enabled && model.node && model.castShadow) {
|
||||||
&& (model.node && ((visibility & model.node.layer) === model.node.layer))) {
|
|
||||||
this._castModels.push(model);
|
this._castModels.push(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { IRenderFlowInfo, RenderFlow } from '../render-flow';
|
|||||||
import { ReflectionProbeStage } from './reflection-probe-stage';
|
import { ReflectionProbeStage } from './reflection-probe-stage';
|
||||||
import { RenderFlowTag } from '../pipeline-serialization';
|
import { RenderFlowTag } from '../pipeline-serialization';
|
||||||
import { RenderPipeline } from '../render-pipeline';
|
import { RenderPipeline } from '../render-pipeline';
|
||||||
import { Camera } from '../../render-scene/scene/camera';
|
import { Camera, CameraUsage } from '../../render-scene/scene/camera';
|
||||||
import { ProbeType, ReflectionProbe } from '../../render-scene/scene/reflection-probe';
|
import { ProbeType, ReflectionProbe } from '../../render-scene/scene/reflection-probe';
|
||||||
import { cclegacy } from '../../core';
|
import { cclegacy } from '../../core';
|
||||||
|
|
||||||
@@ -65,7 +65,13 @@ export class ReflectionProbeFlow extends RenderFlow {
|
|||||||
const probes = cclegacy.internal.reflectionProbeManager.getProbes() as ReflectionProbe[];
|
const probes = cclegacy.internal.reflectionProbeManager.getProbes() as ReflectionProbe[];
|
||||||
for (let i = 0; i < probes.length; i++) {
|
for (let i = 0; i < probes.length; i++) {
|
||||||
if (probes[i].needRender) {
|
if (probes[i].needRender) {
|
||||||
if (EDITOR || probes[i].probeType === ProbeType.PLANAR) {
|
if (probes[i].probeType === ProbeType.PLANAR) {
|
||||||
|
let reflectionCamera: Camera | undefined;
|
||||||
|
if (EDITOR && camera.cameraUsage === CameraUsage.PREVIEW) {
|
||||||
|
reflectionCamera = probes[i].renderPreviewPlanarReflection(camera);
|
||||||
|
}
|
||||||
|
this._renderStage(camera, probes[i], reflectionCamera);
|
||||||
|
} else if (EDITOR) {
|
||||||
this._renderStage(camera, probes[i]);
|
this._renderStage(camera, probes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,12 +81,12 @@ export class ReflectionProbeFlow extends RenderFlow {
|
|||||||
public destroy (): void {
|
public destroy (): void {
|
||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
private _renderStage (camera: Camera, probe: ReflectionProbe): void {
|
private _renderStage (camera: Camera, probe: ReflectionProbe, reflectionCamera?: Camera): void {
|
||||||
for (let i = 0; i < this._stages.length; i++) {
|
for (let i = 0; i < this._stages.length; i++) {
|
||||||
const probeStage = this._stages[i] as ReflectionProbeStage;
|
const probeStage = this._stages[i] as ReflectionProbeStage;
|
||||||
if (probe.probeType === ProbeType.PLANAR) {
|
if (probe.probeType === ProbeType.PLANAR) {
|
||||||
cclegacy.internal.reflectionProbeManager.updatePlanarMap(probe, null);
|
cclegacy.internal.reflectionProbeManager.updatePlanarMap(probe, null);
|
||||||
probeStage.setUsageInfo(probe, probe.realtimePlanarTexture!.window!.framebuffer);
|
probeStage.setUsageInfo(probe, probe.realtimePlanarTexture!.window!.framebuffer, reflectionCamera);
|
||||||
probeStage.render(camera);
|
probeStage.render(camera);
|
||||||
cclegacy.internal.reflectionProbeManager.updatePlanarMap(probe, probe.realtimePlanarTexture!.getGFXTexture());
|
cclegacy.internal.reflectionProbeManager.updatePlanarMap(probe, probe.realtimePlanarTexture!.getGFXTexture());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ export class ReflectionProbeStage extends RenderStage {
|
|||||||
private _frameBuffer: Framebuffer | null = null;
|
private _frameBuffer: Framebuffer | null = null;
|
||||||
private _renderArea = new Rect();
|
private _renderArea = new Rect();
|
||||||
private _probe: ReflectionProbe | null = null;
|
private _probe: ReflectionProbe | null = null;
|
||||||
|
private _reflectionCamera: Camera | null = null;
|
||||||
private _probeRenderQueue!: RenderReflectionProbeQueue;
|
private _probeRenderQueue!: RenderReflectionProbeQueue;
|
||||||
private _rgbeColor = new Vec3();
|
private _rgbeColor = new Vec3();
|
||||||
|
|
||||||
@@ -68,9 +69,10 @@ export class ReflectionProbeStage extends RenderStage {
|
|||||||
* @param probe
|
* @param probe
|
||||||
* @param frameBuffer
|
* @param frameBuffer
|
||||||
*/
|
*/
|
||||||
public setUsageInfo (probe: ReflectionProbe, frameBuffer: Framebuffer): void {
|
public setUsageInfo (probe: ReflectionProbe, frameBuffer: Framebuffer, reflectionCamera?: Camera): void {
|
||||||
this._probe = probe;
|
this._probe = probe;
|
||||||
this._frameBuffer = frameBuffer;
|
this._frameBuffer = frameBuffer;
|
||||||
|
this._reflectionCamera = reflectionCamera ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public destroy (): void {
|
public destroy (): void {
|
||||||
@@ -108,8 +110,9 @@ export class ReflectionProbeStage extends RenderStage {
|
|||||||
public render (camera: Camera): void {
|
public render (camera: Camera): void {
|
||||||
const pipeline = this._pipeline;
|
const pipeline = this._pipeline;
|
||||||
const cmdBuff = pipeline.commandBuffers[0];
|
const cmdBuff = pipeline.commandBuffers[0];
|
||||||
this._probeRenderQueue.gatherRenderObjects(this._probe!, camera, cmdBuff);
|
const probeCamera = this._reflectionCamera ?? this._probe!.camera;
|
||||||
pipeline.pipelineUBO.updateCameraUBO(this._probe!.camera);
|
this._probeRenderQueue.gatherRenderObjects(this._probe!, camera, cmdBuff, probeCamera);
|
||||||
|
pipeline.pipelineUBO.updateCameraUBO(probeCamera);
|
||||||
|
|
||||||
this._renderArea.x = 0;
|
this._renderArea.x = 0;
|
||||||
this._renderArea.y = 0;
|
this._renderArea.y = 0;
|
||||||
@@ -118,10 +121,10 @@ export class ReflectionProbeStage extends RenderStage {
|
|||||||
|
|
||||||
const renderPass = this._frameBuffer!.renderPass;
|
const renderPass = this._frameBuffer!.renderPass;
|
||||||
|
|
||||||
if (this._probe!.camera.clearFlag & ClearFlagBit.COLOR) {
|
if (probeCamera.clearFlag & ClearFlagBit.COLOR) {
|
||||||
this._rgbeColor.x = this._probe!.camera.clearColor.x;
|
this._rgbeColor.x = probeCamera.clearColor.x;
|
||||||
this._rgbeColor.y = this._probe!.camera.clearColor.y;
|
this._rgbeColor.y = probeCamera.clearColor.y;
|
||||||
this._rgbeColor.z = this._probe!.camera.clearColor.z;
|
this._rgbeColor.z = probeCamera.clearColor.z;
|
||||||
const rgbe = packRGBE(this._rgbeColor);
|
const rgbe = packRGBE(this._rgbeColor);
|
||||||
colors[0].x = rgbe.x;
|
colors[0].x = rgbe.x;
|
||||||
colors[0].y = rgbe.y;
|
colors[0].y = rgbe.y;
|
||||||
@@ -134,8 +137,8 @@ export class ReflectionProbeStage extends RenderStage {
|
|||||||
this._frameBuffer!,
|
this._frameBuffer!,
|
||||||
this._renderArea,
|
this._renderArea,
|
||||||
colors,
|
colors,
|
||||||
this._probe!.camera.clearDepth,
|
probeCamera.clearDepth,
|
||||||
this._probe!.camera.clearStencil,
|
probeCamera.clearStencil,
|
||||||
);
|
);
|
||||||
cmdBuff.bindDescriptorSet(SetIndex.GLOBAL, pipeline.descriptorSet);
|
cmdBuff.bindDescriptorSet(SetIndex.GLOBAL, pipeline.descriptorSet);
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export class RenderAdditiveLightQueue {
|
|||||||
private declare _lightBuffer: Buffer;
|
private declare _lightBuffer: Buffer;
|
||||||
private declare _firstLightBufferView: Buffer;
|
private declare _firstLightBufferView: Buffer;
|
||||||
private declare _lightBufferData: Float32Array;
|
private declare _lightBufferData: Float32Array;
|
||||||
private _instancedQueues: RenderInstancedQueue[] = [];
|
private _instancedQueues: (RenderInstancedQueue | undefined)[] = [];
|
||||||
private _lightMeterScale = 10000.0;
|
private _lightMeterScale = 10000.0;
|
||||||
|
|
||||||
constructor (pipeline: PipelineRuntime) {
|
constructor (pipeline: PipelineRuntime) {
|
||||||
@@ -151,7 +151,9 @@ export class RenderAdditiveLightQueue {
|
|||||||
|
|
||||||
public clear (): void {
|
public clear (): void {
|
||||||
this._instancedQueues.forEach((instancedQueue) => {
|
this._instancedQueues.forEach((instancedQueue) => {
|
||||||
instancedQueue.clear();
|
if (instancedQueue) {
|
||||||
|
instancedQueue.clear();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this._instancedQueues.length = 0;
|
this._instancedQueues.length = 0;
|
||||||
|
|
||||||
@@ -196,7 +198,7 @@ export class RenderAdditiveLightQueue {
|
|||||||
|
|
||||||
this._lightCulling(model, validPunctualLights);
|
this._lightCulling(model, validPunctualLights);
|
||||||
|
|
||||||
if (!_lightIndices.length && validPunctualLights.length > 0) { continue; }
|
if (!_lightIndices.length) { continue; }
|
||||||
|
|
||||||
for (let j = 0; j < subModels.length; j++) {
|
for (let j = 0; j < subModels.length; j++) {
|
||||||
const lightPassIdx = _lightPassIndices[j];
|
const lightPassIdx = _lightPassIndices[j];
|
||||||
@@ -219,15 +221,14 @@ export class RenderAdditiveLightQueue {
|
|||||||
public gatherLightPasses (camera: Camera, cmdBuff: CommandBuffer, passLayout = 'default'): void {
|
public gatherLightPasses (camera: Camera, cmdBuff: CommandBuffer, passLayout = 'default'): void {
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
||||||
const validPunctualLights = this._pipeline.pipelineSceneData.validPunctualLights;
|
|
||||||
if (!validPunctualLights.length) {
|
|
||||||
this._bindForwardAddLight(validPunctualLights, passLayout);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._updateUBOs(camera, cmdBuff);
|
this._updateUBOs(camera, cmdBuff);
|
||||||
this._updateLightDescriptorSet(camera, cmdBuff);
|
this._updateLightDescriptorSet(camera, cmdBuff);
|
||||||
|
|
||||||
|
const validPunctualLights = this._pipeline.pipelineSceneData.validPunctualLights;
|
||||||
|
if (!validPunctualLights.length) { return; }
|
||||||
|
|
||||||
this._bindForwardAddLight(validPunctualLights, passLayout);
|
this._bindForwardAddLight(validPunctualLights, passLayout);
|
||||||
|
|
||||||
// only for instanced and batched, no light culling applied
|
// only for instanced and batched, no light culling applied
|
||||||
for (let l = 0; l < validPunctualLights.length; l++) {
|
for (let l = 0; l < validPunctualLights.length; l++) {
|
||||||
const light = validPunctualLights[l];
|
const light = validPunctualLights[l];
|
||||||
@@ -236,17 +237,21 @@ export class RenderAdditiveLightQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._instancedQueues.forEach((instancedQueue) => {
|
this._instancedQueues.forEach((instancedQueue) => {
|
||||||
instancedQueue.uploadBuffers(cmdBuff);
|
if (instancedQueue) {
|
||||||
|
instancedQueue.uploadBuffers(cmdBuff);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public recordCommandBuffer (device: Device, renderPass: RenderPass, cmdBuff: CommandBuffer): void {
|
public recordCommandBuffer (device: Device, renderPass: RenderPass, cmdBuff: CommandBuffer): void {
|
||||||
const globalDSManager: GlobalDSManager = this._pipeline.globalDSManager;
|
const globalDSManager: GlobalDSManager = this._pipeline.globalDSManager;
|
||||||
for (let j = 0; j < this._instancedQueues.length; ++j) {
|
for (let j = 0; j < this._instancedQueues.length; ++j) {
|
||||||
|
const queue = this._instancedQueues[j];
|
||||||
|
if (!queue) { continue; }
|
||||||
const light = this._instancedLightPassPool.lights[j];
|
const light = this._instancedLightPassPool.lights[j];
|
||||||
_dynamicOffsets[0] = this._instancedLightPassPool.dynamicOffsets[j];
|
_dynamicOffsets[0] = this._instancedLightPassPool.dynamicOffsets[j];
|
||||||
const descriptorSet = globalDSManager.getOrCreateDescriptorSet(light);
|
const descriptorSet = globalDSManager.getOrCreateDescriptorSet(light);
|
||||||
this._instancedQueues[j].recordCommandBuffer(device, renderPass, cmdBuff, descriptorSet, _dynamicOffsets);
|
queue.recordCommandBuffer(device, renderPass, cmdBuff, descriptorSet, _dynamicOffsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < this._lightPasses.length; i++) {
|
for (let i = 0; i < this._lightPasses.length; i++) {
|
||||||
@@ -315,14 +320,18 @@ export class RenderAdditiveLightQueue {
|
|||||||
const lightIdx = _lightIndices[l];
|
const lightIdx = _lightIndices[l];
|
||||||
const light = validPunctualLights[lightIdx];
|
const light = validPunctualLights[lightIdx];
|
||||||
const visibility = light.visibility;
|
const visibility = light.visibility;
|
||||||
if (((visibility & model.node.layer) === model.node.layer)) {
|
if (((visibility & model.node.layer) === model.node.layer)
|
||||||
|
|| (visibility & model.visFlags)) {
|
||||||
switch (batchingScheme) {
|
switch (batchingScheme) {
|
||||||
case BatchingSchemes.INSTANCING: {
|
case BatchingSchemes.INSTANCING: {
|
||||||
const buffer = pass.getInstancedBuffer(l);
|
const buffer = pass.getInstancedBuffer(lightIdx);
|
||||||
buffer.merge(subModel, lightPassIdx);
|
buffer.merge(subModel, lightPassIdx);
|
||||||
buffer.dynamicOffsets[0] = this._lightBufferStride;
|
buffer.dynamicOffsets[0] = this._lightBufferStride * lightIdx;
|
||||||
if (!this._instancedQueues[l]) { this._instancedQueues[l] = new RenderInstancedQueue(); }
|
if (this._instancedQueues.length <= lightIdx || !this._instancedQueues[lightIdx]) {
|
||||||
this._instancedQueues[l].queue.add(buffer);
|
this._instancedQueues.length = lightIdx + 1;
|
||||||
|
this._instancedQueues[lightIdx] = new RenderInstancedQueue();
|
||||||
|
}
|
||||||
|
this._instancedQueues[lightIdx]!.queue.add(buffer);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
lp!.lights.push(light);
|
lp!.lights.push(light);
|
||||||
@@ -370,9 +379,6 @@ export class RenderAdditiveLightQueue {
|
|||||||
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 1] = packing;
|
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 1] = packing;
|
||||||
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 2] = 0.0;
|
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 2] = 0.0;
|
||||||
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 3] = 0.0;
|
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 3] = 0.0;
|
||||||
|
|
||||||
// Reserve sphere light shadow interface
|
|
||||||
Color.toArray(this._shadowUBO, shadowInfo.shadowColor, UBOShadowEnum.SHADOW_COLOR_OFFSET);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LightType.SPOT: {
|
case LightType.SPOT: {
|
||||||
@@ -437,8 +443,6 @@ export class RenderAdditiveLightQueue {
|
|||||||
this._shadowUBO[UBOShadowEnum.SHADOW_PROJ_INFO_OFFSET + 2] = 1.0 / matShadowProj.m00;
|
this._shadowUBO[UBOShadowEnum.SHADOW_PROJ_INFO_OFFSET + 2] = 1.0 / matShadowProj.m00;
|
||||||
this._shadowUBO[UBOShadowEnum.SHADOW_PROJ_INFO_OFFSET + 3] = 1.0 / matShadowProj.m05;
|
this._shadowUBO[UBOShadowEnum.SHADOW_PROJ_INFO_OFFSET + 3] = 1.0 / matShadowProj.m05;
|
||||||
|
|
||||||
Color.toArray(this._shadowUBO, shadowInfo.shadowColor, UBOShadowEnum.SHADOW_COLOR_OFFSET);
|
|
||||||
|
|
||||||
// Spot light sampler binding
|
// Spot light sampler binding
|
||||||
if (shadowFrameBufferMap.has(light)) {
|
if (shadowFrameBufferMap.has(light)) {
|
||||||
const texture = shadowFrameBufferMap.get(light)?.colorTextures[0];
|
const texture = shadowFrameBufferMap.get(light)?.colorTextures[0];
|
||||||
@@ -463,15 +467,15 @@ export class RenderAdditiveLightQueue {
|
|||||||
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 1] = packing;
|
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 1] = packing;
|
||||||
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 2] = 0.0;
|
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 2] = 0.0;
|
||||||
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 3] = 0.0;
|
this._shadowUBO[UBOShadowEnum.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 3] = 0.0;
|
||||||
|
|
||||||
// Reserve point light shadow interface
|
|
||||||
Color.toArray(this._shadowUBO, shadowInfo.shadowColor, UBOShadowEnum.SHADOW_COLOR_OFFSET);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
globalDSManager.update();
|
Color.toArray(this._shadowUBO, shadowInfo.shadowColor, UBOShadowEnum.SHADOW_COLOR_OFFSET);
|
||||||
cmdBuff.updateBuffer(descriptorSet.getBuffer(UBOShadow.BINDING)!, this._shadowUBO);
|
|
||||||
|
descriptorSet.update();
|
||||||
|
|
||||||
|
cmdBuff.updateBuffer(descriptorSet.getBuffer(UBOShadow.BINDING)!, this._shadowUBO.buffer, this._shadowUBO.byteLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,6 +631,6 @@ export class RenderAdditiveLightQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdBuff.updateBuffer(this._lightBuffer, this._lightBufferData);
|
cmdBuff.updateBuffer(this._lightBuffer, this._lightBufferData.buffer as ArrayBuffer, this._lightBufferData.byteLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,13 +79,14 @@ export class RenderReflectionProbeQueue {
|
|||||||
public constructor (pipeline: PipelineRuntime) {
|
public constructor (pipeline: PipelineRuntime) {
|
||||||
this._pipeline = pipeline;
|
this._pipeline = pipeline;
|
||||||
}
|
}
|
||||||
public gatherRenderObjects (probe: ReflectionProbe, camera: Camera, cmdBuff: CommandBuffer): void {
|
public gatherRenderObjects (probe: ReflectionProbe, camera: Camera, cmdBuff: CommandBuffer, reflectionCamera?: Camera): void {
|
||||||
this.clear();
|
this.clear();
|
||||||
const scene = camera.scene!;
|
const scene = camera.scene!;
|
||||||
const sceneData = this._pipeline.pipelineSceneData;
|
const sceneData = this._pipeline.pipelineSceneData;
|
||||||
const skybox = sceneData.skybox;
|
const skybox = sceneData.skybox;
|
||||||
|
const probeCamera = reflectionCamera ?? probe.camera;
|
||||||
|
|
||||||
if (skybox.enabled && skybox.model && (probe.camera.clearFlag & SkyBoxFlagValue.VALUE)) {
|
if (skybox.enabled && skybox.model && (probeCamera.clearFlag & SkyBoxFlagValue.VALUE)) {
|
||||||
this.add(skybox.model);
|
this.add(skybox.model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ export class RenderReflectionProbeQueue {
|
|||||||
if (geometry.intersect.aabbWithAABB(model.worldBounds, probe.boundingBox!)) {
|
if (geometry.intersect.aabbWithAABB(model.worldBounds, probe.boundingBox!)) {
|
||||||
this.add(model);
|
this.add(model);
|
||||||
}
|
}
|
||||||
} else if (geometry.intersect.aabbFrustum(model.worldBounds, probe.camera.frustum)) {
|
} else if (geometry.intersect.aabbFrustum(model.worldBounds, probeCamera.frustum)) {
|
||||||
this.add(model);
|
this.add(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,8 +195,8 @@ export function sceneCulling (sceneData: PipelineSceneData, pipelineUBO: Pipelin
|
|||||||
csmLayerObjects.push(getRenderObject(model, camera));
|
csmLayerObjects.push(getRenderObject(model, camera));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.node && ((visibility & model.node.layer) === model.node.layer)
|
if ((model.node && ((visibility & model.node.layer) === model.node.layer))
|
||||||
|| (visibility & model.visFlags)) {
|
|| (visibility & model.visFlags)) {
|
||||||
// frustum culling
|
// frustum culling
|
||||||
if (model.worldBounds && !geometry.intersect.aabbFrustum(model.worldBounds, camera.frustum)) {
|
if (model.worldBounds && !geometry.intersect.aabbFrustum(model.worldBounds, camera.frustum)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
import { cclegacy } from './core/global-exports';
|
import { cclegacy } from './core/global-exports';
|
||||||
import { DataPoolManager } from './3d/skeletal-animation/data-pool-manager';
|
import { DataPoolManager } from './3d/skeletal-animation/data-pool-manager';
|
||||||
import { Device, deviceManager } from './gfx';
|
import { Device, deviceManager } from './gfx';
|
||||||
import { settings, Settings, warnID, Pool, macro, log } from './core';
|
import { settings, Settings, warnID, Pool, macro, log, debug } from './core';
|
||||||
import { PipelineEventProcessor } from './rendering/pipeline-event';
|
import { PipelineEventProcessor } from './rendering/pipeline-event';
|
||||||
import type { Root as JsbRoot } from './root';
|
import type { Root as JsbRoot } from './root';
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ rootProto.setRenderPipeline = function (customPipeline: boolean) {
|
|||||||
if (customPipeline) {
|
if (customPipeline) {
|
||||||
cclegacy.rendering.createCustomPipeline();
|
cclegacy.rendering.createCustomPipeline();
|
||||||
ppl = oldSetPipeline.call(this, null);
|
ppl = oldSetPipeline.call(this, null);
|
||||||
log(`Using custom pipeline: ${macro.CUSTOM_PIPELINE_NAME}`);
|
debug(`Using custom pipeline: ${macro.CUSTOM_PIPELINE_NAME}`);
|
||||||
} else {
|
} else {
|
||||||
// pipeline should not be created in C++, ._ctor need to be triggered
|
// pipeline should not be created in C++, ._ctor need to be triggered
|
||||||
if (cclegacy.legacy_rendering) {
|
if (cclegacy.legacy_rendering) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { USE_XR } from 'internal:constants';
|
import { USE_XR } from 'internal:constants';
|
||||||
import { Pool, cclegacy, warnID, settings, macro, log, errorID, SettingsCategory } from './core';
|
import { Pool, cclegacy, warnID, settings, macro, log, errorID, SettingsCategory, debug } from './core';
|
||||||
import { DebugView } from './rendering/debug-view';
|
import { DebugView } from './rendering/debug-view';
|
||||||
import { Camera, CameraType, Light, Model, TrackingType } from './render-scene/scene';
|
import { Camera, CameraType, Light, Model, TrackingType } from './render-scene/scene';
|
||||||
import type { DataPoolManager } from './3d/skeletal-animation/data-pool-manager';
|
import type { DataPoolManager } from './3d/skeletal-animation/data-pool-manager';
|
||||||
@@ -380,11 +380,11 @@ export class Root {
|
|||||||
isCreateDefaultPipeline = true;
|
isCreateDefaultPipeline = true;
|
||||||
this._pipeline = this._customPipeline!;
|
this._pipeline = this._customPipeline!;
|
||||||
// Use default _pipelineEvent
|
// Use default _pipelineEvent
|
||||||
log(`Using custom pipeline: ${macro.CUSTOM_PIPELINE_NAME}`);
|
debug(`Using custom pipeline: ${macro.CUSTOM_PIPELINE_NAME}`);
|
||||||
} else {
|
} else {
|
||||||
const rppl: (PipelineRuntime & IPipelineEvent) = legacy_rendering.createDefaultPipeline();
|
const rppl: (PipelineRuntime & IPipelineEvent) = legacy_rendering.createDefaultPipeline();
|
||||||
isCreateDefaultPipeline = true;
|
isCreateDefaultPipeline = true;
|
||||||
log(`Using legacy pipeline`);
|
debug(`Using legacy pipeline`);
|
||||||
|
|
||||||
this._classicPipeline = rppl!;
|
this._classicPipeline = rppl!;
|
||||||
this._pipeline = this._classicPipeline;
|
this._pipeline = this._classicPipeline;
|
||||||
|
|||||||
@@ -33,16 +33,16 @@ const MAGIC = 0x4E4F4343;
|
|||||||
const CHUNK_ALIGN_AS = 8;
|
const CHUNK_ALIGN_AS = 8;
|
||||||
|
|
||||||
export class CCON {
|
export class CCON {
|
||||||
constructor (document: unknown, chunks: Uint8Array[]) {
|
constructor(document: unknown, chunks: Uint8Array[]) {
|
||||||
this._document = document;
|
this._document = document;
|
||||||
this._chunks = chunks;
|
this._chunks = chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
get document (): unknown {
|
get document(): unknown {
|
||||||
return this._document;
|
return this._document;
|
||||||
}
|
}
|
||||||
|
|
||||||
get chunks (): Uint8Array[] {
|
get chunks(): Uint8Array[] {
|
||||||
return this._chunks;
|
return this._chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ export class CCON {
|
|||||||
private declare _chunks: Uint8Array[];
|
private declare _chunks: Uint8Array[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function encodeCCONBinary (ccon: CCON): Uint8Array {
|
export function encodeCCONBinary(ccon: CCON): Uint8Array {
|
||||||
const { document, chunks } = ccon;
|
const { document, chunks } = ccon;
|
||||||
|
|
||||||
const jsonBytes = new Uint8Array(notepackEncode(document));
|
const jsonBytes = new Uint8Array(notepackEncode(document));
|
||||||
@@ -75,7 +75,7 @@ export function encodeCCONBinary (ccon: CCON): Uint8Array {
|
|||||||
headerView.setUint32(8, ccobBuilder.byteLength, true);
|
headerView.setUint32(8, ccobBuilder.byteLength, true);
|
||||||
return ccobBuilder.get();
|
return ccobBuilder.get();
|
||||||
|
|
||||||
function uint32Bytes (value: number): ArrayBufferView {
|
function uint32Bytes(value: number): ArrayBufferView {
|
||||||
const bytes = new ArrayBuffer(4);
|
const bytes = new ArrayBuffer(4);
|
||||||
const view = new DataView(bytes);
|
const view = new DataView(bytes);
|
||||||
view.setUint32(0, value, true);
|
view.setUint32(0, value, true);
|
||||||
@@ -83,7 +83,7 @@ export function encodeCCONBinary (ccon: CCON): Uint8Array {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function decodeCCONBinary (bytes: Uint8Array): CCON {
|
export function decodeCCONBinary(bytes: Uint8Array): CCON {
|
||||||
if (bytes.length < 16) {
|
if (bytes.length < 16) {
|
||||||
throw new InvalidCCONError(getError(13102));
|
throw new InvalidCCONError(getError(13102));
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ interface BufferConstructor {
|
|||||||
from(buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): Buffer;
|
from(buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function decodeJson (data: Uint8Array): string {
|
function decodeJson(data: Uint8Array): string {
|
||||||
if (typeof TextDecoder !== 'undefined') {
|
if (typeof TextDecoder !== 'undefined') {
|
||||||
return new TextDecoder().decode(data);
|
return new TextDecoder().decode(data);
|
||||||
} else if ('Buffer' in globalThis) {
|
} else if ('Buffer' in globalThis) {
|
||||||
@@ -177,13 +177,13 @@ export class BufferBuilder {
|
|||||||
private _viewOrPaddings: (ArrayBufferView | number)[] = [];
|
private _viewOrPaddings: (ArrayBufferView | number)[] = [];
|
||||||
private _length = 0;
|
private _length = 0;
|
||||||
|
|
||||||
constructor () {}
|
constructor() { }
|
||||||
|
|
||||||
get byteLength (): number {
|
get byteLength(): number {
|
||||||
return this._length;
|
return this._length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public alignAs (align: number): number {
|
public alignAs(align: number): number {
|
||||||
if (align !== 0) {
|
if (align !== 0) {
|
||||||
const remainder = this._length % align;
|
const remainder = this._length % align;
|
||||||
if (remainder !== 0) {
|
if (remainder !== 0) {
|
||||||
@@ -196,14 +196,14 @@ export class BufferBuilder {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public append (view: ArrayBufferView): number {
|
public append(view: ArrayBufferView): number {
|
||||||
const result = this._length;
|
const result = this._length;
|
||||||
this._viewOrPaddings.push(view);
|
this._viewOrPaddings.push(view);
|
||||||
this._length += view.byteLength;
|
this._length += view.byteLength;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get (): Uint8Array {
|
public get(): Uint8Array {
|
||||||
const result = new Uint8Array(this._length);
|
const result = new Uint8Array(this._length);
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
this._viewOrPaddings.forEach((viewOrPadding) => {
|
this._viewOrPaddings.forEach((viewOrPadding) => {
|
||||||
@@ -219,4 +219,6 @@ export class BufferBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cclegacy.internal.decodeCCONBinary = decodeCCONBinary;
|
cclegacy.internal.decodeCCONBinary = decodeCCONBinary;
|
||||||
|
cclegacy.internal.encodeCCONBinary = encodeCCONBinary;
|
||||||
cclegacy.internal.CCON = CCON;
|
cclegacy.internal.CCON = CCON;
|
||||||
|
cclegacy.internal.BufferBuilder = BufferBuilder;
|
||||||
|
|||||||
@@ -42,6 +42,24 @@ declare namespace spine {
|
|||||||
delete();
|
delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
class SPVectorPhysicsConstraintPtr {
|
||||||
|
size(): number;
|
||||||
|
get(index: number): PhysicsConstraint;
|
||||||
|
delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
class SPVectorPhysicsConstraintDataPtr {
|
||||||
|
size(): number;
|
||||||
|
get(index: number): PhysicsConstraintData;
|
||||||
|
delete();
|
||||||
|
}
|
||||||
|
|
||||||
class Animation {
|
class Animation {
|
||||||
constructor(name: string, timelines: Array<Timeline>, duration: number);
|
constructor(name: string, timelines: Array<Timeline>, duration: number);
|
||||||
duration: number;
|
duration: number;
|
||||||
@@ -708,6 +726,10 @@ declare namespace spine {
|
|||||||
ikConstraints: Array<IkConstraint>;
|
ikConstraints: Array<IkConstraint>;
|
||||||
transformConstraints: Array<TransformConstraint>;
|
transformConstraints: Array<TransformConstraint>;
|
||||||
pathConstraints: Array<PathConstraint>;
|
pathConstraints: Array<PathConstraint>;
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
physicsConstraints: Array<PhysicsConstraint>;
|
||||||
_updateCache: Updatable[];
|
_updateCache: Updatable[];
|
||||||
skin: Skin;
|
skin: Skin;
|
||||||
color: Color;
|
color: Color;
|
||||||
@@ -735,8 +757,24 @@ declare namespace spine {
|
|||||||
findIkConstraint(constraintName: string): IkConstraint;
|
findIkConstraint(constraintName: string): IkConstraint;
|
||||||
findTransformConstraint(constraintName: string): TransformConstraint;
|
findTransformConstraint(constraintName: string): TransformConstraint;
|
||||||
findPathConstraint(constraintName: string): PathConstraint;
|
findPathConstraint(constraintName: string): PathConstraint;
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
findPhysicsConstraint(constraintName: string): PhysicsConstraint;
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
getPhysicsConstraints(): SPVectorPhysicsConstraintPtr;
|
||||||
//getBounds(offset: Vector2, size: Vector2, temp?: Array<number>): void;
|
//getBounds(offset: Vector2, size: Vector2, temp?: Array<number>): void;
|
||||||
update(delta: number): void;
|
update(delta: number): void;
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
updateWorldTransform(physics: Physics): void;
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
updateWorldTransform(physics: Physics, parent: Bone): void;
|
||||||
}
|
}
|
||||||
class SkeletonBinary {
|
class SkeletonBinary {
|
||||||
static AttachmentTypeValues: number[];
|
static AttachmentTypeValues: number[];
|
||||||
@@ -812,6 +850,10 @@ declare namespace spine {
|
|||||||
ikConstraints: IkConstraintData[];
|
ikConstraints: IkConstraintData[];
|
||||||
transformConstraints: TransformConstraintData[];
|
transformConstraints: TransformConstraintData[];
|
||||||
pathConstraints: PathConstraintData[];
|
pathConstraints: PathConstraintData[];
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
physicsConstraints: PhysicsConstraintData[];
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
width: number;
|
width: number;
|
||||||
@@ -835,6 +877,14 @@ declare namespace spine {
|
|||||||
findTransformConstraint(constraintName: string): TransformConstraintData;
|
findTransformConstraint(constraintName: string): TransformConstraintData;
|
||||||
findPathConstraint(constraintName: string): PathConstraintData;
|
findPathConstraint(constraintName: string): PathConstraintData;
|
||||||
findPathConstraintIndex(pathConstraintName: string): number;
|
findPathConstraintIndex(pathConstraintName: string): number;
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
findPhysicsConstraint(constraintName: string): PhysicsConstraintData;
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
getPhysicsConstraints(): SPVectorPhysicsConstraintDataPtr;
|
||||||
}
|
}
|
||||||
class SkeletonJson {
|
class SkeletonJson {
|
||||||
attachmentLoader: AttachmentLoader;
|
attachmentLoader: AttachmentLoader;
|
||||||
@@ -1005,6 +1055,82 @@ declare namespace spine {
|
|||||||
local: boolean;
|
local: boolean;
|
||||||
constructor(name: string);
|
constructor(name: string);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
enum Physics {
|
||||||
|
none = 0,
|
||||||
|
reset = 1,
|
||||||
|
update = 2,
|
||||||
|
pose = 3
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
class PhysicsConstraint implements Updatable {
|
||||||
|
data: PhysicsConstraintData;
|
||||||
|
bone: Bone;
|
||||||
|
inertia: number;
|
||||||
|
strength: number;
|
||||||
|
damping: number;
|
||||||
|
massInverse: number;
|
||||||
|
wind: number;
|
||||||
|
gravity: number;
|
||||||
|
mix: number;
|
||||||
|
_reset: boolean;
|
||||||
|
ux: number;
|
||||||
|
uy: number;
|
||||||
|
cx: number;
|
||||||
|
cy: number;
|
||||||
|
tx: number;
|
||||||
|
ty: number;
|
||||||
|
xOffset: number;
|
||||||
|
xVelocity: number;
|
||||||
|
yOffset: number;
|
||||||
|
yVelocity: number;
|
||||||
|
rotateOffset: number;
|
||||||
|
rotateVelocity: number;
|
||||||
|
scaleOffset: number;
|
||||||
|
scaleVelocity: number;
|
||||||
|
remaining: number;
|
||||||
|
lastTime: number;
|
||||||
|
active: boolean;
|
||||||
|
constructor(data: PhysicsConstraintData, skeleton: Skeleton);
|
||||||
|
isActive(): boolean;
|
||||||
|
reset(): void;
|
||||||
|
setToSetupPose(): void;
|
||||||
|
update(): void;
|
||||||
|
translate(x: number, y: number): void;
|
||||||
|
rotate(x: number, y: number, degrees: number): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @version 4.2
|
||||||
|
*/
|
||||||
|
class PhysicsConstraintData extends ConstraintData {
|
||||||
|
bone: BoneData;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
rotate: number;
|
||||||
|
scaleX: number;
|
||||||
|
shearX: number;
|
||||||
|
limit: number;
|
||||||
|
step: number;
|
||||||
|
inertia: number;
|
||||||
|
strength: number;
|
||||||
|
damping: number;
|
||||||
|
massInverse: number;
|
||||||
|
wind: number;
|
||||||
|
gravity: number;
|
||||||
|
mix: number;
|
||||||
|
inertiaGlobal: boolean;
|
||||||
|
strengthGlobal: boolean;
|
||||||
|
dampingGlobal: boolean;
|
||||||
|
massGlobal: boolean;
|
||||||
|
windGlobal: boolean;
|
||||||
|
gravityGlobal: boolean;
|
||||||
|
mixGlobal: boolean;
|
||||||
|
constructor(name: string);
|
||||||
|
}
|
||||||
class Triangulator {
|
class Triangulator {
|
||||||
private convexPolygons;
|
private convexPolygons;
|
||||||
private convexPolygonsIndices;
|
private convexPolygonsIndices;
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Runtime-selectable spine instantiation. Used only when both spine-3.8 and spine-4.2 are compiled into
|
||||||
|
// the engine (editor/preview): cc.config.json's moduleOverrides then replaces spine-instantiate.ts with
|
||||||
|
// this file. Unlike the fixed-version files (spine-instantiate-3.8.ts / -4.2.ts), both the 3.8 and 4.2
|
||||||
|
// external references are kept here (so both wasm/asm binaries are bundled), and the matching one is
|
||||||
|
// executed at runtime according to the selected version.
|
||||||
|
// The version comes from the preview boot (game-boot.js / engine-bootstrap.ts), which reads it from
|
||||||
|
// cocos.config.json before engine init and writes globalThis._CC_SPINE_VERSION.
|
||||||
|
|
||||||
|
import { ensureWasmModuleReady } from 'pal/wasm';
|
||||||
|
import { error } from '../../core';
|
||||||
|
import { shouldUseWasmModule, initWasm, initAsmJS } from './spine-wasm-utils';
|
||||||
|
// Import setSpineVersion through the overridden './spine-version' (= spine-version-dynamic) so it is the
|
||||||
|
// same module instance whose SPINE_VERSION live binding is read by the shared spine-define.ts.
|
||||||
|
import { setSpineVersion } from './spine-version';
|
||||||
|
|
||||||
|
function getSelectedSpineVersion (): string {
|
||||||
|
const v = (globalThis as any)._CC_SPINE_VERSION;
|
||||||
|
return v === '4.2' ? '4.2' : '3.8';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function waitForSpineWasmInstantiation (): Promise<void> {
|
||||||
|
const errorReport = (msg: any): void => { error(msg); };
|
||||||
|
// The version must be set before wasm instantiation and before spine-define patches prototypes.
|
||||||
|
const version = getSelectedSpineVersion();
|
||||||
|
setSpineVersion(version);
|
||||||
|
return ensureWasmModuleReady().then((): Promise<void> => {
|
||||||
|
//We should use static code here, import operation will cause file copy to cache folder.
|
||||||
|
if (version === '4.2') {
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Runtime-selectable spine version. Used only when both spine-3.8 and spine-4.2 are compiled into the
|
||||||
|
// engine (editor/preview): cc.config.json's moduleOverrides then replaces spine-version.ts with this file.
|
||||||
|
// Unlike the fixed-version files (spine-version-3.8.ts / -4.2.ts), SPINE_VERSION is a mutable `let`
|
||||||
|
// (a live ES binding), so the shared layer (spine-define.ts / skeleton.ts) reads the runtime value and
|
||||||
|
// keeps both `SPINE_VERSION === '3.8' / '4.2'` branches instead of tree-shaking to a single one.
|
||||||
|
// The version is set by spine-instantiate-dynamic.ts before instantiation, sourced from the host-provided
|
||||||
|
// globalThis._CC_SPINE_VERSION (injected by the preview boot from cocos.config.json).
|
||||||
|
import { DataInput, SkeletonBinary } from './spine-binary';
|
||||||
|
import { BUILD } from 'internal:constants';
|
||||||
|
|
||||||
|
// Typed as string so comparisons in the shared layer against the other version literal are not flagged by TS.
|
||||||
|
export let SPINE_VERSION: string = '3.8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current spine version. Must be called before spine wasm instantiation and before spine-define runs.
|
||||||
|
*/
|
||||||
|
export function setSpineVersion (version: string): void {
|
||||||
|
SPINE_VERSION = version === '4.2' ? '4.2' : '3.8';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isVersionCompatible (version: string | null): boolean {
|
||||||
|
if (!BUILD) {
|
||||||
|
if (SPINE_VERSION === '3.8') {
|
||||||
|
if (!version || version === '3.8.75' || !version.startsWith('3.8.')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!version || !version.startsWith('4.2.')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal Used only by editor.
|
||||||
|
*/
|
||||||
|
export function isBinaryCompatible (buffer: Uint8Array): boolean {
|
||||||
|
if (!BUILD) {
|
||||||
|
const input = new DataInput(buffer);
|
||||||
|
// The binary hash header differs between versions: 3.8 uses one string, 4.2 uses two ints.
|
||||||
|
if (SPINE_VERSION === '3.8') {
|
||||||
|
SkeletonBinary.readString(input); // read hash
|
||||||
|
} else {
|
||||||
|
SkeletonBinary.readInt(input); // read hash
|
||||||
|
SkeletonBinary.readInt(input); // read hash
|
||||||
|
}
|
||||||
|
const version = SkeletonBinary.readString(input);
|
||||||
|
|
||||||
|
return isVersionCompatible(version);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal Used only by editor.
|
||||||
|
*/
|
||||||
|
export function isJsonCompatible (json: JSON): boolean {
|
||||||
|
if (!BUILD) {
|
||||||
|
return isVersionCompatible(json['skeleton']['spine']);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -24,6 +24,12 @@
|
|||||||
|
|
||||||
export const SPINE_VERSION = '3.8';
|
export const SPINE_VERSION = '3.8';
|
||||||
|
|
||||||
|
// Placeholder so spine-instantiate-dynamic.ts can import setSpineVersion from './spine-version' and type-check.
|
||||||
|
// When building the engine with runtime-selectable spine, moduleOverrides replaces this file with
|
||||||
|
// spine-version-dynamic.ts (the real implementation). In fixed single-version builds (spine-3.8 / spine-4.2)
|
||||||
|
// spine-instantiate-dynamic is not used, so this no-op is never called.
|
||||||
|
export function setSpineVersion (version: string): void {}
|
||||||
|
|
||||||
export function isBinaryCompatible (buffer: Uint8Array): boolean {
|
export function isBinaryCompatible (buffer: Uint8Array): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { Material, Texture2D } from '../asset/assets';
|
|||||||
import { error, errorID, logID, warnID } from '../core/platform/debug';
|
import { error, errorID, logID, warnID } from '../core/platform/debug';
|
||||||
import { Enum, EnumType, ccenum } from '../core/value-types/enum';
|
import { Enum, EnumType, ccenum } from '../core/value-types/enum';
|
||||||
import { Node, NodeEventType } from '../scene-graph';
|
import { Node, NodeEventType } from '../scene-graph';
|
||||||
import { CCObjectFlags, Color, RecyclePool, js } from '../core';
|
import { CCObjectFlags, Color, RecyclePool, js, math } from '../core';
|
||||||
import { SkeletonData } from './skeleton-data';
|
import { SkeletonData } from './skeleton-data';
|
||||||
import type { Graphics } from '../2d/components/graphics';
|
import type { Graphics } from '../2d/components/graphics';
|
||||||
import { UIRenderer } from '../2d/framework/ui-renderer';
|
import { UIRenderer } from '../2d/framework/ui-renderer';
|
||||||
@@ -850,14 +850,12 @@ export class Skeleton extends UIRenderer {
|
|||||||
warnID(16410);
|
warnID(16410);
|
||||||
}
|
}
|
||||||
const skeletonInfo = this._skeletonCache!.getSkeletonInfo(this._skeletonData!);
|
const skeletonInfo = this._skeletonCache!.getSkeletonInfo(this._skeletonData!);
|
||||||
if (this._skeletonInfo !== skeletonInfo) {
|
if (this._skeletonInfo !== skeletonInfo || (!this._skeletonInfo && !skeletonInfo)) {
|
||||||
this._destroySkeletonInfo(this._skeletonCache);
|
this._destroySkeletonInfo(this._skeletonCache);
|
||||||
if (!skeletonInfo && this._cacheMode === SpineAnimationCacheMode.PRIVATE_CACHE) {
|
if (!skeletonInfo && this._cacheMode === SpineAnimationCacheMode.PRIVATE_CACHE) {
|
||||||
this._animCache = this._skeletonCache!.initAnimationCache(this.skeletonData!.uuid, this._skeletonData!, this._animationName);
|
this._animCache = this._skeletonCache!.initAnimationCache(this.skeletonData!.uuid, this._skeletonData!, this._animationName);
|
||||||
}
|
}
|
||||||
this._skeletonInfo = this._skeletonCache!.createSkeletonInfo(this._skeletonData!);
|
this._skeletonInfo = this._skeletonCache!.createSkeletonInfo(this._skeletonData!);
|
||||||
}
|
|
||||||
if (this._skeletonInfo) {
|
|
||||||
this._skeleton = this._skeletonInfo.skeleton!;
|
this._skeleton = this._skeletonInfo.skeleton!;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1589,7 +1587,7 @@ export class Skeleton extends UIRenderer {
|
|||||||
const socket = this._sockets[i];
|
const socket = this._sockets[i];
|
||||||
if (socket.path && socket.target) {
|
if (socket.path && socket.target) {
|
||||||
const boneIdx = this._cachedSockets.get(socket.path);
|
const boneIdx = this._cachedSockets.get(socket.path);
|
||||||
if (!boneIdx) {
|
if (boneIdx == null || boneIdx < 0) {
|
||||||
error(`Skeleton data does not contain path ${socket.path}`);
|
error(`Skeleton data does not contain path ${socket.path}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1883,10 +1881,16 @@ export class Skeleton extends UIRenderer {
|
|||||||
*/
|
*/
|
||||||
public setTrackCompleteListener (entry: spine.TrackEntry, listener: TrackListener2): void {
|
public setTrackCompleteListener (entry: spine.TrackEntry, listener: TrackListener2): void {
|
||||||
const onComplete = (trackEntry: spine.TrackEntry): void => {
|
const onComplete = (trackEntry: spine.TrackEntry): void => {
|
||||||
const loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
|
const animEnd = math.equals(trackEntry.animationEnd, -1.0) ? trackEntry.animation.duration : trackEntry.animationEnd;
|
||||||
listener(trackEntry, loopCount);
|
const duration = animEnd - trackEntry.animationStart;
|
||||||
// this._instance.setListener(listenerID, spine.EventType.event);
|
if (duration > 0) {
|
||||||
// this._listener!.event = listener;
|
const loopCount = trackEntry.loop ? Math.floor(trackEntry.trackTime / duration) : 1;
|
||||||
|
listener(trackEntry, loopCount);
|
||||||
|
// this._instance.setListener(listenerID, spine.EventType.event);
|
||||||
|
// this._listener!.event = listener;
|
||||||
|
} else {
|
||||||
|
warnID(16420);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
TrackEntryListeners.getListeners(entry, this._instance!).complete = onComplete;
|
TrackEntryListeners.getListeners(entry, this._instance!).complete = onComplete;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -878,7 +878,7 @@ export class TiledLayer extends UIRenderer {
|
|||||||
const axis = this._staggerAxis;
|
const axis = this._staggerAxis;
|
||||||
|
|
||||||
switch (this._layerOrientation) {
|
switch (this._layerOrientation) {
|
||||||
// left top to right dowm
|
// left top to right down
|
||||||
case Orientation.ORTHO:
|
case Orientation.ORTHO:
|
||||||
col = Math.floor(x / maptw);
|
col = Math.floor(x / maptw);
|
||||||
row = Math.floor(y / mapth);
|
row = Math.floor(y / mapth);
|
||||||
@@ -889,7 +889,7 @@ export class TiledLayer extends UIRenderer {
|
|||||||
col = Math.floor(x / maptw2);
|
col = Math.floor(x / maptw2);
|
||||||
row = Math.floor(y / mapth2);
|
row = Math.floor(y / mapth2);
|
||||||
break;
|
break;
|
||||||
// left top to right dowm
|
// left top to right down
|
||||||
case Orientation.HEX:
|
case Orientation.HEX:
|
||||||
if (axis === StaggerAxis.STAGGERAXIS_Y) {
|
if (axis === StaggerAxis.STAGGERAXIS_Y) {
|
||||||
row = Math.floor(y / (mapth - this._diffY1!));
|
row = Math.floor(y / (mapth - this._diffY1!));
|
||||||
@@ -1017,7 +1017,7 @@ export class TiledLayer extends UIRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (layerOrientation) {
|
switch (layerOrientation) {
|
||||||
// left top to right dowm
|
// left top to right down
|
||||||
case Orientation.ORTHO:
|
case Orientation.ORTHO:
|
||||||
cullingCol = col;
|
cullingCol = col;
|
||||||
cullingRow = rows - row - 1;
|
cullingRow = rows - row - 1;
|
||||||
@@ -1039,7 +1039,7 @@ export class TiledLayer extends UIRenderer {
|
|||||||
left = maptw2 * cullingCol;
|
left = maptw2 * cullingCol;
|
||||||
bottom = mapth2 * cullingRow;
|
bottom = mapth2 * cullingRow;
|
||||||
break;
|
break;
|
||||||
// left top to right dowm
|
// left top to right down
|
||||||
case Orientation.HEX:
|
case Orientation.HEX:
|
||||||
diffX2 = (axis! === StaggerAxis.STAGGERAXIS_Y && row % 2 === 1) ? maptw2 * odd_even! : 0;
|
diffX2 = (axis! === StaggerAxis.STAGGERAXIS_Y && row % 2 === 1) ? maptw2 * odd_even! : 0;
|
||||||
diffY2 = (axis! === StaggerAxis.STAGGERAXIS_X && col % 2 === 1) ? mapth2 * -odd_even! : 0;
|
diffY2 = (axis! === StaggerAxis.STAGGERAXIS_X && col % 2 === 1) ? mapth2 * -odd_even! : 0;
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ function align (node: Node, widget: Widget): void {
|
|||||||
// TODO: type is hack, Change to the type actually used (Node or BaseNode) when BaseNode complete
|
// TODO: type is hack, Change to the type actually used (Node or BaseNode) when BaseNode complete
|
||||||
function visitNode (node: any): void {
|
function visitNode (node: any): void {
|
||||||
const widget = node.getComponent(Widget);
|
const widget = node.getComponent(Widget);
|
||||||
if (widget && widget.enabled) {
|
if (widget && widget.enabled && cclegacy.isValid(widget, true)) {
|
||||||
if (DEV) {
|
if (DEV) {
|
||||||
widget._validateTargetInDEV();
|
widget._validateTargetInDEV();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -852,6 +852,9 @@ export class Widget extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onDestroy (): void {
|
public onDestroy (): void {
|
||||||
|
// `onDisable` is skipped when the component was never enabled by the scheduler
|
||||||
|
// (`IsOnEnableCalled` unset), so unregister here as well.
|
||||||
|
cclegacy._widgetManager?.remove(this);
|
||||||
this._removeParentEvent();
|
this._removeParentEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ vec3 HDRToLDR(vec3 color)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// linear exposure has already applied to light intensity
|
// linear exposure has already applied to light intensity
|
||||||
#if CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES
|
#if CC_TONE_MAPPING_TYPE == TONE_MAPPING_ACES
|
||||||
color.rgb = ACESToneMap(color.rgb);
|
color.rgb = ACESToneMap(color.rgb);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,8 +79,12 @@ vec4 saturate(vec4 value) { return clamp(value, vec4(0.0), vec4(1.0)); }
|
|||||||
#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) equalf_lowp(light_type, LIGHT_TYPE_RANGED_DIRECTIONAL)
|
#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) equalf_lowp(light_type, LIGHT_TYPE_RANGED_DIRECTIONAL)
|
||||||
|
|
||||||
// CC_TONE_MAPPING_TYPE Values
|
// CC_TONE_MAPPING_TYPE Values
|
||||||
#define TONE_MAPPING_ACES 0
|
#ifndef TONE_MAPPING_ACES
|
||||||
#define TONE_MAPPING_LINEAR 1
|
#define TONE_MAPPING_ACES 0
|
||||||
|
#endif
|
||||||
|
#ifndef TONE_MAPPING_LINEAR
|
||||||
|
#define TONE_MAPPING_LINEAR 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// Material
|
// Material
|
||||||
#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0
|
#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0
|
||||||
|
|||||||
@@ -81,9 +81,10 @@ vec3 CalculateNormal(vec3 tangent, vec3 binormal)
|
|||||||
// return value is un-normalized
|
// return value is un-normalized
|
||||||
vec3 CalculateNormalFromTangentSpace(vec3 normalFromTangentSpace, float normalStrength, vec3 normal, vec3 tangent, float mirrorNormal)
|
vec3 CalculateNormalFromTangentSpace(vec3 normalFromTangentSpace, float normalStrength, vec3 normal, vec3 tangent, float mirrorNormal)
|
||||||
{
|
{
|
||||||
|
// according to the linearly interpolated mirrorNormal value, the binormal length should vary linearly to ensure geometric smoothness. therefore, explicit normalization is unnecessary.
|
||||||
vec3 binormal = CalculateBinormal(normal, tangent, mirrorNormal);
|
vec3 binormal = CalculateBinormal(normal, tangent, mirrorNormal);
|
||||||
return (normalFromTangentSpace.x * normalStrength) * normalize(tangent) +
|
return (normalFromTangentSpace.x * normalStrength) * normalize(tangent) +
|
||||||
(normalFromTangentSpace.y * normalStrength) * normalize(binormal) +
|
(normalFromTangentSpace.y * normalStrength) * binormal +
|
||||||
normalFromTangentSpace.z * normalize(normal);
|
normalFromTangentSpace.z * normalize(normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ vec4 CCFragOutput (vec4 color) {
|
|||||||
#if CC_USE_RGBE_OUTPUT
|
#if CC_USE_RGBE_OUTPUT
|
||||||
color = packRGBE(color.rgb);
|
color = packRGBE(color.rgb);
|
||||||
#elif !CC_USE_FLOAT_OUTPUT
|
#elif !CC_USE_FLOAT_OUTPUT
|
||||||
#if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES
|
#if CC_USE_HDR && CC_TONE_MAPPING_TYPE == TONE_MAPPING_ACES
|
||||||
color.rgb = ACESToneMap(color.rgb);
|
color.rgb = ACESToneMap(color.rgb);
|
||||||
#endif
|
#endif
|
||||||
color.rgb = LinearToSRGB(color.rgb);
|
color.rgb = LinearToSRGB(color.rgb);
|
||||||
|
|||||||
@@ -222,7 +222,9 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {
|
|||||||
vec3 R = normalize(reflect(-V, N));
|
vec3 R = normalize(reflect(-V, N));
|
||||||
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_CUBE
|
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_CUBE
|
||||||
if(s.reflectionProbeId < 0.0){
|
if(s.reflectionProbeId < 0.0){
|
||||||
env = SampleReflectionProbe(cc_environment, R, s.roughness, cc_ambientGround.w, CC_USE_IBL == IBL_RGBE);
|
#if CC_USE_IBL
|
||||||
|
env = SampleReflectionProbe(cc_environment, R, s.roughness, cc_ambientGround.w, CC_USE_IBL == IBL_RGBE);
|
||||||
|
#endif
|
||||||
}else{
|
}else{
|
||||||
vec3 centerPos, boxHalfSize;
|
vec3 centerPos, boxHalfSize;
|
||||||
float mipCount;
|
float mipCount;
|
||||||
@@ -247,7 +249,9 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {
|
|||||||
env = unpackRGBE(probe);
|
env = unpackRGBE(probe);
|
||||||
#elif CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX
|
#elif CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX
|
||||||
if (s.reflectionProbeId < 0.0) {
|
if (s.reflectionProbeId < 0.0) {
|
||||||
env = SampleReflectionProbe(cc_environment, R, s.roughness, cc_ambientGround.w, CC_USE_IBL == IBL_RGBE);
|
#if CC_USE_IBL
|
||||||
|
env = SampleReflectionProbe(cc_environment, R, s.roughness, cc_ambientGround.w, CC_USE_IBL == IBL_RGBE);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
vec3 centerPos, boxHalfSize;
|
vec3 centerPos, boxHalfSize;
|
||||||
float mipCount;
|
float mipCount;
|
||||||
@@ -256,7 +260,10 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {
|
|||||||
|
|
||||||
env = SampleReflectionProbe(cc_reflectionProbeCubemap, fixedR.xyz, s.roughness, mipCount, isReflectProbeUsingRGBE(s.reflectionProbeId));
|
env = SampleReflectionProbe(cc_reflectionProbeCubemap, fixedR.xyz, s.roughness, mipCount, isReflectProbeUsingRGBE(s.reflectionProbeId));
|
||||||
if (s.reflectionProbeBlendId < 0.0) {
|
if (s.reflectionProbeBlendId < 0.0) {
|
||||||
vec3 skyBoxEnv = SampleReflectionProbe(cc_environment, R, s.roughness, cc_ambientGround.w, CC_USE_IBL == IBL_RGBE) * lightIntensity;
|
vec3 skyBoxEnv = vec3(0.0);
|
||||||
|
#if CC_USE_IBL
|
||||||
|
skyBoxEnv = SampleReflectionProbe(cc_environment, R, s.roughness, cc_ambientGround.w, CC_USE_IBL == IBL_RGBE) * lightIntensity;
|
||||||
|
#endif
|
||||||
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX
|
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX
|
||||||
//blend with skybox
|
//blend with skybox
|
||||||
env = mix(env, skyBoxEnv, s.reflectionProbeBlendFactor);
|
env = mix(env, skyBoxEnv, s.reflectionProbeBlendFactor);
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ vec3 SampleEnvironmentSpecular(samplerCube tex, in LightingIntermediateData ligh
|
|||||||
vec4 fixedR = CalculateBoxProjectedDirection(R, worldPos, cubeCenterPos, boxHalfSize);
|
vec4 fixedR = CalculateBoxProjectedDirection(R, worldPos, cubeCenterPos, boxHalfSize);
|
||||||
R = fixedR.xyz;
|
R = fixedR.xyz;
|
||||||
|
|
||||||
vec3 envmap = SampleEnvironmentSpecular(cc_environment, lightingData, cc_ambientGround.w).xyz * cc_ambientSky.w;
|
vec3 envmap = vec3(0.0);
|
||||||
|
#if CC_USE_IBL
|
||||||
|
envmap = SampleEnvironmentSpecular(cc_environment, lightingData, cc_ambientGround.w).xyz * cc_ambientSky.w;
|
||||||
|
#endif
|
||||||
#if CC_SURFACES_LIGHTING_ANISOTROPIC && CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT
|
#if CC_SURFACES_LIGHTING_ANISOTROPIC && CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT
|
||||||
envSpec = EnvAnisotropicReflection(tex, fixedR.xyz, roughness, mipCount, lightingData.anisotropyShape, lightingData.V, lightingData.N, lightingData.T, lightingData.B);
|
envSpec = EnvAnisotropicReflection(tex, fixedR.xyz, roughness, mipCount, lightingData.anisotropyShape, lightingData.V, lightingData.N, lightingData.T, lightingData.B);
|
||||||
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_CUBE
|
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_CUBE
|
||||||
@@ -159,7 +162,9 @@ vec3 CalculateEnvironmentSpecular(in LightingIntermediateData lightingData, floa
|
|||||||
|
|
||||||
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_CUBE
|
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_CUBE
|
||||||
if(FSInput_reflectionProbeId < 0.0){
|
if(FSInput_reflectionProbeId < 0.0){
|
||||||
|
#if CC_USE_IBL
|
||||||
envSpec = SampleEnvironmentSpecular(cc_environment, lightingData, cc_ambientGround.w);
|
envSpec = SampleEnvironmentSpecular(cc_environment, lightingData, cc_ambientGround.w);
|
||||||
|
#endif
|
||||||
}else{
|
}else{
|
||||||
vec3 centerPos, boxHalfSize;
|
vec3 centerPos, boxHalfSize;
|
||||||
float mipCount;
|
float mipCount;
|
||||||
@@ -181,7 +186,9 @@ vec3 CalculateEnvironmentSpecular(in LightingIntermediateData lightingData, floa
|
|||||||
}
|
}
|
||||||
#elif CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX
|
#elif CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX
|
||||||
if(FSInput_reflectionProbeId < 0.0){
|
if(FSInput_reflectionProbeId < 0.0){
|
||||||
|
#if CC_USE_IBL
|
||||||
envSpec = SampleEnvironmentSpecular(cc_environment, lightingData, cc_ambientGround.w);
|
envSpec = SampleEnvironmentSpecular(cc_environment, lightingData, cc_ambientGround.w);
|
||||||
|
#endif
|
||||||
}else{
|
}else{
|
||||||
vec3 centerPos, boxHalfSize;
|
vec3 centerPos, boxHalfSize;
|
||||||
float mipCount;
|
float mipCount;
|
||||||
@@ -197,7 +204,10 @@ vec3 CalculateEnvironmentSpecular(in LightingIntermediateData lightingData, floa
|
|||||||
|
|
||||||
if(FSInput_reflectionProbeBlendId < 0.0)
|
if(FSInput_reflectionProbeBlendId < 0.0)
|
||||||
{
|
{
|
||||||
vec3 skyBoxEnv = SampleEnvironmentSpecular(cc_environment, lightingData, cc_ambientGround.w).rgb * lightIntensity;
|
vec3 skyBoxEnv = vec3(0.0);
|
||||||
|
#if CC_USE_IBL
|
||||||
|
skyBoxEnv = SampleEnvironmentSpecular(cc_environment, lightingData, cc_ambientGround.w).rgb * lightIntensity;
|
||||||
|
#endif
|
||||||
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX
|
#if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX
|
||||||
//blend with skybox
|
//blend with skybox
|
||||||
envSpec = mix(envSpec, skyBoxEnv, blendFactor);
|
envSpec = mix(envSpec, skyBoxEnv, blendFactor);
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 945 B |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "6ef37a33-5db9-4231-9855-f72b8428f6fa",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.4",
|
||||||
|
"importer": "texture-cube",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "a4063d6c-c46e-482a-bf84-99eb9fbb2789",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "repeat",
|
||||||
|
"wrapModeT": "repeat",
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0,
|
||||||
|
"isRGBE": false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -434,7 +434,8 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder
|
|||||||
// Reflection Probe
|
// Reflection Probe
|
||||||
cameraConfigs.enablePlanarReflectionProbe = cameraConfigs.isMainGameWindow
|
cameraConfigs.enablePlanarReflectionProbe = cameraConfigs.isMainGameWindow
|
||||||
|| camera.cameraUsage === CameraUsage.SCENE_VIEW
|
|| camera.cameraUsage === CameraUsage.SCENE_VIEW
|
||||||
|| camera.cameraUsage === CameraUsage.GAME_VIEW;
|
|| camera.cameraUsage === CameraUsage.GAME_VIEW
|
||||||
|
|| camera.cameraUsage === CameraUsage.PREVIEW;
|
||||||
|
|
||||||
// MSAA
|
// MSAA
|
||||||
cameraConfigs.enableMSAA = cameraConfigs.settings.msaa.enabled
|
cameraConfigs.enableMSAA = cameraConfigs.settings.msaa.enabled
|
||||||
@@ -551,7 +552,7 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder
|
|||||||
ppl, camera, pplConfigs.mobileMaxSpotLightShadowMaps);
|
ppl, camera, pplConfigs.mobileMaxSpotLightShadowMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._tryAddReflectionProbePasses(ppl, cameraConfigs, id, mainLight, camera.scene);
|
this._tryAddReflectionProbePasses(ppl, cameraConfigs, id, mainLight, camera.scene, camera);
|
||||||
|
|
||||||
if (cameraConfigs.remainingPasses > 0 || cameraConfigs.enableShadingScale) {
|
if (cameraConfigs.remainingPasses > 0 || cameraConfigs.enableShadingScale) {
|
||||||
context.colorName = cameraConfigs.enableShadingScale
|
context.colorName = cameraConfigs.enableShadingScale
|
||||||
@@ -630,6 +631,7 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder
|
|||||||
id: number,
|
id: number,
|
||||||
mainLight: renderer.scene.DirectionalLight | null,
|
mainLight: renderer.scene.DirectionalLight | null,
|
||||||
scene: renderer.RenderScene | null,
|
scene: renderer.RenderScene | null,
|
||||||
|
sourceCamera: renderer.scene.Camera,
|
||||||
): void {
|
): void {
|
||||||
const reflectionProbeManager = cclegacy.internal.reflectionProbeManager as ReflectionProbeManager | undefined;
|
const reflectionProbeManager = cclegacy.internal.reflectionProbeManager as ReflectionProbeManager | undefined;
|
||||||
if (!reflectionProbeManager) {
|
if (!reflectionProbeManager) {
|
||||||
@@ -651,6 +653,10 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder
|
|||||||
if (!cameraConfigs.enablePlanarReflectionProbe) {
|
if (!cameraConfigs.enablePlanarReflectionProbe) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let reflectionCamera = probe.camera;
|
||||||
|
if (EDITOR && sourceCamera.cameraUsage === CameraUsage.PREVIEW) {
|
||||||
|
reflectionCamera = probe.renderPreviewPlanarReflection(sourceCamera);
|
||||||
|
}
|
||||||
const window: renderer.RenderWindow = probe.realtimePlanarTexture!.window!;
|
const window: renderer.RenderWindow = probe.realtimePlanarTexture!.window!;
|
||||||
const colorName = `PlanarProbeRT${probeID}`;
|
const colorName = `PlanarProbeRT${probeID}`;
|
||||||
const depthStencilName = `PlanarProbeDS${probeID}`;
|
const depthStencilName = `PlanarProbeDS${probeID}`;
|
||||||
@@ -663,8 +669,8 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder
|
|||||||
// Rendering
|
// Rendering
|
||||||
const probePass = ppl.addRenderPass(width, height, 'default');
|
const probePass = ppl.addRenderPass(width, height, 'default');
|
||||||
probePass.name = `PlanarReflectionProbe${probeID}`;
|
probePass.name = `PlanarReflectionProbe${probeID}`;
|
||||||
this._buildReflectionProbePass(probePass, cameraConfigs, id, probe.camera,
|
this._buildReflectionProbePass(probePass, cameraConfigs, id, reflectionCamera, probe,
|
||||||
colorName, depthStencilName, mainLight, scene);
|
colorName, depthStencilName, mainLight);
|
||||||
} else if (EDITOR) {
|
} else if (EDITOR) {
|
||||||
for (let faceIdx = 0; faceIdx < probe.bakedCubeTextures.length; faceIdx++) {
|
for (let faceIdx = 0; faceIdx < probe.bakedCubeTextures.length; faceIdx++) {
|
||||||
probe.updateCameraDir(faceIdx);
|
probe.updateCameraDir(faceIdx);
|
||||||
@@ -680,8 +686,8 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder
|
|||||||
// Rendering
|
// Rendering
|
||||||
const probePass = ppl.addRenderPass(width, height, 'default');
|
const probePass = ppl.addRenderPass(width, height, 'default');
|
||||||
probePass.name = `CubeProbe${probeID}${faceIdx}`;
|
probePass.name = `CubeProbe${probeID}${faceIdx}`;
|
||||||
this._buildReflectionProbePass(probePass, cameraConfigs, id, probe.camera,
|
this._buildReflectionProbePass(probePass, cameraConfigs, id, probe.camera, probe,
|
||||||
colorName, depthStencilName, mainLight, scene);
|
colorName, depthStencilName, mainLight);
|
||||||
}
|
}
|
||||||
probe.needRender = false;
|
probe.needRender = false;
|
||||||
}
|
}
|
||||||
@@ -696,10 +702,10 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder
|
|||||||
cameraConfigs: Readonly<CameraConfigs & ForwardPassConfigs>,
|
cameraConfigs: Readonly<CameraConfigs & ForwardPassConfigs>,
|
||||||
id: number,
|
id: number,
|
||||||
camera: renderer.scene.Camera,
|
camera: renderer.scene.Camera,
|
||||||
|
probe: renderer.scene.ReflectionProbe,
|
||||||
colorName: string,
|
colorName: string,
|
||||||
depthStencilName: string,
|
depthStencilName: string,
|
||||||
mainLight: renderer.scene.DirectionalLight | null,
|
mainLight: renderer.scene.DirectionalLight | null,
|
||||||
scene: renderer.RenderScene | null = null,
|
|
||||||
): void {
|
): void {
|
||||||
const QueueHint = rendering.QueueHint;
|
const QueueHint = rendering.QueueHint;
|
||||||
const SceneFlags = rendering.SceneFlags;
|
const SceneFlags = rendering.SceneFlags;
|
||||||
@@ -743,11 +749,11 @@ export class BuiltinForwardPassBuilder implements rendering.PipelinePassBuilder
|
|||||||
// TODO(zhouzhenglong): Separate OPAQUE and MASK queue
|
// TODO(zhouzhenglong): Separate OPAQUE and MASK queue
|
||||||
|
|
||||||
// add opaque and mask queue
|
// add opaque and mask queue
|
||||||
|
const lightInfo = new rendering.LightInfo(mainLight || null, 0, false, probe);
|
||||||
pass.addQueue(QueueHint.NONE, 'reflect-map') // Currently we put OPAQUE and MASK into one queue, so QueueHint is NONE
|
pass.addQueue(QueueHint.NONE, 'reflect-map') // Currently we put OPAQUE and MASK into one queue, so QueueHint is NONE
|
||||||
.addScene(camera,
|
.addSceneOfCamera(camera,
|
||||||
SceneFlags.OPAQUE | SceneFlags.MASK | SceneFlags.REFLECTION_PROBE,
|
lightInfo,
|
||||||
mainLight || undefined,
|
SceneFlags.OPAQUE | SceneFlags.MASK | SceneFlags.REFLECTION_PROBE);
|
||||||
scene ? scene : undefined);
|
|
||||||
}
|
}
|
||||||
private _addForwardRadiancePasses(
|
private _addForwardRadiancePasses(
|
||||||
ppl: rendering.BasicPipeline,
|
ppl: rendering.BasicPipeline,
|
||||||
|
|||||||
@@ -70,7 +70,9 @@ CCProgram smaa-edge-fs %{
|
|||||||
vec3 ToLDR(vec3 color) {
|
vec3 ToLDR(vec3 color) {
|
||||||
#if CC_USE_HDR
|
#if CC_USE_HDR
|
||||||
color *= cc_exposure.x * FP_SCALE_INV;
|
color *= cc_exposure.x * FP_SCALE_INV;
|
||||||
color = ACESToneMap(color);
|
#if CC_TONE_MAPPING_TYPE == TONE_MAPPING_ACES
|
||||||
|
color = ACESToneMap(color);
|
||||||
|
#endif
|
||||||
color = LinearToSRGB(color);
|
color = LinearToSRGB(color);
|
||||||
#endif
|
#endif
|
||||||
return color;
|
return color;
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ CCProgram tonemap-fs %{
|
|||||||
vec3 ToLDR(vec3 color) {
|
vec3 ToLDR(vec3 color) {
|
||||||
#if CC_USE_HDR
|
#if CC_USE_HDR
|
||||||
color *= cc_exposure.x * FP_SCALE_INV;
|
color *= cc_exposure.x * FP_SCALE_INV;
|
||||||
color = ACESToneMap(color);
|
#if CC_TONE_MAPPING_TYPE == TONE_MAPPING_ACES
|
||||||
|
color = ACESToneMap(color);
|
||||||
|
#endif
|
||||||
color = LinearToSRGB(color);
|
color = LinearToSRGB(color);
|
||||||
#endif
|
#endif
|
||||||
return color;
|
return color;
|
||||||
|
|||||||
@@ -244,6 +244,20 @@
|
|||||||
"faceCount": 0.1
|
"faceCount": 0.1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"legacyFbxImporter": false,
|
||||||
|
"allowMeshDataAccess": true,
|
||||||
|
"addVertexColor": false,
|
||||||
|
"generateLightmapUVNode": false,
|
||||||
|
"meshOptimizer": {
|
||||||
|
"enable": false,
|
||||||
|
"algorithm": "simplify",
|
||||||
|
"simplifyOptions": {
|
||||||
|
"targetRatio": 1,
|
||||||
|
"enableSmartLink": true,
|
||||||
|
"agressiveness": 7,
|
||||||
|
"maxIterationCount": 100
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ module.exports = {
|
|||||||
newCubeMap: 'CubeMap',
|
newCubeMap: 'CubeMap',
|
||||||
newRenderTexture: 'Render Texture',
|
newRenderTexture: 'Render Texture',
|
||||||
newScene: 'Scene',
|
newScene: 'Scene',
|
||||||
|
newScene:{
|
||||||
|
'2d': '2D Scene',
|
||||||
|
'3d': '3D Scene',
|
||||||
|
quality: 'High Quality Scene',
|
||||||
|
},
|
||||||
newPrefab: 'Node Prefab',
|
newPrefab: 'Node Prefab',
|
||||||
newMaterial: 'Material',
|
newMaterial: 'Material',
|
||||||
newPhysicsMaterial: 'Physics Material',
|
newPhysicsMaterial: 'Physics Material',
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ module.exports = link(mixin({
|
|||||||
illuminance: 'Illuminance of the light',
|
illuminance: 'Illuminance of the light',
|
||||||
luminous_power: 'Luminous power of the light',
|
luminous_power: 'Luminous power of the light',
|
||||||
luminance: 'Luminance of the light',
|
luminance: 'Luminance of the light',
|
||||||
visibility: 'Visibility mask, declaring a set of node layers that will be visible to this valid punctual Light(Does not work with directional light)',
|
visibility: 'Visibility mask, declaring a set of node layers that will be visible in the current light source',
|
||||||
term: 'The photometric term currently being used',
|
term: 'The photometric term currently being used',
|
||||||
size: 'Size of the light',
|
size: 'Size of the light',
|
||||||
range: 'Range of the light',
|
range: 'Range of the light',
|
||||||
@@ -779,6 +779,7 @@ module.exports = link(mixin({
|
|||||||
},
|
},
|
||||||
mask: {
|
mask: {
|
||||||
type: 'The mask type',
|
type: 'The mask type',
|
||||||
|
radius: 'The radius for rounded corners of rect mask',
|
||||||
spriteFrame: 'The mask image',
|
spriteFrame: 'The mask image',
|
||||||
inverted: 'The Reverse mask (Not supported Canvas Mode)',
|
inverted: 'The Reverse mask (Not supported Canvas Mode)',
|
||||||
alphaThreshold:
|
alphaThreshold:
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ module.exports = {
|
|||||||
newTypeScript: '脚本 (TypeScript)',
|
newTypeScript: '脚本 (TypeScript)',
|
||||||
newCubeMap: '立方体贴图',
|
newCubeMap: '立方体贴图',
|
||||||
newScene: '场景',
|
newScene: '场景',
|
||||||
|
newScene:{
|
||||||
|
'2d': '2D 场景',
|
||||||
|
'3d': '3D 场景',
|
||||||
|
quality: '高质量场景',
|
||||||
|
},
|
||||||
newPrefab: '预制 (Prefab)',
|
newPrefab: '预制 (Prefab)',
|
||||||
newRenderTexture: '渲染纹理 (Render Texture)',
|
newRenderTexture: '渲染纹理 (Render Texture)',
|
||||||
newMaterial: '材质',
|
newMaterial: '材质',
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ module.exports = link(mixin({
|
|||||||
illuminance: '光源强度',
|
illuminance: '光源强度',
|
||||||
luminous_flux: '光通量',
|
luminous_flux: '光通量',
|
||||||
luminance: '光亮度',
|
luminance: '光亮度',
|
||||||
visibility: '可见性掩码,声明在当前精确光源中可见的节点层级集合(对方向光不生效)',
|
visibility: '可见性掩码,声明在当前光源中可见的节点层级集合',
|
||||||
term: '当前使用的光度学计量单位',
|
term: '当前使用的光度学计量单位',
|
||||||
size: '光源大小',
|
size: '光源大小',
|
||||||
range: '光源范围',
|
range: '光源范围',
|
||||||
@@ -760,6 +760,7 @@ module.exports = link(mixin({
|
|||||||
},
|
},
|
||||||
mask: {
|
mask: {
|
||||||
type: '遮罩类型',
|
type: '遮罩类型',
|
||||||
|
radius: '矩形遮罩的圆角半径',
|
||||||
spriteFrame: '遮罩所需要的贴图',
|
spriteFrame: '遮罩所需要的贴图',
|
||||||
inverted: '反向遮罩(不支持 Canvas 模式)',
|
inverted: '反向遮罩(不支持 Canvas 模式)',
|
||||||
alphaThreshold: 'Alpha 阈值,只有当模板的像素的 Alpha 大于 Alpha Threshold 时,才会绘制内容(不支持 Canvas 模式)',
|
alphaThreshold: 'Alpha 阈值,只有当模板的像素的 Alpha 大于 Alpha Threshold 时,才会绘制内容(不支持 Canvas 模式)',
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# ignore third_party code from clang-format checks
|
# ignore third_party code from clang-format checks
|
||||||
./cocos/bindings/auto/*
|
./cocos/bindings/auto/*
|
||||||
|
./cocos/base/std/**
|
||||||
|
./cocos/cocos-version.h
|
||||||
|
./cocos/editor-support/spine-wasm/**
|
||||||
|
./cocos/editor-support/spine/**
|
||||||
./cocos/gi/light-probe/predicates.cpp
|
./cocos/gi/light-probe/predicates.cpp
|
||||||
./cocos/gi/light-probe/tetgen.cpp
|
./cocos/gi/light-probe/tetgen.cpp
|
||||||
./cocos/gi/light-probe/tetgen.h
|
./cocos/gi/light-probe/tetgen.h
|
||||||
|
./cocos/platform/openharmony/napi/**
|
||||||
|
./tools/**
|
||||||
|
./vendor/**
|
||||||
|
|||||||
@@ -3725,9 +3725,14 @@ if(APPLE)
|
|||||||
"$(inherited)"
|
"$(inherited)"
|
||||||
${CC_EXTERNAL_LIBS}
|
${CC_EXTERNAL_LIBS}
|
||||||
)
|
)
|
||||||
|
if(CMAKE_OSX_ARCHITECTURES)
|
||||||
|
set(_CC_ENGINE_ARCHS "${CMAKE_OSX_ARCHITECTURES}")
|
||||||
|
else()
|
||||||
|
set(_CC_ENGINE_ARCHS "arm64;x86_64")
|
||||||
|
endif()
|
||||||
set_target_properties(${ENGINE_NAME} PROPERTIES
|
set_target_properties(${ENGINE_NAME} PROPERTIES
|
||||||
XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "YES"
|
XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "YES"
|
||||||
OSX_ARCHITECTURES "arm64;x86_64"
|
OSX_ARCHITECTURES "${_CC_ENGINE_ARCHS}"
|
||||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/archives
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/archives
|
||||||
)
|
)
|
||||||
if(MACOSX)
|
if(MACOSX)
|
||||||
@@ -3739,9 +3744,9 @@ if(APPLE)
|
|||||||
)
|
)
|
||||||
elseif(IOS)
|
elseif(IOS)
|
||||||
|
|
||||||
if("${XCODE_VERSION}" VERSION_GREATER_EQUAL "15.0")
|
if("${XCODE_VERSION}" VERSION_GREATER_EQUAL "15.0" AND "${XCODE_VERSION}" VERSION_LESS "15.1")
|
||||||
# For Xcode 15 and newer, add extra link flags to fix crash in __cxx_global_var_init.
|
# Xcode 15.0 new linker crashes on weak symbols (114813650), fixed in 15.1.
|
||||||
message(STATUS "Using Xcode 15 or newer, adding extra link flags: -Wl,-ld_classic.")
|
message(STATUS "Xcode ${XCODE_VERSION}: adding -Wl,-ld_classic to work around weak symbol crash.")
|
||||||
target_link_options(${ENGINE_NAME} PUBLIC -Wl,-ld_classic)
|
target_link_options(${ENGINE_NAME} PUBLIC -Wl,-ld_classic)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ if("$ENV{COCOS_ENGINE_DEV}" EQUAL "1")
|
|||||||
set(WERROR_FLAGS "-Werror -Werror=return-type") # -Wshorten-64-to-32 -Werror=return-type
|
set(WERROR_FLAGS "-Werror -Werror=return-type") # -Wshorten-64-to-32 -Werror=return-type
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(WERROR_FLAGS " ${WERROR_FLAGS} -Wno-deprecated-declarations -Wno-deprecated-builtins -Wno-unqualified-std-cast-call")
|
set(WERROR_FLAGS " ${WERROR_FLAGS} -Wno-deprecated-declarations -Wno-deprecated-builtins -Wno-unqualified-std-cast-call -Wno-nontrivial-memcall")
|
||||||
elseif(LINUX)
|
elseif(LINUX)
|
||||||
set(WERROR_FLAGS " ${WERROR_FLAGS} -Wno-nullability-completeness -Wno-deprecated-declarations")
|
set(WERROR_FLAGS " ${WERROR_FLAGS} -Wno-nullability-completeness -Wno-deprecated-declarations")
|
||||||
elseif(ANDROID)
|
elseif(ANDROID)
|
||||||
|
|||||||
@@ -40,16 +40,16 @@ int32_t sorting2DCount{0};
|
|||||||
|
|
||||||
CC_FORCE_INLINE void fillIndexBuffers(RenderDrawInfo* drawInfo) { // NOLINT(readability-convert-member-functions-to-static)
|
CC_FORCE_INLINE void fillIndexBuffers(RenderDrawInfo* drawInfo) { // NOLINT(readability-convert-member-functions-to-static)
|
||||||
uint16_t* ib = drawInfo->getIDataBuffer();
|
uint16_t* ib = drawInfo->getIDataBuffer();
|
||||||
|
|
||||||
UIMeshBuffer* buffer = drawInfo->getMeshBuffer();
|
UIMeshBuffer* buffer = drawInfo->getMeshBuffer();
|
||||||
uint32_t indexOffset = buffer->getIndexOffset();
|
uint32_t indexOffset = buffer->getIndexOffset();
|
||||||
|
|
||||||
uint16_t* indexb = drawInfo->getIbBuffer();
|
uint16_t* indexb = drawInfo->getIbBuffer();
|
||||||
uint32_t indexCount = drawInfo->getIbCount();
|
uint32_t indexCount = drawInfo->getIbCount();
|
||||||
|
|
||||||
memcpy(&ib[indexOffset], indexb, indexCount * sizeof(uint16_t));
|
memcpy(&ib[indexOffset], indexb, indexCount * sizeof(uint16_t));
|
||||||
indexOffset += indexCount;
|
indexOffset += indexCount;
|
||||||
|
|
||||||
buffer->setIndexOffset(indexOffset);
|
buffer->setIndexOffset(indexOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ CC_FORCE_INLINE void fillColor(RenderEntity* entity, RenderDrawInfo* drawInfo) {
|
|||||||
uint32_t size = drawInfo->getVbCount() * stride;
|
uint32_t size = drawInfo->getVbCount() * stride;
|
||||||
float* vbBuffer = drawInfo->getVbBuffer();
|
float* vbBuffer = drawInfo->getVbBuffer();
|
||||||
Color temp = entity->getColor();
|
Color temp = entity->getColor();
|
||||||
|
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
for (int i = 0; i < size; i += stride) {
|
for (int i = 0; i < size; i += stride) {
|
||||||
offset = i + 5;
|
offset = i + 5;
|
||||||
@@ -91,9 +91,9 @@ CC_FORCE_INLINE void fillColor(RenderEntity* entity, RenderDrawInfo* drawInfo) {
|
|||||||
// Spine set 'UIRenderer._useVertexOpacity = true', it uses RGBA32 (4 bytes) color and fills color in Skeleton._updateColor and spine/simple.ts assembler.
|
// Spine set 'UIRenderer._useVertexOpacity = true', it uses RGBA32 (4 bytes) color and fills color in Skeleton._updateColor and spine/simple.ts assembler.
|
||||||
// So for Spine rendering, it will never go here to fill color.
|
// So for Spine rendering, it will never go here to fill color.
|
||||||
vbBuffer[offset] = static_cast<float>(temp.r) / 255.0F;
|
vbBuffer[offset] = static_cast<float>(temp.r) / 255.0F;
|
||||||
vbBuffer[offset+1] = static_cast<float>(temp.g) / 255.0F;
|
vbBuffer[offset + 1] = static_cast<float>(temp.g) / 255.0F;
|
||||||
vbBuffer[offset+2] = static_cast<float>(temp.b) / 255.0F;
|
vbBuffer[offset + 2] = static_cast<float>(temp.b) / 255.0F;
|
||||||
vbBuffer[offset+3] = entity->getOpacity();
|
vbBuffer[offset + 3] = entity->getOpacity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ Batcher2d::Batcher2d(Root* root)
|
|||||||
_root = root;
|
_root = root;
|
||||||
_device = _root->getDevice();
|
_device = _root->getDevice();
|
||||||
_stencilManager = StencilManager::getInstance();
|
_stencilManager = StencilManager::getInstance();
|
||||||
|
|
||||||
_recordedRendererInfoQueue.reserve(100);
|
_recordedRendererInfoQueue.reserve(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ Batcher2d::~Batcher2d() { // NOLINT
|
|||||||
_maskAttributes.clear();
|
_maskAttributes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ccstd::vector<RecordedRendererInfo> &Batcher2d::getRecordedRendererInfoQueue() {
|
ccstd::vector<RecordedRendererInfo>& Batcher2d::getRecordedRendererInfoQueue() {
|
||||||
return _recordedRendererInfoQueue;
|
return _recordedRendererInfoQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,11 +170,11 @@ void Batcher2d::fillBuffersAndMergeBatches() {
|
|||||||
for (auto* rootNode : _rootNodeArr) {
|
for (auto* rootNode : _rootNodeArr) {
|
||||||
// _batches will add by generateBatch
|
// _batches will add by generateBatch
|
||||||
walk(rootNode, 1, false);
|
walk(rootNode, 1, false);
|
||||||
|
|
||||||
if (ENABLE_SORTING_2D && sorting2DCount > 0) {
|
if (ENABLE_SORTING_2D && sorting2DCount > 0) {
|
||||||
flushRecordedUIRenderers();
|
flushRecordedUIRenderers();
|
||||||
}
|
}
|
||||||
|
|
||||||
generateBatch(_currEntity, _currDrawInfo);
|
generateBatch(_currEntity, _currDrawInfo);
|
||||||
|
|
||||||
auto* scene = rootNode->getScene()->getRenderScene();
|
auto* scene = rootNode->getScene()->getRenderScene();
|
||||||
@@ -186,7 +186,7 @@ void Batcher2d::fillBuffersAndMergeBatches() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batcher2d::handleUIRenderer(RenderEntity *entity) { // NOLINT(misc-no-recursion)
|
void Batcher2d::handleUIRenderer(RenderEntity* entity) { // NOLINT(misc-no-recursion)
|
||||||
uint32_t size = entity->getRenderDrawInfosSize();
|
uint32_t size = entity->getRenderDrawInfosSize();
|
||||||
for (uint32_t i = 0; i < size; i++) {
|
for (uint32_t i = 0; i < size; i++) {
|
||||||
auto* drawInfo = entity->getRenderDrawInfoAt(i);
|
auto* drawInfo = entity->getRenderDrawInfoAt(i);
|
||||||
@@ -195,25 +195,25 @@ void Batcher2d::handleUIRenderer(RenderEntity *entity) { // NOLINT(misc-no-recur
|
|||||||
entity->setVBColorDirty(false);
|
entity->setVBColorDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Batcher2d::recordUIRenderer(RenderEntity *entity) {
|
int32_t Batcher2d::recordUIRenderer(RenderEntity* entity) {
|
||||||
if (!ENABLE_SORTING_2D) return -1;
|
if (!ENABLE_SORTING_2D) return -1;
|
||||||
auto &queue = getRecordedRendererInfoQueue();
|
auto& queue = getRecordedRendererInfoQueue();
|
||||||
auto &info = queue.emplace_back();
|
auto& info = queue.emplace_back();
|
||||||
info.renderEntity = entity;
|
info.renderEntity = entity;
|
||||||
return static_cast<int32_t>(queue.size() - 1);
|
return static_cast<int32_t>(queue.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batcher2d::flushRecordedUIRenderers() { // NOLINT(misc-no-recursion)
|
void Batcher2d::flushRecordedUIRenderers() { // NOLINT(misc-no-recursion)
|
||||||
if (!ENABLE_SORTING_2D) return;
|
if (!ENABLE_SORTING_2D) return;
|
||||||
auto &queue = getRecordedRendererInfoQueue();
|
auto& queue = getRecordedRendererInfoQueue();
|
||||||
if (queue.empty()) return;
|
if (queue.empty()) return;
|
||||||
|
|
||||||
std::stable_sort(queue.begin(), queue.end(), [](const auto &a, const auto &b){
|
std::stable_sort(queue.begin(), queue.end(), [](const auto& a, const auto& b) {
|
||||||
return a.renderEntity->getPriority() < b.renderEntity->getPriority();
|
return a.renderEntity->getPriority() < b.renderEntity->getPriority();
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const auto &info : queue) {
|
for (const auto& info : queue) {
|
||||||
auto *entity = info.renderEntity;
|
auto* entity = info.renderEntity;
|
||||||
if (entity) {
|
if (entity) {
|
||||||
handleUIRenderer(entity);
|
handleUIRenderer(entity);
|
||||||
}
|
}
|
||||||
@@ -227,13 +227,13 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool parentColorDirty) { /
|
|||||||
}
|
}
|
||||||
bool breakWalk = false;
|
bool breakWalk = false;
|
||||||
auto* entity = static_cast<RenderEntity*>(node->getUserData());
|
auto* entity = static_cast<RenderEntity*>(node->getUserData());
|
||||||
|
|
||||||
const bool isCurrentColorDirty = node->_isColorDirty() || parentColorDirty;
|
const bool isCurrentColorDirty = node->_isColorDirty() || parentColorDirty;
|
||||||
const float localOpacity = node->_getLocalOpacity();
|
const float localOpacity = node->_getLocalOpacity();
|
||||||
// Keep the same logic as which in batcher-2d.ts
|
// Keep the same logic as which in batcher-2d.ts
|
||||||
const float finalOpacity = parentOpacity * localOpacity * (entity ? entity->getColorAlpha() : 1.F);
|
const float finalOpacity = parentOpacity * localOpacity * (entity ? entity->getColorAlpha() : 1.F);
|
||||||
node->_setFinalOpacity(finalOpacity);
|
node->_setFinalOpacity(finalOpacity);
|
||||||
|
|
||||||
const bool visible = math::isNotEqualF(finalOpacity, 0);
|
const bool visible = math::isNotEqualF(finalOpacity, 0);
|
||||||
|
|
||||||
if (entity) {
|
if (entity) {
|
||||||
@@ -244,7 +244,7 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool parentColorDirty) { /
|
|||||||
entity->setOpacity(finalOpacity);
|
entity->setOpacity(finalOpacity);
|
||||||
entity->setVBColorDirty(true);
|
entity->setVBColorDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ENABLE_SORTING_2D && sorting2DCount > 0) {
|
if (ENABLE_SORTING_2D && sorting2DCount > 0) {
|
||||||
if (entity->getIsMask()) {
|
if (entity->getIsMask()) {
|
||||||
flushRecordedUIRenderers();
|
flushRecordedUIRenderers();
|
||||||
@@ -257,7 +257,7 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool parentColorDirty) { /
|
|||||||
handleUIRenderer(entity);
|
handleUIRenderer(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity->getRenderEntityType() == RenderEntityType::CROSSED) {
|
if (entity->getRenderEntityType() == RenderEntityType::CROSSED) {
|
||||||
breakWalk = true;
|
breakWalk = true;
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool parentColorDirty) { /
|
|||||||
walk(child, thisOpacity, isCurrentColorDirty);
|
walk(child, thisOpacity, isCurrentColorDirty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCurrentColorDirty) {
|
if (isCurrentColorDirty) {
|
||||||
node->_setColorDirty(false);
|
node->_setColorDirty(false);
|
||||||
}
|
}
|
||||||
@@ -283,7 +283,7 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool parentColorDirty) { /
|
|||||||
flushRecordedUIRenderers();
|
flushRecordedUIRenderers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visible && _stencilManager->getMaskStackSize() > 0) {
|
if (visible && _stencilManager->getMaskStackSize() > 0) {
|
||||||
handlePostRender(entity);
|
handlePostRender(entity);
|
||||||
}
|
}
|
||||||
@@ -521,7 +521,7 @@ void Batcher2d::generateBatch(RenderEntity* entity, RenderDrawInfo* drawInfo) {
|
|||||||
curdrawBatch->setFirstIndex(indexOffset);
|
curdrawBatch->setFirstIndex(indexOffset);
|
||||||
curdrawBatch->setIndexCount(indexCount);
|
curdrawBatch->setIndexCount(indexCount);
|
||||||
curdrawBatch->fillPass(_currMaterial, depthStencil, dssHash);
|
curdrawBatch->fillPass(_currMaterial, depthStencil, dssHash);
|
||||||
const auto &passes = curdrawBatch->getPasses();
|
const auto& passes = curdrawBatch->getPasses();
|
||||||
if (!passes.empty()) {
|
if (!passes.empty()) {
|
||||||
const auto& pass = passes.at(0);
|
const auto& pass = passes.at(0);
|
||||||
if (entity->getUseLocal()) {
|
if (entity->getUseLocal()) {
|
||||||
@@ -695,6 +695,8 @@ void Batcher2d::reset() {
|
|||||||
_currSampler = nullptr;
|
_currSampler = nullptr;
|
||||||
|
|
||||||
// stencilManager
|
// stencilManager
|
||||||
|
_stencilManager->setMaskStackSize(0);
|
||||||
|
_stencilManager->setStencilStage(static_cast<uint32_t>(StencilStage::DISABLED));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batcher2d::insertMaskBatch(RenderEntity* entity) {
|
void Batcher2d::insertMaskBatch(RenderEntity* entity) {
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ using UIMeshBufferArray = ccstd::vector<UIMeshBuffer*>;
|
|||||||
using UIMeshBufferMap = ccstd::unordered_map<uint16_t, UIMeshBufferArray>;
|
using UIMeshBufferMap = ccstd::unordered_map<uint16_t, UIMeshBufferArray>;
|
||||||
|
|
||||||
struct RecordedRendererInfo {
|
struct RecordedRendererInfo {
|
||||||
RenderEntity *renderEntity{nullptr};
|
RenderEntity* renderEntity{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
class Batcher2d final {
|
class Batcher2d final {
|
||||||
public:
|
public:
|
||||||
static void setSorting2DCount(int32_t v);
|
static void setSorting2DCount(int32_t v);
|
||||||
|
|
||||||
Batcher2d();
|
Batcher2d();
|
||||||
explicit Batcher2d(Root* root);
|
explicit Batcher2d(Root* root);
|
||||||
~Batcher2d();
|
~Batcher2d();
|
||||||
@@ -87,10 +87,10 @@ private:
|
|||||||
void createClearModel();
|
void createClearModel();
|
||||||
|
|
||||||
gfx::DescriptorSet* getDescriptorSet(gfx::Texture* texture, gfx::Sampler* sampler, const gfx::DescriptorSetLayout* dsLayout);
|
gfx::DescriptorSet* getDescriptorSet(gfx::Texture* texture, gfx::Sampler* sampler, const gfx::DescriptorSetLayout* dsLayout);
|
||||||
|
|
||||||
ccstd::vector<RecordedRendererInfo> &getRecordedRendererInfoQueue();
|
ccstd::vector<RecordedRendererInfo>& getRecordedRendererInfoQueue();
|
||||||
void handleUIRenderer(RenderEntity *entity);
|
void handleUIRenderer(RenderEntity* entity);
|
||||||
int32_t recordUIRenderer(RenderEntity *entity);
|
int32_t recordUIRenderer(RenderEntity* entity);
|
||||||
void flushRecordedUIRenderers();
|
void flushRecordedUIRenderers();
|
||||||
|
|
||||||
StencilManager* _stencilManager{nullptr};
|
StencilManager* _stencilManager{nullptr};
|
||||||
@@ -103,7 +103,7 @@ private:
|
|||||||
// manage memory manually
|
// manage memory manually
|
||||||
ccstd::vector<scene::DrawBatch2D*> _batches;
|
ccstd::vector<scene::DrawBatch2D*> _batches;
|
||||||
memop::Pool<scene::DrawBatch2D> _drawBatchPool;
|
memop::Pool<scene::DrawBatch2D> _drawBatchPool;
|
||||||
|
|
||||||
ccstd::vector<RecordedRendererInfo> _recordedRendererInfoQueue;
|
ccstd::vector<RecordedRendererInfo> _recordedRendererInfoQueue;
|
||||||
|
|
||||||
// weak reference
|
// weak reference
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "2d/renderer/UIMeshBuffer.h"
|
#include "2d/renderer/UIMeshBuffer.h"
|
||||||
#include "base/Ptr.h"
|
|
||||||
#include "base/Macros.h"
|
#include "base/Macros.h"
|
||||||
|
#include "base/Ptr.h"
|
||||||
#include "base/TypeDef.h"
|
#include "base/TypeDef.h"
|
||||||
#include "bindings/utils/BindingUtils.h"
|
#include "bindings/utils/BindingUtils.h"
|
||||||
#include "core/ArrayBuffer.h"
|
#include "core/ArrayBuffer.h"
|
||||||
@@ -115,7 +115,7 @@ public:
|
|||||||
inline void setIsMeshBuffer(bool isMeshBuffer) {
|
inline void setIsMeshBuffer(bool isMeshBuffer) {
|
||||||
_drawInfoAttrs._isMeshBuffer = isMeshBuffer ? 1 : 0;
|
_drawInfoAttrs._isMeshBuffer = isMeshBuffer ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isVertexPositionInWorld() const {
|
inline bool isVertexPositionInWorld() const {
|
||||||
return _drawInfoAttrs._isVertexPositionInWorld != 0;
|
return _drawInfoAttrs._isVertexPositionInWorld != 0;
|
||||||
}
|
}
|
||||||
@@ -262,9 +262,9 @@ private:
|
|||||||
struct DrawInfoAttrs {
|
struct DrawInfoAttrs {
|
||||||
RenderDrawInfoType _drawInfoType{RenderDrawInfoType::COMP};
|
RenderDrawInfoType _drawInfoType{RenderDrawInfoType::COMP};
|
||||||
bool _vertDirty{false};
|
bool _vertDirty{false};
|
||||||
uint8_t _isMeshBuffer: 1;
|
uint8_t _isMeshBuffer : 1;
|
||||||
uint8_t _isVertexPositionInWorld: 1;
|
uint8_t _isVertexPositionInWorld : 1;
|
||||||
uint8_t _padding: 6;
|
uint8_t _padding : 6;
|
||||||
uint8_t _stride{0};
|
uint8_t _stride{0};
|
||||||
uint16_t _bufferId{0};
|
uint16_t _bufferId{0};
|
||||||
uint16_t _accId{0};
|
uint16_t _accId{0};
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ RenderEntity::RenderEntity(RenderEntityType type) : _renderEntityType(type) {
|
|||||||
} else {
|
} else {
|
||||||
ccnew_placement(&_dynamicDrawInfos) ccstd::vector<RenderDrawInfo*>();
|
ccnew_placement(&_dynamicDrawInfos) ccstd::vector<RenderDrawInfo*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
_entityAttrLayout.enabledIndex = 0;
|
_entityAttrLayout.enabledIndex = 0;
|
||||||
_entityAttrLayout.useLocal = 0;
|
_entityAttrLayout.useLocal = 0;
|
||||||
_entityAttrLayout.paddings = 0;
|
_entityAttrLayout.paddings = 0;
|
||||||
|
|
||||||
_entitySharedBufferActor.initialize(&_entityAttrLayout, sizeof(EntityAttrLayout));
|
_entitySharedBufferActor.initialize(&_entityAttrLayout, sizeof(EntityAttrLayout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ enum class MaskMode : uint8_t {
|
|||||||
MASK_NODE_INVERTED
|
MASK_NODE_INVERTED
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class FillColorType: uint8_t {
|
enum class FillColorType : uint8_t {
|
||||||
COLOR = 0,
|
COLOR = 0,
|
||||||
VERTEX,
|
VERTEX,
|
||||||
};
|
};
|
||||||
@@ -62,9 +62,9 @@ struct EntityAttrLayout {
|
|||||||
uint8_t colorA{255};
|
uint8_t colorA{255};
|
||||||
uint8_t maskMode{0};
|
uint8_t maskMode{0};
|
||||||
FillColorType fillColorType{FillColorType::COLOR};
|
FillColorType fillColorType{FillColorType::COLOR};
|
||||||
uint8_t enabledIndex: 1;
|
uint8_t enabledIndex : 1;
|
||||||
uint8_t useLocal: 1;
|
uint8_t useLocal : 1;
|
||||||
uint8_t paddings: 6;
|
uint8_t paddings : 6;
|
||||||
uint8_t paddings2{0};
|
uint8_t paddings2{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
inline void setUseLocal(bool useLocal) {
|
inline void setUseLocal(bool useLocal) {
|
||||||
_entityAttrLayout.useLocal = useLocal;
|
_entityAttrLayout.useLocal = useLocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FillColorType getFillColorType() const { return _entityAttrLayout.fillColorType; }
|
inline FillColorType getFillColorType() const { return _entityAttrLayout.fillColorType; }
|
||||||
|
|
||||||
inline Node* getNode() const { return _node; }
|
inline Node* getNode() const { return _node; }
|
||||||
@@ -142,7 +142,7 @@ public:
|
|||||||
inline RenderDrawInfo* getRenderDrawInfoAt(uint32_t index) {
|
inline RenderDrawInfo* getRenderDrawInfoAt(uint32_t index) {
|
||||||
return _renderEntityType == RenderEntityType::STATIC ? &(_staticDrawInfos[index]) : _dynamicDrawInfos[index];
|
return _renderEntityType == RenderEntityType::STATIC ? &(_staticDrawInfos[index]) : _dynamicDrawInfos[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t getPriority() const { return _entityAttrLayout.priority; }
|
inline uint32_t getPriority() const { return _entityAttrLayout.priority; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -152,7 +152,7 @@ private:
|
|||||||
|
|
||||||
// weak reference
|
// weak reference
|
||||||
Node* _renderTransform{nullptr};
|
Node* _renderTransform{nullptr};
|
||||||
|
|
||||||
bindings::NativeMemorySharedToScriptActor _entitySharedBufferActor;
|
bindings::NativeMemorySharedToScriptActor _entitySharedBufferActor;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
@@ -160,13 +160,13 @@ private:
|
|||||||
ccstd::vector<RenderDrawInfo*> _dynamicDrawInfos;
|
ccstd::vector<RenderDrawInfo*> _dynamicDrawInfos;
|
||||||
};
|
};
|
||||||
EntityAttrLayout _entityAttrLayout;
|
EntityAttrLayout _entityAttrLayout;
|
||||||
|
|
||||||
StencilStage _stencilStage{StencilStage::DISABLED};
|
StencilStage _stencilStage{StencilStage::DISABLED};
|
||||||
RenderEntityType _renderEntityType{RenderEntityType::STATIC};
|
RenderEntityType _renderEntityType{RenderEntityType::STATIC};
|
||||||
uint8_t _staticDrawInfoSize{0};
|
uint8_t _staticDrawInfoSize{0};
|
||||||
bool _vbColorDirty{true};
|
bool _vbColorDirty{true};
|
||||||
uint8_t _paddings[1];
|
uint8_t _paddings[1];
|
||||||
|
|
||||||
float _opacity{1.0F};
|
float _opacity{1.0F};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,12 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "base/Ptr.h"
|
|
||||||
#include "base/Macros.h"
|
#include "base/Macros.h"
|
||||||
|
#include "base/Ptr.h"
|
||||||
#include "base/TypeDef.h"
|
#include "base/TypeDef.h"
|
||||||
#include "renderer/gfx-base/GFXInputAssembler.h"
|
|
||||||
#include "renderer/gfx-base/GFXDef-common.h"
|
|
||||||
#include "renderer/gfx-base/GFXBuffer.h"
|
#include "renderer/gfx-base/GFXBuffer.h"
|
||||||
|
#include "renderer/gfx-base/GFXDef-common.h"
|
||||||
|
#include "renderer/gfx-base/GFXInputAssembler.h"
|
||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
|
|||||||