diff --git a/3.6.3/native/engine/android/CMakeLists.txt b/3.6.3/native/engine/android/CMakeLists.txt new file mode 100644 index 0000000..1a1bec4 --- /dev/null +++ b/3.6.3/native/engine/android/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) + +option(APP_NAME "Project Name" "ui-sorting-group") +project(${APP_NAME} CXX) +set(CC_LIB_NAME cocos) +set(CC_PROJECT_DIR ${CMAKE_CURRENT_LIST_DIR}) +set(CC_PROJ_SOURCES) +set(CC_COMMON_SOURCES) +set(CC_ALL_SOURCES) + +include(${CMAKE_CURRENT_LIST_DIR}/../common/CMakeLists.txt) + +cc_android_before_target(${CC_LIB_NAME}) +add_library(${CC_LIB_NAME} SHARED ${CC_ALL_SOURCES}) +cc_android_after_target(${CC_LIB_NAME}) diff --git a/3.6.3/native/engine/android/Post-service.cmake b/3.6.3/native/engine/android/Post-service.cmake new file mode 100644 index 0000000..16fd033 --- /dev/null +++ b/3.6.3/native/engine/android/Post-service.cmake @@ -0,0 +1 @@ +# Supported for Cocos Service! \ No newline at end of file diff --git a/3.6.3/native/engine/android/Pre-service.cmake b/3.6.3/native/engine/android/Pre-service.cmake new file mode 100644 index 0000000..16fd033 --- /dev/null +++ b/3.6.3/native/engine/android/Pre-service.cmake @@ -0,0 +1 @@ +# Supported for Cocos Service! \ No newline at end of file diff --git a/3.6.3/native/engine/android/app/AndroidManifest.xml b/3.6.3/native/engine/android/app/AndroidManifest.xml new file mode 100644 index 0000000..7e12819 --- /dev/null +++ b/3.6.3/native/engine/android/app/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/3.6.3/native/engine/android/app/build.gradle b/3.6.3/native/engine/android/app/build.gradle new file mode 100644 index 0000000..540d6b6 --- /dev/null +++ b/3.6.3/native/engine/android/app/build.gradle @@ -0,0 +1,104 @@ +import org.apache.tools.ant.taskdefs.condition.Os + +apply plugin: 'com.android.application' + +RES_PATH = RES_PATH.replace("\\", "/") +COCOS_ENGINE_PATH = COCOS_ENGINE_PATH.replace("\\", "/") + +buildDir = "${RES_PATH}/proj/build/$project.name" +android { + compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + buildToolsVersion PROP_BUILD_TOOLS_VERSION + ndkPath PROP_NDK_PATH + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + applicationId APPLICATION_ID + minSdkVersion PROP_MIN_SDK_VERSION + targetSdkVersion PROP_TARGET_SDK_VERSION + versionCode 1 + versionName "1.0" + + externalNativeBuild { + cmake { + targets "cocos" + arguments "-DRES_DIR=${RES_PATH}", "-DCOCOS_X_PATH=${COCOS_ENGINE_PATH}", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE", "-DANDROID_LD=gold" + } + ndk { abiFilters PROP_APP_ABI.split(':') } + } + } + + sourceSets.main { + java.srcDirs "../src", "src" + res.srcDirs "../res", 'res' + jniLibs.srcDirs "../libs", 'libs' + manifest.srcFile "AndroidManifest.xml" + assets.srcDir "${RES_PATH}/data" + jniLibs { + // Vulkan validation layer + // srcDir "${android.ndkDirectory}/sources/third_party/vulkan/src/build-android/jniLibs" + } + } + + externalNativeBuild { + cmake { + path "../CMakeLists.txt" + buildStagingDirectory "${RES_PATH}/proj/build" + } + } + + signingConfigs { + + release { + if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) { + storeFile file(RELEASE_STORE_FILE) + storePassword RELEASE_STORE_PASSWORD + keyAlias RELEASE_KEY_ALIAS + keyPassword RELEASE_KEY_PASSWORD + } + } + } + + buildTypes { + release { + debuggable false + jniDebuggable false + renderscriptDebuggable false + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + if (project.hasProperty("RELEASE_STORE_FILE")) { + signingConfig signingConfigs.release + } + + externalNativeBuild { + cmake { + // switch HIDE_SYMBOLS to OFF to skip compilation flag `-fvisibility=hidden` + arguments "-DHIDE_SYMBOLS=ON" + } + } + + // resValue "string", "app_name", PROP_APP_NAME + } + + debug { + debuggable true + jniDebuggable true + renderscriptDebuggable true + // resValue "string", "app_name", "${PROP_APP_NAME}-dbg" + // applicationIdSuffix ".debug" + } + } +} + +dependencies { + implementation fileTree(dir: '../libs', include: ['*.jar','*.aar']) + implementation fileTree(dir: 'libs', include: ['*.jar','*.aar']) + implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar']) + implementation project(':libservice') + implementation project(':libcocos') +} diff --git a/3.6.3/native/engine/android/app/proguard-rules.pro b/3.6.3/native/engine/android/app/proguard-rules.pro new file mode 100644 index 0000000..dbb43fb --- /dev/null +++ b/3.6.3/native/engine/android/app/proguard-rules.pro @@ -0,0 +1,42 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Proguard Cocos2d-x-lite for release +-keep public class com.cocos.** { *; } +-dontwarn com.cocos.** + +# Proguard Apache HTTP for release +-keep class org.apache.http.** { *; } +-dontwarn org.apache.http.** + +# Proguard okhttp for release +-keep class okhttp3.** { *; } +-dontwarn okhttp3.** + +-keep class okio.** { *; } +-dontwarn okio.** + +# Proguard Android Webivew for release. you can comment if you are not using a webview +-keep public class android.net.http.SslError +-keep public class android.webkit.WebViewClient + +-keep public class com.google.** { *; } + +-dontwarn android.webkit.WebView +-dontwarn android.net.http.SslError +-dontwarn android.webkit.WebViewClient diff --git a/3.6.3/native/engine/android/app/src/com/cocos/game/AppActivity.java b/3.6.3/native/engine/android/app/src/com/cocos/game/AppActivity.java new file mode 100644 index 0000000..5aaece8 --- /dev/null +++ b/3.6.3/native/engine/android/app/src/com/cocos/game/AppActivity.java @@ -0,0 +1,125 @@ +/**************************************************************************** +Copyright (c) 2015-2016 Chukong Technologies Inc. +Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + +http://www.cocos2d-x.org + +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. +****************************************************************************/ +package com.cocos.game; + +import android.os.Bundle; +import android.content.Intent; +import android.content.res.Configuration; + +import com.cocos.service.SDKWrapper; +import com.cocos.lib.CocosActivity; + +public class AppActivity extends CocosActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // DO OTHER INITIALIZATION BELOW + SDKWrapper.shared().init(this); + + } + + @Override + protected void onResume() { + super.onResume(); + SDKWrapper.shared().onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + SDKWrapper.shared().onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + // Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508 + if (!isTaskRoot()) { + return; + } + SDKWrapper.shared().onDestroy(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + SDKWrapper.shared().onActivityResult(requestCode, resultCode, data); + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + SDKWrapper.shared().onNewIntent(intent); + } + + @Override + protected void onRestart() { + super.onRestart(); + SDKWrapper.shared().onRestart(); + } + + @Override + protected void onStop() { + super.onStop(); + SDKWrapper.shared().onStop(); + } + + @Override + public void onBackPressed() { + SDKWrapper.shared().onBackPressed(); + super.onBackPressed(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + SDKWrapper.shared().onConfigurationChanged(newConfig); + super.onConfigurationChanged(newConfig); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + SDKWrapper.shared().onRestoreInstanceState(savedInstanceState); + super.onRestoreInstanceState(savedInstanceState); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + SDKWrapper.shared().onSaveInstanceState(outState); + super.onSaveInstanceState(outState); + } + + @Override + protected void onStart() { + SDKWrapper.shared().onStart(); + super.onStart(); + } + + @Override + public void onLowMemory() { + SDKWrapper.shared().onLowMemory(); + super.onLowMemory(); + } +} diff --git a/3.6.3/native/engine/android/build-cfg.json b/3.6.3/native/engine/android/build-cfg.json new file mode 100644 index 0000000..fb658e2 --- /dev/null +++ b/3.6.3/native/engine/android/build-cfg.json @@ -0,0 +1,8 @@ +{ + "ndk_module_path" :[ + "${COCOS_ROOT}", + "${COCOS_ROOT}/cocos", + "${COCOS_ROOT}/external" + ], + "copy_resources": [] +} diff --git a/3.6.3/native/engine/android/build.gradle b/3.6.3/native/engine/android/build.gradle new file mode 100644 index 0000000..2ae589d --- /dev/null +++ b/3.6.3/native/engine/android/build.gradle @@ -0,0 +1,31 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + mavenCentral() + // jcenter() // keeped as anchor, will be removed soon + } + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + mavenCentral() + // jcenter() // keeped as anchor, will be removed soon + flatDir { + dirs 'libs' + } + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/3.6.3/native/engine/android/instantapp/AndroidManifest.xml b/3.6.3/native/engine/android/instantapp/AndroidManifest.xml new file mode 100644 index 0000000..2bf48de --- /dev/null +++ b/3.6.3/native/engine/android/instantapp/AndroidManifest.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/3.6.3/native/engine/android/instantapp/build.gradle b/3.6.3/native/engine/android/instantapp/build.gradle new file mode 100644 index 0000000..cac6ddc --- /dev/null +++ b/3.6.3/native/engine/android/instantapp/build.gradle @@ -0,0 +1,101 @@ +import org.apache.tools.ant.taskdefs.condition.Os + +apply plugin: 'com.android.application' + +RES_PATH = RES_PATH.replace("\\", "/") +COCOS_ENGINE_PATH = COCOS_ENGINE_PATH.replace("\\", "/") +buildDir = "${RES_PATH}/proj/build/$project.name" + +android { + compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + buildToolsVersion PROP_BUILD_TOOLS_VERSION + ndkPath PROP_NDK_PATH + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + applicationId "com.lcc.test" + minSdkVersion PROP_MIN_SDK_VERSION + targetSdkVersion PROP_TARGET_SDK_VERSION + versionCode 1 + versionName "1.0" + + externalNativeBuild { + cmake { + targets "cocos" + arguments "-DRES_DIR=${RES_PATH}", "-DCOCOS_X_PATH=${COCOS_ENGINE_PATH}","-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE", "-DANDROID_LD=gold" + cppFlags "-frtti -fexceptions -fsigned-char -DANDROID_INSTANT=1" + } + ndk { abiFilters PROP_APP_ABI.split(':') } + } + } + + sourceSets.main { + java.srcDirs "../src", "src" + res.srcDirs "../res", 'res' + jniLibs.srcDirs "../libs", 'libs' + manifest.srcFile "AndroidManifest.xml" + assets.srcDir "${RES_PATH}/data" + } + + externalNativeBuild { + cmake { + path "../CMakeLists.txt" + buildStagingDirectory "${RES_PATH}/proj/build" + } + } + + signingConfigs { + + release { + if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) { + storeFile file(RELEASE_STORE_FILE) + storePassword RELEASE_STORE_PASSWORD + keyAlias RELEASE_KEY_ALIAS + keyPassword RELEASE_KEY_PASSWORD + } + } + } + + buildTypes { + release { + debuggable false + jniDebuggable false + renderscriptDebuggable false + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + if (project.hasProperty("RELEASE_STORE_FILE")) { + signingConfig signingConfigs.release + } + + externalNativeBuild { + cmake { + // switch HIDE_SYMBOLS to OFF to skip compilation flag `-fvisibility=hidden` + arguments "-DHIDE_SYMBOLS=ON" + } + } + + // resValue "string", "app_name", PROP_APP_NAME + } + + debug { + debuggable true + jniDebuggable true + renderscriptDebuggable true + // resValue "string", "app_name", "${PROP_APP_NAME}-dbg" + // applicationIdSuffix ".debug" + } + } +} + +dependencies { + implementation fileTree(dir: '../libs', include: ['*.jar','*.aar']) + implementation fileTree(dir: 'libs', include: ['*.jar','*.aar']) + implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar']) + implementation project(':libservice') + implementation project(':libcocos') +} diff --git a/3.6.3/native/engine/android/instantapp/proguard-rules.pro b/3.6.3/native/engine/android/instantapp/proguard-rules.pro new file mode 100644 index 0000000..dbb43fb --- /dev/null +++ b/3.6.3/native/engine/android/instantapp/proguard-rules.pro @@ -0,0 +1,42 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Proguard Cocos2d-x-lite for release +-keep public class com.cocos.** { *; } +-dontwarn com.cocos.** + +# Proguard Apache HTTP for release +-keep class org.apache.http.** { *; } +-dontwarn org.apache.http.** + +# Proguard okhttp for release +-keep class okhttp3.** { *; } +-dontwarn okhttp3.** + +-keep class okio.** { *; } +-dontwarn okio.** + +# Proguard Android Webivew for release. you can comment if you are not using a webview +-keep public class android.net.http.SslError +-keep public class android.webkit.WebViewClient + +-keep public class com.google.** { *; } + +-dontwarn android.webkit.WebView +-dontwarn android.net.http.SslError +-dontwarn android.webkit.WebViewClient diff --git a/3.6.3/native/engine/android/instantapp/src/com/cocos/game/InstantActivity.java b/3.6.3/native/engine/android/instantapp/src/com/cocos/game/InstantActivity.java new file mode 100644 index 0000000..318e839 --- /dev/null +++ b/3.6.3/native/engine/android/instantapp/src/com/cocos/game/InstantActivity.java @@ -0,0 +1,125 @@ +/**************************************************************************** +Copyright (c) 2015-2016 Chukong Technologies Inc. +Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + +http://www.cocos2d-x.org + +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. +****************************************************************************/ +package com.cocos.game; + +import android.os.Bundle; +import android.content.Intent; +import android.content.res.Configuration; + +import com.cocos.service.SDKWrapper; +import com.cocos.lib.CocosActivity; + +public class InstantActivity extends CocosActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // DO OTHER INITIALIZATION BELOW + SDKWrapper.shared().init(this); + + } + + @Override + protected void onResume() { + super.onResume(); + SDKWrapper.shared().onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + SDKWrapper.shared().onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + // Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508 + if (!isTaskRoot()) { + return; + } + SDKWrapper.shared().onDestroy(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + SDKWrapper.shared().onActivityResult(requestCode, resultCode, data); + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + SDKWrapper.shared().onNewIntent(intent); + } + + @Override + protected void onRestart() { + super.onRestart(); + SDKWrapper.shared().onRestart(); + } + + @Override + protected void onStop() { + super.onStop(); + SDKWrapper.shared().onStop(); + } + + @Override + public void onBackPressed() { + SDKWrapper.shared().onBackPressed(); + super.onBackPressed(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + SDKWrapper.shared().onConfigurationChanged(newConfig); + super.onConfigurationChanged(newConfig); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + SDKWrapper.shared().onRestoreInstanceState(savedInstanceState); + super.onRestoreInstanceState(savedInstanceState); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + SDKWrapper.shared().onSaveInstanceState(outState); + super.onSaveInstanceState(outState); + } + + @Override + protected void onStart() { + SDKWrapper.shared().onStart(); + super.onStart(); + } + + @Override + public void onLowMemory() { + SDKWrapper.shared().onLowMemory(); + super.onLowMemory(); + } +} diff --git a/3.6.3/native/engine/android/res/mipmap-hdpi/ic_launcher.png b/3.6.3/native/engine/android/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..888c0d5 Binary files /dev/null and b/3.6.3/native/engine/android/res/mipmap-hdpi/ic_launcher.png differ diff --git a/3.6.3/native/engine/android/res/mipmap-mdpi/ic_launcher.png b/3.6.3/native/engine/android/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..d5e3c77 Binary files /dev/null and b/3.6.3/native/engine/android/res/mipmap-mdpi/ic_launcher.png differ diff --git a/3.6.3/native/engine/android/res/mipmap-xhdpi/ic_launcher.png b/3.6.3/native/engine/android/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..2b6f32a Binary files /dev/null and b/3.6.3/native/engine/android/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/3.6.3/native/engine/android/res/mipmap-xxhdpi/ic_launcher.png b/3.6.3/native/engine/android/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..2f1e5a6 Binary files /dev/null and b/3.6.3/native/engine/android/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/3.6.3/native/engine/android/res/mipmap-xxxhdpi/ic_launcher.png b/3.6.3/native/engine/android/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..a9ebc79 Binary files /dev/null and b/3.6.3/native/engine/android/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/3.6.3/native/engine/android/res/values/strings.xml b/3.6.3/native/engine/android/res/values/strings.xml new file mode 100644 index 0000000..2e222d1 --- /dev/null +++ b/3.6.3/native/engine/android/res/values/strings.xml @@ -0,0 +1,3 @@ + + ui-sorting-group + diff --git a/3.6.3/native/engine/common/CMakeLists.txt b/3.6.3/native/engine/common/CMakeLists.txt new file mode 100644 index 0000000..936b69f --- /dev/null +++ b/3.6.3/native/engine/common/CMakeLists.txt @@ -0,0 +1,54 @@ +enable_language(C ASM) +set(DEVELOPMENT_TEAM "" CACHE STRING "APPLE Developtment Team") +set(RES_DIR "" CACHE STRING "Resource path") +set(COCOS_X_PATH "" CACHE STRING "Path to engine/native/") + +set(TARGET_OSX_VERSION "10.14" CACHE STRING "Target MacOSX version" FORCE) +set(TARGET_IOS_VERSION "11.0" CACHE STRING "Target iOS version" FORCE) + +set(CMAKE_CXX_STANDARD 17) +option(CC_DEBUG_FORCE "Force enable CC_DEBUG in release mode" OFF) +option(USE_SE_V8 "Use V8 JavaScript Engine" ON) +option(USE_V8_DEBUGGER "Compile v8 inspector ws server" ON) +option(USE_V8_DEBUGGER_FORCE "Force enable debugger in release mode" OFF) +option(USE_SOCKET "Enable WebSocket & SocketIO" ON) +option(USE_AUDIO "Enable Audio" ON) #Enable AudioEngine +option(USE_EDIT_BOX "Enable EditBox" ON) +option(USE_SE_JSC "Use JavaScriptCore on MacOSX/iOS" OFF) +option(USE_VIDEO "Enable VideoPlayer Component" ON) +option(USE_WEBVIEW "Enable WebView Component" ON) +option(USE_MIDDLEWARE "Enable Middleware" ON) +option(USE_DRAGONBONES "Enable Dragonbones" ON) +option(USE_SPINE "Enable Spine" ON) +option(USE_WEBSOCKET_SERVER "Enable WebSocket Server" OFF) +option(USE_JOB_SYSTEM_TASKFLOW "Use taskflow as job system backend" OFF) +option(USE_JOB_SYSTEM_TBB "Use tbb as job system backend" OFF) +option(USE_PHYSICS_PHYSX "Use PhysX Physics" ON) +option(USE_OCCLUSION_QUERY "Use Occlusion Query" ON) +option(USE_DEBUG_RENDERER "Use Debug Renderer" ON) +option(USE_GEOMETRY_RENDERER "Use Geometry Renderer" ON) +option(USE_WEBP "Use Webp" ON) + +if(NOT RES_DIR) + message(FATAL_ERROR "RES_DIR is not set!") +endif() + +include(${RES_DIR}/proj/cfg.cmake) + +if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/localCfg.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/localCfg.cmake) +endif() + +if(NOT COCOS_X_PATH) + message(FATAL_ERROR "COCOS_X_PATH is not set!") +endif() + +# 引入lcc-ui-sorting-group native部分 +include(${CMAKE_CURRENT_LIST_DIR}/../lcc-ui-sorting-group-native/CMakeLists.txt) + +include(${COCOS_X_PATH}/CMakeLists.txt) + +list(APPEND CC_COMMON_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/Classes/Game.h + ${CMAKE_CURRENT_LIST_DIR}/Classes/Game.cpp +) diff --git a/3.6.3/native/engine/common/Classes/Game.cpp b/3.6.3/native/engine/common/Classes/Game.cpp new file mode 100644 index 0000000..c15664c --- /dev/null +++ b/3.6.3/native/engine/common/Classes/Game.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You + shall not use Cocos Creator software for developing other software or tools + that's used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to + you. + + 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. + ****************************************************************************/ +#include "Game.h" + +#ifndef GAME_NAME +#define GAME_NAME "CocosGame"; +#endif + +#ifndef SCRIPT_XXTEAKEY +#define SCRIPT_XXTEAKEY ""; +#endif + +Game::Game() = default; + +int Game::init() { + _windowInfo.title = GAME_NAME; + // configurate window size + // _windowInfo.height = 600; + // _windowInfo.width = 800; + +#if CC_DEBUG + _debuggerInfo.enabled = true; +#else + _debuggerInfo.enabled = false; +#endif + _debuggerInfo.port = 6086; + _debuggerInfo.address = "0.0.0.0"; + _debuggerInfo.pauseOnStart = false; + + _xxteaKey = SCRIPT_XXTEAKEY; + + BaseGame::init(); + return 0; +} + +void Game::onPause() { BaseGame::onPause(); } + +void Game::onResume() { BaseGame::onResume(); } + +void Game::onClose() { BaseGame::onClose(); } + +CC_REGISTER_APPLICATION(Game); diff --git a/3.6.3/native/engine/common/Classes/Game.h b/3.6.3/native/engine/common/Classes/Game.h new file mode 100644 index 0000000..521615e --- /dev/null +++ b/3.6.3/native/engine/common/Classes/Game.h @@ -0,0 +1,44 @@ +/**************************************************************************** + Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You + shall not use Cocos Creator software for developing other software or tools + that's used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to + you. + + 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. + ****************************************************************************/ +#pragma once + +#include "cocos/cocos.h" + +/** + @brief The cocos2d Application. + + The reason for implement as private inheritance is to hide some interface call + by Director. + */ +class Game : public cc::BaseGame { +public: + Game(); + int init() override; + // bool init() override; + void onPause() override; + void onResume() override; + void onClose() override; +}; diff --git a/3.6.3/native/engine/common/cocos-version.json b/3.6.3/native/engine/common/cocos-version.json new file mode 100644 index 0000000..6519c54 --- /dev/null +++ b/3.6.3/native/engine/common/cocos-version.json @@ -0,0 +1 @@ +{"version":"3.6.3","skipCheck":false} diff --git a/3.6.3/native/engine/common/localCfg.cmake b/3.6.3/native/engine/common/localCfg.cmake new file mode 100644 index 0000000..f17333e --- /dev/null +++ b/3.6.3/native/engine/common/localCfg.cmake @@ -0,0 +1,3 @@ +## Add or overwrite options from cfg.cmake. +## This file is ignored from git. +# set(NODE_EXECUTABLE /opt/...) \ No newline at end of file diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/CMakeLists.txt b/3.6.3/native/engine/lcc-ui-sorting-group-native/CMakeLists.txt new file mode 100644 index 0000000..f0fba3d --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/CMakeLists.txt @@ -0,0 +1,36 @@ + +if(NOT DEFINED COCOS_SOURCE_PLUGIN_EXCULDE) + set(COCOS_SOURCE_PLUGIN_EXCULDE) +endif() +if(NOT DEFINED COCOS_SOURCE_PLUGIN_LIST) + set(COCOS_SOURCE_PLUGIN_LIST) +endif() +if(NOT DEFINED COCOS_SOURCE_PLUGIN_INCLUDES) + set(COCOS_SOURCE_PLUGIN_INCLUDES) +endif() + +# 排除替换源文件 +list(APPEND COCOS_SOURCE_PLUGIN_EXCULDE + "${COCOS_X_PATH}/cocos/2d/renderer/Batcher2d.h" + "${COCOS_X_PATH}/cocos/2d/renderer/Batcher2d.cpp" + "${COCOS_X_PATH}/cocos/2d/renderer/RenderEntity.h" + "${COCOS_X_PATH}/cocos/2d/renderer/RenderEntity.cpp" + "${COCOS_X_PATH}/cocos/core/scene-graph/Node.h" + "${COCOS_X_PATH}/cocos/core/scene-graph/Node.cpp" +) + +# 添加替换源文件 +list(APPEND COCOS_SOURCE_PLUGIN_LIST + "${CMAKE_CURRENT_LIST_DIR}/native/cocos/2d/renderer/Batcher2d.h" + "${CMAKE_CURRENT_LIST_DIR}/native/cocos/2d/renderer/Batcher2d.cpp" + "${CMAKE_CURRENT_LIST_DIR}/native/cocos/2d/renderer/RenderEntity.h" + "${CMAKE_CURRENT_LIST_DIR}/native/cocos/2d/renderer/RenderEntity.cpp" + "${CMAKE_CURRENT_LIST_DIR}/native/cocos/core/scene-graph/Node.h" + "${CMAKE_CURRENT_LIST_DIR}/native/cocos/core/scene-graph/Node.cpp" +) + +# 添加替换源文件 +list(APPEND COCOS_SOURCE_PLUGIN_INCLUDES + "${CMAKE_CURRENT_LIST_DIR}/native" + "${CMAKE_CURRENT_LIST_DIR}/native/cocos" +) diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/backup/CMakeLists.txt b/3.6.3/native/engine/lcc-ui-sorting-group-native/backup/CMakeLists.txt new file mode 100644 index 0000000..4c1fab3 --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/backup/CMakeLists.txt @@ -0,0 +1,3189 @@ +include(${CMAKE_CURRENT_LIST_DIR}/cmake/predefine.cmake) + +################################# engine source code ################################## +set(CWD ${CMAKE_CURRENT_LIST_DIR}) +set(COCOS_SOURCE_LIST) +set(ENGINE_NAME cocos_engine) + +# Should be enable someday in the future +# set(CMAKE_CXX_FLAGS "${WERROR_FLAGS}") + +################################# options ############################################ +# default fallback options +cc_set_if_undefined(CC_DEBUG_FORCE OFF) +cc_set_if_undefined(USE_SE_V8 ON) +cc_set_if_undefined(USE_SE_SM OFF) +cc_set_if_undefined(USE_V8_DEBUGGER ON) +cc_set_if_undefined(USE_V8_DEBUGGER_FORCE OFF) +cc_set_if_undefined(USE_SOCKET ON) +cc_set_if_undefined(USE_AUDIO ON) +cc_set_if_undefined(USE_EDIT_BOX ON) +cc_set_if_undefined(USE_VIDEO ON) +cc_set_if_undefined(USE_WEBVIEW ON) +cc_set_if_undefined(USE_MIDDLEWARE ON) +cc_set_if_undefined(USE_DRAGONBONES ON) +cc_set_if_undefined(USE_SPINE ON) +cc_set_if_undefined(USE_WEBSOCKET_SERVER OFF) +cc_set_if_undefined(USE_JOB_SYSTEM_TASKFLOW OFF) +cc_set_if_undefined(USE_JOB_SYSTEM_TBB OFF) +cc_set_if_undefined(USE_PHYSICS_PHYSX OFF) +cc_set_if_undefined(USE_MODULES OFF) +cc_set_if_undefined(USE_XR OFF) +cc_set_if_undefined(USE_SERVER_MODE OFF) +cc_set_if_undefined(USE_PLUGINS ON) +cc_set_if_undefined(USE_OCCLUSION_QUERY ON) +cc_set_if_undefined(USE_DEBUG_RENDERER ON) +cc_set_if_undefined(USE_GEOMETRY_RENDERER ON) +cc_set_if_undefined(USE_WEBP ON) +cc_set_if_undefined(NET_MODE 0) # 0 is client +cc_set_if_undefined(USE_REMOTE_LOG OFF) + + +if(ANDROID AND NOT DEFINED USE_CCACHE) + if("$ENV{COCOS_USE_CCACHE}" STREQUAL "1") + message(STATUS "Enable ccache by env CC_USE_CACHE=1") + set(USE_CCACHE ON) + else() + set(USE_CCACHE OFF) + endif() +endif() + +if(NX) + cc_set_if_undefined(CC_USE_VULKAN ON) + cc_set_if_undefined(CC_USE_GLES3 OFF) + cc_set_if_undefined(CC_USE_GLES2 OFF) +elseif(ANDROID OR WINDOWS OR OHOS) + cc_set_if_undefined(CC_USE_GLES3 ON) + cc_set_if_undefined(CC_USE_VULKAN OFF) + cc_set_if_undefined(CC_USE_GLES2 OFF) +elseif(MACOSX OR IOS) + cc_set_if_undefined(CC_USE_METAL ON) + cc_set_if_undefined(CC_USE_VULKAN OFF) + cc_set_if_undefined(CC_USE_GLES3 OFF) + cc_set_if_undefined(CC_USE_GLES2 OFF) +endif() + +set(CC_USE_GLES3 ${CC_USE_GLES3} CACHE INTERNAL "") +set(CC_USE_GLES2 ${CC_USE_GLES2} CACHE INTERNAL "") +set(CC_USE_VULKAN ${CC_USE_VULKAN} CACHE INTERNAL "") +set(CC_USE_METAL ${CC_USE_METAL} CACHE INTERNAL "") + +if(USE_SERVER_MODE) + set(CC_USE_VULKAN OFF) + set(CC_USE_METAL OFF) + set(CC_USE_GLES3 OFF) + set(CC_USE_GLES2 OFF) + add_definitions(-DCC_SERVER_MODE) +endif() + + +add_definitions(-DCC_NETMODE_CLIENT=0) +add_definitions(-DCC_NETMODE_LISTEN_SERVER=1) +add_definitions(-DCC_NETMODE_HOST_SERVER=2) +if(${NET_MODE} EQUAL "0" OR ${NET_MODE} EQUAL "1" OR ${NET_MODE} EQUAL "2") + add_definitions(-DCC_NETMODE=${NET_MODE}) +else() + message(FATAL_ERROR "NET_MODE only support setting to 1 2 or 3.") +endif() + +if(USE_PHYSICS_PHYSX) + if (ANDROID AND CMAKE_ANDROID_ARCH_ABI MATCHES x86) + set(USE_PHYSICS_PHYSX OFF) + message(AUTHOR_WARNING "Native PhysX does not support Google Android X86") + endif() +endif() + +if(NOT USE_SOCKET) + set(USE_WEBSOCKET_SERVER OFF) +endif() + +if(OHOS) + set(CC_USE_GLES2 OFF) +endif() + +## disable videoplay on non-mobile platforms +if(NOT ANDROID AND NOT IOS AND NOT OHOS) + set(USE_VIDEO OFF) + set(USE_WEBVIEW OFF) +endif() + +## disable middleware when dragonbones and spine are disabled +if(NOT USE_DRAGONBONES AND NOT USE_SPINE) + set(USE_MIDDLEWARE OFF) +endif() + +if(USE_DRAGONBONES OR USE_SPINE) + set(USE_MIDDLEWARE ON) +endif() + +if(USE_JOB_SYSTEM_TASKFLOW AND USE_JOB_SYSTEM_TBB) + set(USE_JOB_SYSTEM_TASKFLOW ON) + set(USE_JOB_SYSTEM_TBB OFF) +endif() + +if(OHOS AND USE_JOB_SYSTEM_TBB) + message(WARNING "JobSystem tbb is not supported by HarmonyOS") + set(USE_JOB_SYSTEM_TBB OFF) +endif() + +if(USE_JOB_SYSTEM_TASKFLOW) + set(CMAKE_CXX_STANDARD 17) + if(IOS AND "${TARGET_IOS_VERSION}" VERSION_LESS "12.0") + message(FATAL_ERROR "Target iOS version requires 12.0+ when enable taskflow") + endif() +endif() + +if(ANDROID) + if(USE_CCACHE AND NOT CCACHE_EXECUTABLE) + message(AUTHOR_WARNING "ccache executable not found!") + endif() + if(CCACHE_EXECUTABLE AND USE_CCACHE) + set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}") + set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}") + endif() +endif() + +if(CI_FORCE_MINIMAL_FEATURES) + set(USE_V8_DEBUGGER_FORCE OFF) + set(USE_V8_DEBUGGER OFF) + set(USE_AUDIO OFF) + set(USE_EDIT_BOX OFF) + set(USE_VIDEO OFF) + set(USE_WEBVIEW OFF) + set(USE_MIDDLEWARE OFF) + set(USE_DRAGONBONES OFF) + set(USE_SPINE OFF) + set(USE_SOCKET OFF) + set(USE_WEBSOCKET_SERVER OFF) + set(USE_PHYSICS_PHYSX OFF) + set(USE_JOB_SYSTEM_TBB OFF) + set(USE_JOB_SYSTEM_TASKFLOW OFF) + set(USE_PLUGINS OFF) + set(USE_OCCLUSION_QUERY OFF) + set(USE_DEBUG_RENDERER OFF) + set(USE_GEOMETRY_RENDERER OFF) + set(USE_WEBP OFF) +endif() + +################################# external source code ################################ +set(EXTERNAL_ROOT ${CMAKE_CURRENT_LIST_DIR}/external) +set(USE_BUILTIN_EXTERNAL OFF) +if(NOT EXISTS ${EXTERNAL_ROOT}/CMakeLists.txt) + if(DEFINED BUILTIN_COCOS_X_PATH) + set(EXTERNAL_ROOT ${BUILTIN_COCOS_X_PATH}/external) + set(USE_BUILTIN_EXTERNAL ON) + message(AUTHOR_WARNING "Directory 'external' not found in '${CMAKE_CURRENT_LIST_DIR}', use builtin directory '${BUILTIN_COCOS_X_PATH}' instead!") + else() + message(FATAL_ERROR "Please download external libraries! File ${CMAKE_CURRENT_LIST_DIR}/external/CMakeLists.txt not exist!") + endif() +endif() +################################# list all option values ############################## + +cc_inspect_values( + BUILTIN_COCOS_X_PATH + USE_BUILTIN_EXTERNAL + USE_MODULES + CC_USE_METAL + CC_USE_GLES3 + CC_USE_GLES2 + CC_USE_VULKAN + CC_DEBUG_FORCE + USE_SE_V8 + USE_V8_DEBUGGER + USE_V8_DEBUGGER_FORCE + USE_SE_SM + USE_SOCKET + USE_AUDIO + USE_EDIT_BOX + USE_VIDEO + USE_WEBVIEW + USE_MIDDLEWARE + USE_DRAGONBONES + USE_SPINE + USE_WEBSOCKET_SERVER + USE_PHYSICS_PHYSX + USE_JOB_SYSTEM_TBB + USE_JOB_SYSTEM_TASKFLOW + USE_XR + USE_SERVER_MODE + USE_CCACHE + CCACHE_EXECUTABLE + NODE_EXECUTABLE + NET_MODE + USE_REMOTE_LOG +) + + +include(${EXTERNAL_ROOT}/CMakeLists.txt) + +##### audio +if(USE_AUDIO) + cocos_source_files( + cocos/audio/AudioEngine.cpp + cocos/audio/include/AudioEngine.h + cocos/audio/include/AudioDef.h + cocos/audio/include/Export.h + ) + if(WINDOWS) + cocos_source_files( + cocos/audio/common/utils/tinysndfile.cpp +NO_WERROR cocos/audio/common/utils/primitives.cpp + cocos/audio/common/utils/include/tinysndfile.h + cocos/audio/common/utils/include/primitives.h + cocos/audio/common/utils/private/private.h + cocos/audio/common/decoder/AudioDecoder.cpp + cocos/audio/common/decoder/AudioDecoder.h + cocos/audio/common/decoder/AudioDecoderManager.cpp + cocos/audio/common/decoder/AudioDecoderManager.h + cocos/audio/common/decoder/AudioDecoderMp3.cpp + cocos/audio/common/decoder/AudioDecoderMp3.h + cocos/audio/common/decoder/AudioDecoderOgg.cpp + cocos/audio/common/decoder/AudioDecoderOgg.h + cocos/audio/common/decoder/AudioDecoderWav.cpp + cocos/audio/common/decoder/AudioDecoderWav.h + cocos/audio/oalsoft/AudioCache.cpp + cocos/audio/oalsoft/AudioCache.h + cocos/audio/oalsoft/AudioEngine-soft.cpp + cocos/audio/oalsoft/AudioEngine-soft.h + cocos/audio/include/AudioMacros.h + cocos/audio/oalsoft/AudioPlayer.cpp + cocos/audio/oalsoft/AudioPlayer.h + ) + elseif(LINUX OR QNX) + cocos_source_files( + cocos/audio/common/decoder/AudioDecoder.cpp + cocos/audio/common/decoder/AudioDecoder.h + cocos/audio/common/decoder/AudioDecoderManager.cpp + cocos/audio/common/decoder/AudioDecoderManager.h + cocos/audio/common/decoder/AudioDecoderMp3.cpp + cocos/audio/common/decoder/AudioDecoderMp3.h + cocos/audio/common/decoder/AudioDecoderOgg.cpp + cocos/audio/common/decoder/AudioDecoderOgg.h + cocos/audio/oalsoft/AudioCache.cpp + cocos/audio/oalsoft/AudioCache.h + cocos/audio/oalsoft/AudioEngine-soft.cpp + cocos/audio/oalsoft/AudioEngine-soft.h + cocos/audio/include/AudioMacros.h + cocos/audio/oalsoft/AudioPlayer.cpp + cocos/audio/oalsoft/AudioPlayer.h + ) + elseif(ANDROID) + cocos_source_files( + cocos/audio/common/utils/include/primitives.h + cocos/audio/common/utils/include/format.h + cocos/audio/common/utils/include/minifloat.h + cocos/audio/common/utils/include/tinysndfile.h + cocos/audio/common/utils/private/private.h + cocos/audio/common/utils/minifloat.cpp + cocos/audio/common/utils/primitives.cpp + cocos/audio/common/utils/tinysndfile.cpp + cocos/audio/common/utils/format.cpp + cocos/audio/android/AssetFd.cpp + cocos/audio/android/AssetFd.h + cocos/audio/android/audio.h + cocos/audio/android/AudioBufferProvider.h + cocos/audio/android/AudioDecoder.cpp + cocos/audio/android/AudioDecoder.h + cocos/audio/android/AudioDecoderMp3.cpp + cocos/audio/android/AudioDecoderMp3.h + cocos/audio/android/AudioDecoderOgg.cpp + cocos/audio/android/AudioDecoderOgg.h + cocos/audio/android/AudioDecoderProvider.cpp + cocos/audio/android/AudioDecoderProvider.h + cocos/audio/android/AudioDecoderSLES.cpp + cocos/audio/android/AudioDecoderSLES.h + cocos/audio/android/AudioDecoderWav.cpp + cocos/audio/android/AudioDecoderWav.h + cocos/audio/android/AudioEngine-inl.cpp + cocos/audio/android/AudioEngine-inl.h + cocos/audio/android/AudioMixer.cpp + cocos/audio/android/AudioMixer.h + cocos/audio/android/AudioMixerController.cpp + cocos/audio/android/AudioMixerController.h + cocos/audio/android/AudioMixerOps.h + cocos/audio/android/AudioPlayerProvider.cpp + cocos/audio/android/AudioPlayerProvider.h + cocos/audio/android/AudioResampler.cpp + cocos/audio/android/AudioResampler.h + cocos/audio/android/AudioResamplerCubic.cpp + cocos/audio/android/AudioResamplerCubic.h + cocos/audio/android/AudioResamplerPublic.h + cocos/audio/android/cutils/bitops.h + cocos/audio/android/cutils/log.h + cocos/audio/android/IAudioPlayer.h + cocos/audio/android/ICallerThreadUtils.h + cocos/audio/android/IVolumeProvider.h + cocos/audio/android/mp3reader.cpp + cocos/audio/android/mp3reader.h + cocos/audio/android/OpenSLHelper.h + cocos/audio/android/PcmAudioPlayer.cpp + cocos/audio/android/PcmAudioPlayer.h + cocos/audio/android/PcmAudioService.cpp + cocos/audio/android/PcmAudioService.h + cocos/audio/android/PcmBufferProvider.cpp + cocos/audio/android/PcmBufferProvider.h + cocos/audio/android/PcmData.cpp + cocos/audio/android/PcmData.h + cocos/audio/android/Track.cpp + cocos/audio/android/Track.h + cocos/audio/android/UrlAudioPlayer.cpp + cocos/audio/android/UrlAudioPlayer.h + cocos/audio/android/utils/Compat.h + cocos/audio/android/utils/Errors.h + cocos/audio/android/utils/Utils.cpp + cocos/audio/android/utils/Utils.h + ) + elseif(OHOS) + cocos_source_files( + cocos/audio/common/utils/tinysndfile.cpp + cocos/audio/common/utils/primitives.cpp + cocos/audio/common/utils/include/tinysndfile.h + cocos/audio/common/utils/include/primitives.h + cocos/audio/common/decoder/AudioDecoder.cpp + cocos/audio/common/decoder/AudioDecoder.h + cocos/audio/common/decoder/AudioDecoderManager.cpp + cocos/audio/common/decoder/AudioDecoderManager.h + cocos/audio/common/decoder/AudioDecoderMp3.cpp + cocos/audio/common/decoder/AudioDecoderMp3.h + cocos/audio/common/decoder/AudioDecoderOgg.cpp + cocos/audio/common/decoder/AudioDecoderOgg.h + cocos/audio/common/decoder/AudioDecoderWav.cpp + cocos/audio/common/decoder/AudioDecoderWav.h + cocos/audio/oalsoft/AudioCache.cpp + cocos/audio/oalsoft/AudioCache.h + cocos/audio/oalsoft/AudioEngine-soft.cpp + cocos/audio/oalsoft/AudioEngine-soft.h + cocos/audio/include/AudioMacros.h + cocos/audio/oalsoft/AudioPlayer.cpp + cocos/audio/oalsoft/AudioPlayer.h + cocos/audio/ohos/FsCallback.h + cocos/audio/ohos/FsCallback.cpp + ) + elseif(APPLE) + cocos_source_files( + cocos/audio/apple/AudioDecoder.h + NO_WERROR NO_UBUILD cocos/audio/apple/AudioPlayer.mm + NO_WERROR NO_UBUILD cocos/audio/apple/AudioDecoder.mm + cocos/audio/apple/AudioPlayer.h + NO_WERROR NO_UBUILD cocos/audio/apple/AudioEngine-inl.mm + cocos/audio/apple/AudioMacros.h + NO_WERROR NO_UBUILD cocos/audio/apple/AudioCache.mm + cocos/audio/apple/AudioCache.h + cocos/audio/apple/AudioEngine-inl.h + ) + endif() + +endif() + +##### plugins +cocos_source_files( + cocos/plugins/Plugins.h + cocos/plugins/Plugins.cpp + cocos/plugins/bus/BusTypes.h + cocos/plugins/bus/EventBus.h + cocos/plugins/bus/EventBus.cpp +) + +##### base +cocos_source_files( + cocos/base/Agent.h + cocos/base/astc.cpp + cocos/base/astc.h + cocos/base/base64.cpp + cocos/base/base64.h + cocos/base/Config.h + cocos/base/csscolorparser.cpp + cocos/base/csscolorparser.h + cocos/base/DeferredReleasePool.cpp + cocos/base/DeferredReleasePool.h + cocos/base/etc1.cpp + cocos/base/etc1.h + cocos/base/etc2.cpp + cocos/base/etc2.h + cocos/base/IndexHandle.h + cocos/base/Locked.h + cocos/base/Macros.h + cocos/base/Object.h + cocos/base/Ptr.h + cocos/base/Random.h + cocos/base/RefCounted.cpp + cocos/base/RefCounted.h + cocos/base/RefMap.h + cocos/base/RefVector.h + cocos/base/Scheduler.cpp + cocos/base/Scheduler.h + cocos/base/StringHandle.cpp + cocos/base/StringHandle.h + cocos/base/StringPool.h + cocos/base/StringUtil.cpp + cocos/base/StringUtil.h + cocos/base/ThreadPool.cpp + cocos/base/ThreadPool.h + cocos/base/TypeDef.h + cocos/base/std/any.h + cocos/base/std/optional.h + cocos/base/std/variant.h + cocos/base/std/container/array.h + cocos/base/std/container/deque.h + cocos/base/std/container/list.h + cocos/base/std/container/map.h + cocos/base/std/container/queue.h + cocos/base/std/container/set.h + cocos/base/std/container/string.h + cocos/base/std/container/unordered_map.h + cocos/base/std/container/unordered_set.h + cocos/base/std/container/vector.h + cocos/base/std/hash/detail/float_functions.hpp + cocos/base/std/hash/detail/hash_float.hpp + cocos/base/std/hash/detail/limits.hpp + cocos/base/std/hash/extensions.hpp + cocos/base/std/hash/hash_fwd.hpp + cocos/base/std/hash/hash.h +) + +############ application +cocos_source_files( + cocos/application/BaseApplication.h + cocos/application/CocosApplication.h + cocos/application/CocosApplication.cpp + cocos/application/ApplicationManager.h + cocos/application/ApplicationManager.cpp + cocos/application/BaseGame.h + cocos/application/BaseGame.cpp +) + +############ engine +cocos_source_files( + cocos/engine/BaseEngine.cpp + cocos/engine/BaseEngine.h + cocos/engine/Engine.cpp + cocos/engine/Engine.h +) + +############ main +if(NOT USE_SERVER_MODE AND (WINDOWS OR LINUX)) +cocos_source_files( + cocos/platform/SDLHelper.h + cocos/platform/SDLHelper.cpp +) +endif() + +############ platform +cocos_source_files( + cocos/platform/IEventDispatch.h + cocos/platform/BasePlatform.cpp + cocos/platform/BasePlatform.h + cocos/platform/UniversalPlatform.cpp + cocos/platform/UniversalPlatform.h +) +if(WINDOWS) + cocos_source_files( + cocos/platform/win32/WindowsPlatform.cpp + cocos/platform/win32/WindowsPlatform.h + ) +elseif(LINUX) + cocos_source_files( + cocos/platform/linux/LinuxPlatform.cpp + cocos/platform/linux/LinuxPlatform.h + ) +elseif(ANDROID) + cocos_source_files( + cocos/platform/android/AndroidPlatform.cpp + cocos/platform/android/AndroidPlatform.h + ) +elseif(OHOS) + cocos_source_files( + cocos/platform/ohos/OhosPlatform.cpp + cocos/platform/ohos/OhosPlatform.h + ) +elseif(MACOSX) + cocos_source_files( + cocos/platform/mac/MacPlatform.mm + cocos/platform/mac/MacPlatform.h + cocos/platform/mac/ViewController.h + cocos/platform/mac/ViewController.mm + cocos/platform/mac/AppDelegate.h + cocos/platform/mac/AppDelegate.mm + ) +elseif(IOS) + cocos_source_files( + cocos/platform/ios/IOSPlatform.mm + cocos/platform/ios/IOSPlatform.h + cocos/platform/ios/AppDelegateBridge.mm + cocos/platform/ios/AppDelegateBridge.h + ) +endif() + +############ platform : Abstract interface +cocos_source_files( + cocos/platform/interfaces/OSInterface.cpp + cocos/platform/interfaces/OSInterface.h +) + +############ platform : Interface definition +cocos_source_files( + cocos/platform/interfaces/modules/Device.cpp + cocos/platform/interfaces/modules/Device.h + cocos/platform/interfaces/modules/IAccelerometer.h + cocos/platform/interfaces/modules/IBattery.h + cocos/platform/interfaces/modules/IScreen.h + cocos/platform/interfaces/modules/INetwork.h + cocos/platform/interfaces/modules/ISystem.cpp + cocos/platform/interfaces/modules/ISystem.h + cocos/platform/interfaces/modules/ISystemWindow.h + cocos/platform/interfaces/modules/IVibrator.h + cocos/platform/interfaces/modules/XRCommon.h + cocos/platform/interfaces/modules/IXRInterface.h +) + +cocos_source_files( + cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp + cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.h + cocos/platform/interfaces/modules/canvas/ICanvasRenderingContext2D.cpp + cocos/platform/interfaces/modules/canvas/ICanvasRenderingContext2D.h +) +if(USE_SERVER_MODE) + cocos_source_files( + cocos/platform/empty/modules/CanvasRenderingContext2DDelegate.cpp + cocos/platform/empty/modules/CanvasRenderingContext2DDelegate.h + ) +elseif(WINDOWS) + cocos_source_files( + cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp + cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.h + ) +elseif(ANDROID OR OHOS) + cocos_source_files( + cocos/platform/java/modules/CanvasRenderingContext2DDelegate.cpp + cocos/platform/java/modules/CanvasRenderingContext2DDelegate.h + ) +elseif(MACOSX OR IOS) + cocos_source_files( + cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm + cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.h + ) +elseif(LINUX) + cocos_source_files( + cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp + cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.h + ) +endif() + +############ platform : Interface implementation of windows + +if(WINDOWS) + cocos_source_files( + cocos/platform/win32/modules/Accelerometer.cpp + cocos/platform/win32/modules/Accelerometer.h + cocos/platform/win32/modules/Battery.cpp + cocos/platform/win32/modules/Battery.h + cocos/platform/win32/modules/Network.cpp + cocos/platform/win32/modules/Network.h + cocos/platform/win32/modules/Vibrator.cpp + cocos/platform/win32/modules/Vibrator.h + cocos/platform/win32/modules/System.cpp + cocos/platform/win32/modules/System.h + ) + if(USE_SERVER_MODE) + cocos_source_files( + cocos/platform/empty/modules/Screen.cpp + cocos/platform/empty/modules/Screen.h + cocos/platform/empty/modules/SystemWindow.cpp + cocos/platform/empty/modules/SystemWindow.h + ) + else() + cocos_source_files( + cocos/platform/win32/modules/Screen.cpp + cocos/platform/win32/modules/Screen.h + cocos/platform/win32/modules/SystemWindow.cpp + cocos/platform/win32/modules/SystemWindow.h + ) + endif() +elseif(ANDROID OR OHOS) + cocos_source_files( + cocos/platform/java/modules/Accelerometer.cpp + cocos/platform/java/modules/Accelerometer.h + cocos/platform/java/modules/Battery.cpp + cocos/platform/java/modules/Battery.h + cocos/platform/java/modules/CommonScreen.cpp + cocos/platform/java/modules/CommonScreen.h + cocos/platform/java/modules/Network.cpp + cocos/platform/java/modules/Network.h + cocos/platform/java/modules/Vibrator.cpp + cocos/platform/java/modules/Vibrator.h + cocos/platform/java/modules/CommonSystem.cpp + cocos/platform/java/modules/CommonSystem.h + cocos/platform/java/modules/SystemWindow.cpp + cocos/platform/java/modules/SystemWindow.h + cocos/platform/java/modules/XRInterface.cpp + cocos/platform/java/modules/XRInterface.h + ) +endif() + +if(ANDROID) + cocos_source_files( + cocos/platform/android/modules/Screen.cpp + cocos/platform/android/modules/Screen.h + cocos/platform/android/modules/System.cpp + cocos/platform/android/modules/System.h + ) +elseif(OHOS) + cocos_source_files( + cocos/platform/ohos/modules/Screen.cpp + cocos/platform/ohos/modules/Screen.h + cocos/platform/ohos/modules/System.cpp + cocos/platform/ohos/modules/System.h + ) +elseif(MACOSX) + cocos_source_files( + NO_WERROR cocos/platform/mac/modules/Accelerometer.mm + cocos/platform/mac/modules/Accelerometer.h + cocos/platform/mac/modules/Battery.mm + cocos/platform/mac/modules/Battery.h + cocos/platform/mac/modules/Network.mm + cocos/platform/mac/modules/Network.h + cocos/platform/mac/modules/Vibrator.mm + cocos/platform/mac/modules/Vibrator.h + cocos/platform/mac/modules/System.mm + cocos/platform/mac/modules/System.h + ) + if(USE_SERVER_MODE) + cocos_source_files( + cocos/platform/empty/modules/Screen.cpp + cocos/platform/empty/modules/Screen.h + cocos/platform/empty/modules/SystemWindow.cpp + cocos/platform/empty/modules/SystemWindow.h + ) + else() + cocos_source_files( + NO_WERROR NO_UBUILD cocos/platform/mac/modules/Screen.mm + cocos/platform/mac/modules/Screen.h + cocos/platform/mac/modules/SystemWindow.mm + cocos/platform/mac/modules/SystemWindow.h + ) + endif() +elseif(IOS) + cocos_source_files( + NO_WERROR NO_UBUILD cocos/platform/ios/modules/Accelerometer.mm + cocos/platform/ios/modules/Accelerometer.h + cocos/platform/ios/modules/Battery.mm + cocos/platform/ios/modules/Battery.h + NO_WERROR NO_UBUILD cocos/platform/ios/modules/Screen.mm + cocos/platform/ios/modules/Screen.h + cocos/platform/ios/modules/Network.mm + cocos/platform/ios/modules/Network.h + cocos/platform/ios/modules/Vibrator.mm + cocos/platform/ios/modules/Vibrator.h + cocos/platform/ios/modules/System.mm + cocos/platform/ios/modules/System.h + cocos/platform/ios/modules/SystemWindow.mm + cocos/platform/ios/modules/SystemWindow.h + ) +elseif(LINUX) + cocos_source_files( + cocos/platform/linux/modules/Accelerometer.cpp + cocos/platform/linux/modules/Accelerometer.h + cocos/platform/linux/modules/Battery.cpp + cocos/platform/linux/modules/Battery.h + cocos/platform/linux/modules/Network.cpp + cocos/platform/linux/modules/Network.h + cocos/platform/linux/modules/Vibrator.cpp + cocos/platform/linux/modules/Vibrator.h + cocos/platform/linux/modules/System.cpp + cocos/platform/linux/modules/System.h + ) + if(USE_SERVER_MODE) + cocos_source_files( + cocos/platform/empty/modules/Screen.cpp + cocos/platform/empty/modules/Screen.h + cocos/platform/empty/modules/SystemWindow.cpp + cocos/platform/empty/modules/SystemWindow.h + ) + else() + cocos_source_files( + cocos/platform/linux/modules/Screen.cpp + cocos/platform/linux/modules/Screen.h + cocos/platform/linux/modules/SystemWindow.cpp + cocos/platform/linux/modules/SystemWindow.h + ) + endif() +endif() + +############ module log +cocos_source_files(MODULE cclog + cocos/base/Log.cpp + cocos/base/Log.h +) + +cocos_source_files(MODULE cclog + cocos/base/LogRemote.cpp +) + +############ module log +cocos_source_files(MODULE ccunzip + cocos/base/ZipUtils.cpp + cocos/base/ZipUtils.h +) + +##### memory +cocos_source_files( + cocos/base/memory/Memory.h + cocos/base/memory/MemoryHook.cpp + cocos/base/memory/MemoryHook.h + cocos/base/memory/CallStack.cpp + cocos/base/memory/CallStack.h +) + +##### threading +cocos_source_files( + cocos/base/threading/ConditionVariable.h + cocos/base/threading/ConditionVariable.cpp + cocos/base/threading/Event.h + cocos/base/threading/MessageQueue.h + cocos/base/threading/MessageQueue.cpp + cocos/base/threading/Semaphore.h + cocos/base/threading/Semaphore.cpp + cocos/base/threading/ThreadPool.h + cocos/base/threading/ThreadPool.cpp + cocos/base/threading/ThreadSafeCounter.h + cocos/base/threading/ThreadSafeLinearAllocator.h + cocos/base/threading/ThreadSafeLinearAllocator.cpp +) +if(APPLE) +cocos_source_files( + cocos/base/threading/AutoReleasePool.h + cocos/base/threading/AutoReleasePool-apple.mm +) +else() +cocos_source_files( + cocos/base/threading/AutoReleasePool.h + cocos/base/threading/AutoReleasePool.cpp +) +endif() + +##### job system +cocos_source_files( + cocos/base/job-system/JobSystem.h +) + +if(USE_JOB_SYSTEM_TASKFLOW) + cocos_source_files( + cocos/base/job-system/job-system-taskflow/TFJobGraph.h + cocos/base/job-system/job-system-taskflow/TFJobGraph.cpp + cocos/base/job-system/job-system-taskflow/TFJobSystem.h + cocos/base/job-system/job-system-taskflow/TFJobSystem.cpp + ) +elseif(USE_JOB_SYSTEM_TBB) + cocos_source_files( + cocos/base/job-system/job-system-tbb/TBBJobGraph.h + cocos/base/job-system/job-system-tbb/TBBJobGraph.cpp + cocos/base/job-system/job-system-tbb/TBBJobSystem.h + cocos/base/job-system/job-system-tbb/TBBJobSystem.cpp + ) +else() + cocos_source_files( + cocos/base/job-system/job-system-dummy/DummyJobGraph.h + cocos/base/job-system/job-system-dummy/DummyJobGraph.cpp + cocos/base/job-system/job-system-dummy/DummyJobSystem.h + cocos/base/job-system/job-system-dummy/DummyJobSystem.cpp + ) +endif() + +######### module math +cocos_source_files(MODULE ccmath + cocos/math/Utils.h + cocos/math/Utils.cpp + cocos/math/Geometry.cpp + cocos/math/Geometry.h + cocos/math/Color.cpp + cocos/math/Color.h + cocos/math/Math.h + cocos/math/Math.cpp + cocos/math/MathBase.h + cocos/math/Vertex.cpp + cocos/math/Vertex.h + cocos/math/Mat3.cpp + cocos/math/Mat3.h + cocos/math/Mat4.cpp + cocos/math/Mat4.h + cocos/math/Mat4.inl + cocos/math/MathUtil.cpp + cocos/math/MathUtil.h + cocos/math/MathUtil.inl + cocos/math/MathUtilNeon.inl + cocos/math/MathUtilNeon64.inl + cocos/math/MathUtilSSE.inl + cocos/math/Quaternion.cpp + cocos/math/Quaternion.h + cocos/math/Quaternion.inl + cocos/math/Vec2.cpp + cocos/math/Vec2.h + cocos/math/Vec2.inl + cocos/math/Vec3.cpp + cocos/math/Vec3.h + cocos/math/Vec3.inl + cocos/math/Vec4.cpp + cocos/math/Vec4.h + cocos/math/Vec4.inl +) + +##### network +cocos_source_files( + cocos/network/Downloader.cpp + cocos/network/Downloader.h + cocos/network/DownloaderImpl.h + cocos/network/HttpClient.h + cocos/network/HttpCookie.cpp + cocos/network/HttpCookie.h + cocos/network/HttpRequest.h + cocos/network/HttpResponse.h + cocos/network/Uri.cpp + cocos/network/Uri.h + ) + +if(USE_SOCKET) + cocos_source_files( + cocos/network/WebSocket.h + cocos/network/SocketIO.cpp + cocos/network/SocketIO.h + ) +endif() + +if(NOT IOS AND USE_WEBSOCKET_SERVER) + cocos_source_files( + cocos/network/WebSocketServer.h + cocos/network/WebSocketServer.cpp + ) +endif() + +if(APPLE) + cocos_source_files( + cocos/network/DownloaderImpl-apple.h + cocos/network/DownloaderImpl-apple.mm + cocos/network/HttpAsynConnection-apple.h + NO_WERROR NO_UBUILD cocos/network/HttpAsynConnection-apple.m + NO_UBUILD cocos/network/HttpClient-apple.mm + ) + if(USE_SOCKET) + cocos_source_files( + cocos/network/WebSocket-apple.mm + ) + set_source_files_properties(${CWD}/cocos/network/WebSocket-apple.mm PROPERTIES + COMPILE_FLAGS -fobjc-arc + ) + endif() +endif() + +if(ANDROID OR OHOS) + cocos_source_files( + cocos/network/Downloader-java.cpp + cocos/network/Downloader-java.h + cocos/network/HttpClient-java.cpp + ) +endif() + +if(NOT APPLE AND USE_SOCKET) + if(ANDROID) + cocos_source_files( + NO_WERROR cocos/network/WebSocket-okhttp.cpp + ) + else() + cocos_source_files( + NO_WERROR cocos/network/WebSocket-libwebsockets.cpp + ) + endif() +endif() + +if(WINDOWS OR LINUX OR QNX) + cocos_source_files( + NO_WERROR cocos/network/Downloader-curl.cpp + cocos/network/Downloader-curl.h + ) +endif() + +if(WINDOWS OR MACOSX OR LINUX OR QNX) + cocos_source_files( + NO_WERROR NO_UBUILD cocos/network/HttpClient.cpp + ) +endif() + + +##### platform +cocos_source_files( + cocos/platform/Image.cpp + cocos/platform/Image.h + cocos/platform/StdC.h +) + +########## module utils +cocos_source_files(MODULE ccutils + cocos/base/Data.cpp + cocos/base/Data.h + cocos/base/Value.cpp + cocos/base/Value.h + cocos/base/UTF8.cpp + cocos/base/UTF8.h + cocos/platform/SAXParser.cpp + cocos/platform/SAXParser.h + cocos/base/Utils.cpp + cocos/base/Utils.h + cocos/base/Timer.cpp + cocos/base/Timer.h +) + +########## module ccfilesystem +cocos_source_files(MODULE ccfilesystem + cocos/platform/FileUtils.cpp + cocos/platform/FileUtils.h +) + +if(WINDOWS) + cocos_source_files(MODULE ccutils + cocos/platform/win32/Utils-win32.cpp + cocos/platform/win32/Utils-win32.h + ) +endif() + +if(WINDOWS) + cocos_source_files( + cocos/platform/win32/compat + cocos/platform/win32/compat/stdint.h + ) + cocos_source_files(MODULE ccfilesystem + cocos/platform/win32/FileUtils-win32.cpp + cocos/platform/win32/FileUtils-win32.h + ) +elseif(ANDROID) + set(CC_JNI_SRC_FILES + ${CWD}/cocos/platform/android/jni/JniCocosEntry.cpp + ${CWD}/cocos/platform/java/jni/JniCocosOrientationHelper.cpp + ${CWD}/cocos/platform/java/jni/JniHelper.cpp + ${CWD}/cocos/platform/java/jni/JniHelper.h + ${CWD}/cocos/platform/java/jni/JniImp.cpp + ${CWD}/cocos/platform/java/jni/JniImp.h + ${CWD}/cocos/platform/java/jni/glue/MessagePipe.cpp + ${CWD}/cocos/platform/java/jni/glue/MessagePipe.h + ) + + cocos_source_files(MODULE ccfilesystem + cocos/platform/android/FileUtils-android.cpp + cocos/platform/android/FileUtils-android.h + ) +elseif(OHOS) + set(CC_JNI_SRC_FILES + ${CWD}/cocos/platform/ohos/jni/JniCocosAbility.cpp + ${CWD}/cocos/platform/ohos/jni/JniCocosAbility.h + ${CWD}/cocos/platform/java/jni/JniHelper.cpp + ${CWD}/cocos/platform/java/jni/JniHelper.h + ${CWD}/cocos/platform/java/jni/JniImp.cpp + ${CWD}/cocos/platform/java/jni/JniImp.h + ${CWD}/cocos/platform/java/jni/JniCocosTouchHandler.cpp + ${CWD}/cocos/platform/java/jni/JniCocosKeyCodeHandler.cpp + ${CWD}/cocos/platform/java/jni/JniCocosOrientationHelper.cpp + ${CWD}/cocos/platform/ohos/jni/AbilityConsts.h + ${CWD}/cocos/platform/java/jni/glue/JniNativeGlue.cpp + ${CWD}/cocos/platform/java/jni/glue/JniNativeGlue.h + ${CWD}/cocos/platform/java/jni/glue/MessagePipe.cpp + ${CWD}/cocos/platform/java/jni/glue/MessagePipe.h + ) + cocos_source_files(MODULE ccfilesystem + cocos/platform/ohos/FileUtils-ohos.cpp + cocos/platform/ohos/FileUtils-ohos.h + ) +elseif(APPLE) + cocos_source_files( + cocos/platform/apple/Reachability.h + cocos/platform/apple/Reachability.cpp + ) + + cocos_source_files(MODULE ccfilesystem + cocos/platform/apple/FileUtils-apple.h + cocos/platform/apple/FileUtils-apple.mm + ) + if(MACOSX) + cocos_source_files( + cocos/platform/mac/View.h + cocos/platform/mac/View.mm + cocos/platform/mac/KeyCodeHelper.h + cocos/platform/mac/KeyCodeHelper.cpp + ) + elseif(IOS) + cocos_source_files( + cocos/platform/ios/View.h + NO_WERROR NO_UBUILD cocos/platform/ios/View.mm # CAMetalLayer bug for apple + ) + endif() +elseif(LINUX) + cocos_source_files(MODULE ccfilesystem + cocos/platform/linux/FileUtils-linux.cpp + cocos/platform/linux/FileUtils-linux.h + ) +endif() + +##### renderer +cocos_source_files( + cocos/renderer/core/PassUtils.h + cocos/renderer/core/PassUtils.cpp + cocos/renderer/core/ProgramLib.h + cocos/renderer/core/ProgramLib.cpp + cocos/renderer/core/MaterialInstance.h + cocos/renderer/core/MaterialInstance.cpp + cocos/renderer/core/PassInstance.h + cocos/renderer/core/PassInstance.cpp + cocos/renderer/core/TextureBufferPool.h + cocos/renderer/core/TextureBufferPool.cpp + + cocos/renderer/GFXDeviceManager.h + + cocos/renderer/gfx-base/SPIRVUtils.h + cocos/renderer/gfx-base/SPIRVUtils.cpp + cocos/renderer/gfx-base/GFXObject.h + cocos/renderer/gfx-base/GFXObject.cpp + cocos/renderer/gfx-base/GFXBuffer.cpp + cocos/renderer/gfx-base/GFXBuffer.h + cocos/renderer/gfx-base/GFXCommandBuffer.cpp + cocos/renderer/gfx-base/GFXCommandBuffer.h + cocos/renderer/gfx-base/GFXDef.cpp + cocos/renderer/gfx-base/GFXDef.h + cocos/renderer/gfx-base/GFXDef-common.h + cocos/renderer/gfx-base/GFXDevice.cpp + cocos/renderer/gfx-base/GFXDevice.h + cocos/renderer/gfx-base/GFXFramebuffer.cpp + cocos/renderer/gfx-base/GFXFramebuffer.h + cocos/renderer/gfx-base/GFXInputAssembler.cpp + cocos/renderer/gfx-base/GFXInputAssembler.h + cocos/renderer/gfx-base/GFXDescriptorSet.cpp + cocos/renderer/gfx-base/GFXDescriptorSet.h + cocos/renderer/gfx-base/GFXDescriptorSetLayout.cpp + cocos/renderer/gfx-base/GFXDescriptorSetLayout.h + cocos/renderer/gfx-base/GFXPipelineLayout.cpp + cocos/renderer/gfx-base/GFXPipelineLayout.h + cocos/renderer/gfx-base/GFXPipelineState.cpp + cocos/renderer/gfx-base/GFXPipelineState.h + cocos/renderer/gfx-base/GFXQueue.cpp + cocos/renderer/gfx-base/GFXQueue.h + cocos/renderer/gfx-base/GFXQueryPool.cpp + cocos/renderer/gfx-base/GFXQueryPool.h + cocos/renderer/gfx-base/GFXRenderPass.cpp + cocos/renderer/gfx-base/GFXRenderPass.h + cocos/renderer/gfx-base/GFXShader.cpp + cocos/renderer/gfx-base/GFXShader.h + cocos/renderer/gfx-base/GFXSwapchain.cpp + cocos/renderer/gfx-base/GFXSwapchain.h + cocos/renderer/gfx-base/GFXTexture.cpp + cocos/renderer/gfx-base/GFXTexture.h + cocos/renderer/gfx-base/states/GFXGeneralBarrier.cpp + cocos/renderer/gfx-base/states/GFXGeneralBarrier.h + cocos/renderer/gfx-base/states/GFXSampler.cpp + cocos/renderer/gfx-base/states/GFXSampler.h + cocos/renderer/gfx-base/states/GFXTextureBarrier.cpp + cocos/renderer/gfx-base/states/GFXTextureBarrier.h + cocos/renderer/gfx-base/states/GFXBufferBarrier.h + cocos/renderer/gfx-base/states/GFXBufferBarrier.cpp + + cocos/renderer/gfx-agent/BufferAgent.h + cocos/renderer/gfx-agent/BufferAgent.cpp + cocos/renderer/gfx-agent/CommandBufferAgent.h + cocos/renderer/gfx-agent/CommandBufferAgent.cpp + cocos/renderer/gfx-agent/DescriptorSetAgent.h + cocos/renderer/gfx-agent/DescriptorSetAgent.cpp + cocos/renderer/gfx-agent/DescriptorSetLayoutAgent.h + cocos/renderer/gfx-agent/DescriptorSetLayoutAgent.cpp + cocos/renderer/gfx-agent/DeviceAgent.h + cocos/renderer/gfx-agent/DeviceAgent.cpp + cocos/renderer/gfx-agent/FramebufferAgent.h + cocos/renderer/gfx-agent/FramebufferAgent.cpp + cocos/renderer/gfx-agent/InputAssemblerAgent.h + cocos/renderer/gfx-agent/InputAssemblerAgent.cpp + cocos/renderer/gfx-agent/PipelineLayoutAgent.h + cocos/renderer/gfx-agent/PipelineLayoutAgent.cpp + cocos/renderer/gfx-agent/PipelineStateAgent.h + cocos/renderer/gfx-agent/PipelineStateAgent.cpp + cocos/renderer/gfx-agent/QueueAgent.h + cocos/renderer/gfx-agent/QueueAgent.cpp + cocos/renderer/gfx-agent/QueryPoolAgent.h + cocos/renderer/gfx-agent/QueryPoolAgent.cpp + cocos/renderer/gfx-agent/RenderPassAgent.h + cocos/renderer/gfx-agent/RenderPassAgent.cpp + cocos/renderer/gfx-agent/SwapchainAgent.h + cocos/renderer/gfx-agent/SwapchainAgent.cpp + cocos/renderer/gfx-agent/ShaderAgent.h + cocos/renderer/gfx-agent/ShaderAgent.cpp + cocos/renderer/gfx-agent/TextureAgent.h + cocos/renderer/gfx-agent/TextureAgent.cpp + + cocos/renderer/gfx-validator/BufferValidator.h + cocos/renderer/gfx-validator/BufferValidator.cpp + cocos/renderer/gfx-validator/CommandBufferValidator.h + cocos/renderer/gfx-validator/CommandBufferValidator.cpp + cocos/renderer/gfx-validator/DescriptorSetValidator.h + cocos/renderer/gfx-validator/DescriptorSetValidator.cpp + cocos/renderer/gfx-validator/DescriptorSetLayoutValidator.h + cocos/renderer/gfx-validator/DescriptorSetLayoutValidator.cpp + cocos/renderer/gfx-validator/DeviceValidator.h + cocos/renderer/gfx-validator/DeviceValidator.cpp + cocos/renderer/gfx-validator/FramebufferValidator.h + cocos/renderer/gfx-validator/FramebufferValidator.cpp + cocos/renderer/gfx-validator/InputAssemblerValidator.h + cocos/renderer/gfx-validator/InputAssemblerValidator.cpp + cocos/renderer/gfx-validator/PipelineLayoutValidator.h + cocos/renderer/gfx-validator/PipelineLayoutValidator.cpp + cocos/renderer/gfx-validator/PipelineStateValidator.h + cocos/renderer/gfx-validator/PipelineStateValidator.cpp + cocos/renderer/gfx-validator/QueueValidator.h + cocos/renderer/gfx-validator/QueueValidator.cpp + cocos/renderer/gfx-validator/QueryPoolValidator.h + cocos/renderer/gfx-validator/QueryPoolValidator.cpp + cocos/renderer/gfx-validator/RenderPassValidator.h + cocos/renderer/gfx-validator/RenderPassValidator.cpp + cocos/renderer/gfx-validator/ShaderValidator.h + cocos/renderer/gfx-validator/ShaderValidator.cpp + cocos/renderer/gfx-validator/SwapchainValidator.h + cocos/renderer/gfx-validator/SwapchainValidator.cpp + cocos/renderer/gfx-validator/TextureValidator.h + cocos/renderer/gfx-validator/TextureValidator.cpp + cocos/renderer/gfx-validator/ValidationUtils.h + cocos/renderer/gfx-validator/ValidationUtils.cpp + + cocos/renderer/gfx-empty/EmptyBuffer.h + cocos/renderer/gfx-empty/EmptyBuffer.cpp + cocos/renderer/gfx-empty/EmptyCommandBuffer.h + cocos/renderer/gfx-empty/EmptyCommandBuffer.cpp + cocos/renderer/gfx-empty/EmptyDescriptorSet.h + cocos/renderer/gfx-empty/EmptyDescriptorSet.cpp + cocos/renderer/gfx-empty/EmptyDescriptorSetLayout.h + cocos/renderer/gfx-empty/EmptyDescriptorSetLayout.cpp + cocos/renderer/gfx-empty/EmptyDevice.h + cocos/renderer/gfx-empty/EmptyDevice.cpp + cocos/renderer/gfx-empty/EmptyFramebuffer.h + cocos/renderer/gfx-empty/EmptyFramebuffer.cpp + cocos/renderer/gfx-empty/EmptyInputAssembler.h + cocos/renderer/gfx-empty/EmptyInputAssembler.cpp + cocos/renderer/gfx-empty/EmptyPipelineLayout.h + cocos/renderer/gfx-empty/EmptyPipelineLayout.cpp + cocos/renderer/gfx-empty/EmptyPipelineState.h + cocos/renderer/gfx-empty/EmptyPipelineState.cpp + cocos/renderer/gfx-empty/EmptyQueue.h + cocos/renderer/gfx-empty/EmptyQueue.cpp + cocos/renderer/gfx-empty/EmptyQueryPool.h + cocos/renderer/gfx-empty/EmptyQueryPool.cpp + cocos/renderer/gfx-empty/EmptyRenderPass.h + cocos/renderer/gfx-empty/EmptyRenderPass.cpp + cocos/renderer/gfx-empty/EmptyShader.h + cocos/renderer/gfx-empty/EmptyShader.cpp + cocos/renderer/gfx-empty/EmptySwapchain.h + cocos/renderer/gfx-empty/EmptySwapchain.cpp + cocos/renderer/gfx-empty/EmptyTexture.h + cocos/renderer/gfx-empty/EmptyTexture.cpp + + cocos/renderer/pipeline/BatchedBuffer.cpp + cocos/renderer/pipeline/BatchedBuffer.h + cocos/renderer/pipeline/ClusterLightCulling.cpp + cocos/renderer/pipeline/ClusterLightCulling.h + cocos/renderer/pipeline/Define.h + cocos/renderer/pipeline/Define.cpp + cocos/renderer/pipeline/GlobalDescriptorSetManager.h + cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp + cocos/renderer/pipeline/InstancedBuffer.cpp + cocos/renderer/pipeline/InstancedBuffer.h + cocos/renderer/pipeline/PipelineStateManager.cpp + cocos/renderer/pipeline/PipelineStateManager.h + cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp + cocos/renderer/pipeline/RenderAdditiveLightQueue.h + cocos/renderer/pipeline/RenderBatchedQueue.cpp + cocos/renderer/pipeline/RenderBatchedQueue.h + cocos/renderer/pipeline/RenderFlow.cpp + cocos/renderer/pipeline/RenderFlow.h + cocos/renderer/pipeline/RenderInstancedQueue.cpp + cocos/renderer/pipeline/RenderInstancedQueue.h + cocos/renderer/pipeline/RenderPipeline.cpp + cocos/renderer/pipeline/RenderPipeline.h + cocos/renderer/pipeline/RenderQueue.cpp + cocos/renderer/pipeline/RenderQueue.h + cocos/renderer/pipeline/RenderStage.cpp + cocos/renderer/pipeline/RenderStage.h + cocos/renderer/pipeline/PlanarShadowQueue.cpp + cocos/renderer/pipeline/PlanarShadowQueue.h + cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp + cocos/renderer/pipeline/ShadowMapBatchedQueue.h + cocos/renderer/pipeline/PipelineUBO.cpp + cocos/renderer/pipeline/PipelineUBO.h + cocos/renderer/pipeline/PipelineSceneData.cpp + cocos/renderer/pipeline/PipelineSceneData.h + cocos/renderer/pipeline/forward/ForwardFlow.cpp + cocos/renderer/pipeline/forward/ForwardFlow.h + cocos/renderer/pipeline/forward/ForwardPipeline.cpp + cocos/renderer/pipeline/forward/ForwardPipeline.h + cocos/renderer/pipeline/forward/ForwardStage.cpp + cocos/renderer/pipeline/forward/ForwardStage.h + cocos/renderer/pipeline/SceneCulling.cpp + cocos/renderer/pipeline/SceneCulling.h + cocos/renderer/pipeline/deferred/DeferredPipeline.cpp + cocos/renderer/pipeline/deferred/DeferredPipeline.h + cocos/renderer/pipeline/deferred/MainFlow.cpp + cocos/renderer/pipeline/deferred/MainFlow.h + cocos/renderer/pipeline/deferred/DeferredPipelineSceneData.cpp + cocos/renderer/pipeline/deferred/DeferredPipelineSceneData.h + cocos/renderer/pipeline/deferred/GbufferStage.cpp + cocos/renderer/pipeline/deferred/GbufferStage.h + cocos/renderer/pipeline/deferred/LightingStage.cpp + cocos/renderer/pipeline/deferred/LightingStage.h + cocos/renderer/pipeline/deferred/ReflectionComp.cpp + cocos/renderer/pipeline/deferred/ReflectionComp.h + cocos/renderer/pipeline/shadow/ShadowFlow.cpp + cocos/renderer/pipeline/shadow/ShadowFlow.h + cocos/renderer/pipeline/shadow/ShadowStage.cpp + cocos/renderer/pipeline/shadow/ShadowStage.h + cocos/renderer/pipeline/shadow/CSMLayers.cpp + cocos/renderer/pipeline/shadow/CSMLayers.h + cocos/renderer/pipeline/Enum.h + cocos/renderer/pipeline/deferred/BloomStage.cpp + cocos/renderer/pipeline/deferred/BloomStage.h + cocos/renderer/pipeline/deferred/PostProcessStage.cpp + cocos/renderer/pipeline/deferred/PostProcessStage.h + cocos/renderer/pipeline/UIPhase.cpp + cocos/renderer/pipeline/UIPhase.h + cocos/renderer/pipeline/helper/Utils.h + cocos/renderer/pipeline/helper/Utils.cpp + cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp + cocos/renderer/pipeline/custom/test/test.h + cocos/renderer/pipeline/custom/FGDispatcherGraphs.h + cocos/renderer/pipeline/custom/FGDispatcherTypes.cpp + cocos/renderer/pipeline/custom/FGDispatcherTypes.h + cocos/renderer/pipeline/custom/LayoutGraphFwd.h + cocos/renderer/pipeline/custom/LayoutGraphGraphs.h + cocos/renderer/pipeline/custom/LayoutGraphJsb.cpp + cocos/renderer/pipeline/custom/LayoutGraphJsb.h + cocos/renderer/pipeline/custom/LayoutGraphNames.h + cocos/renderer/pipeline/custom/LayoutGraphReflection.cpp + cocos/renderer/pipeline/custom/LayoutGraphReflection.h + cocos/renderer/pipeline/custom/LayoutGraphTypes.cpp + cocos/renderer/pipeline/custom/LayoutGraphTypes.h + cocos/renderer/pipeline/custom/NativeLayoutGraphImpl.cpp + cocos/renderer/pipeline/custom/NativePipelineFwd.h + cocos/renderer/pipeline/custom/NativePipelineGraphs.h + cocos/renderer/pipeline/custom/NativePipelineImpl.cpp + cocos/renderer/pipeline/custom/NativePipelineTypes.cpp + cocos/renderer/pipeline/custom/NativePipelineTypes.h + cocos/renderer/pipeline/custom/NativeRenderGraphSetup.cpp + cocos/renderer/pipeline/custom/RenderCommonFwd.h + cocos/renderer/pipeline/custom/RenderCommonJsb.cpp + cocos/renderer/pipeline/custom/RenderCommonJsb.h + cocos/renderer/pipeline/custom/RenderCommonNames.h + cocos/renderer/pipeline/custom/RenderCommonReflection.cpp + cocos/renderer/pipeline/custom/RenderCommonReflection.h + cocos/renderer/pipeline/custom/RenderCommonTypes.cpp + cocos/renderer/pipeline/custom/RenderCommonTypes.h + cocos/renderer/pipeline/custom/RenderGraphFwd.h + cocos/renderer/pipeline/custom/RenderGraphGraphs.h + cocos/renderer/pipeline/custom/RenderGraphJsb.cpp + cocos/renderer/pipeline/custom/RenderGraphJsb.h + cocos/renderer/pipeline/custom/RenderGraphNames.h + cocos/renderer/pipeline/custom/RenderGraphReflection.cpp + cocos/renderer/pipeline/custom/RenderGraphReflection.h + cocos/renderer/pipeline/custom/RenderGraphTypes.cpp + cocos/renderer/pipeline/custom/RenderGraphTypes.h + cocos/renderer/pipeline/custom/RenderInterfaceFwd.h + cocos/renderer/pipeline/custom/RenderInterfaceImpl.cpp + cocos/renderer/pipeline/custom/RenderInterfaceTypes.cpp + cocos/renderer/pipeline/custom/RenderInterfaceTypes.h +) + +if (USE_GEOMETRY_RENDERER) + cocos_source_files( + cocos/renderer/pipeline/GeometryRenderer.h + cocos/renderer/pipeline/GeometryRenderer.cpp + ) +endif() + +##### terrain +# +# cocos_source_files( +# cocos/terrain/HeightField.cpp +# cocos/terrain/HeightField.h +# cocos/terrain/Terrain.cpp +# cocos/terrain/Terrain.h +# cocos/terrain/TerrainAsset.cpp +# cocos/terrain/TerrainAsset.h +# cocos/terrain/TerrainLod.cpp +# cocos/terrain/TerrainLod.h +# ) + + +##### scene +cocos_source_files( + cocos/scene/Ambient.h + cocos/scene/Ambient.cpp + cocos/scene/Camera.h + cocos/scene/Camera.cpp + cocos/scene/Define.h + cocos/scene/Define.cpp + cocos/scene/DirectionalLight.h + cocos/scene/DirectionalLight.cpp + cocos/scene/DrawBatch2D.h + cocos/scene/DrawBatch2D.cpp + cocos/scene/Fog.h + cocos/scene/Fog.cpp + cocos/scene/Light.h + cocos/scene/Light.cpp + cocos/scene/Model.h + cocos/scene/Model.cpp + cocos/scene/Pass.h + cocos/scene/Pass.cpp + cocos/scene/RenderScene.h + cocos/scene/RenderScene.cpp + cocos/scene/RenderWindow.cpp + cocos/scene/RenderWindow.h + cocos/scene/Skybox.h + cocos/scene/Skybox.cpp + cocos/scene/SphereLight.h + cocos/scene/SphereLight.cpp + cocos/scene/SpotLight.h + cocos/scene/SpotLight.cpp + cocos/scene/SubModel.h + cocos/scene/SubModel.cpp + cocos/scene/Octree.h + cocos/scene/Octree.cpp + cocos/scene/Shadow.h + cocos/scene/Shadow.cpp +) + +##### primitive +cocos_source_files( + cocos/primitive/Box.cpp + cocos/primitive/Box.h + cocos/primitive/Capsule.cpp + cocos/primitive/Capsule.h + cocos/primitive/Circle.cpp + cocos/primitive/Circle.h + cocos/primitive/Cone.cpp + cocos/primitive/Cone.h + cocos/primitive/Cylinder.cpp + cocos/primitive/Cylinder.h + cocos/primitive/Plane.cpp + cocos/primitive/Plane.h + cocos/primitive/Primitive.cpp + cocos/primitive/Primitive.h + cocos/primitive/PrimitiveDefine.h + cocos/primitive/PrimitiveUtils.cpp + cocos/primitive/PrimitiveUtils.h + cocos/primitive/Quad.cpp + cocos/primitive/Quad.h + cocos/primitive/Sphere.cpp + cocos/primitive/Sphere.h + cocos/primitive/Torus.cpp + cocos/primitive/Torus.h + cocos/primitive/Transform.cpp + cocos/primitive/Transform.h +) + +##### profiler +if (USE_DEBUG_RENDERER) +cocos_source_files( + cocos/profiler/DebugRenderer.h + cocos/profiler/DebugRenderer.cpp +) +endif() + +cocos_source_files( + cocos/profiler/Profiler.h + cocos/profiler/Profiler.cpp + cocos/profiler/GameStats.h +) + +##### components +cocos_source_files( + # cocos/core/components/Component.h + # cocos/core/components/Component.cpp + # cocos/core/components/RenderableComponent.h + # cocos/core/components/RenderableComponent.cpp + # cocos/core/components/CameraComponent.h + # cocos/core/components/CameraComponent.cpp + cocos/3d/models/BakedSkinningModel.h + cocos/3d/models/BakedSkinningModel.cpp + cocos/3d/models/MorphModel.h + cocos/3d/models/MorphModel.cpp + cocos/3d/models/SkinningModel.h + cocos/3d/models/SkinningModel.cpp + # cocos/3d/framework/MeshRenderer.h + # cocos/3d/framework/MeshRenderer.cpp +) + +##### animations +cocos_source_files( + cocos/core/animation/SkeletalAnimationUtils.h + cocos/core/animation/SkeletalAnimationUtils.cpp +) + +##### lights +# cocos_source_files( +# cocos/3d/lights/LightComponent.h +# cocos/3d/lights/LightComponent.cpp +# cocos/3d/lights/DirectionalLightComponent.h +# cocos/3d/lights/DirectionalLightComponent.cpp +# cocos/3d/lights/SpotLightComponent.h +# cocos/3d/lights/SpotLightComponent.cpp +# cocos/3d/lights/SphereLightComponent.h +# cocos/3d/lights/SphereLightComponent.cpp +# ) + +if(CC_USE_GLES2 OR CC_USE_GLES3) + cocos_source_files( + cocos/renderer/gfx-gles-common/GLESCommandPool.h + cocos/renderer/gfx-gles-common/eglw.cpp + cocos/renderer/gfx-gles-common/gles2w.cpp + ) + if(CC_USE_GLES3) + cocos_source_files( + cocos/renderer/gfx-gles-common/gles3w.cpp + ) + endif() +endif() + +if(CC_USE_GLES2) + cocos_source_files( + cocos/renderer/gfx-gles2/GLES2Buffer.cpp + cocos/renderer/gfx-gles2/GLES2Buffer.h + cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp + cocos/renderer/gfx-gles2/GLES2CommandBuffer.h + cocos/renderer/gfx-gles2/GLES2Commands.cpp + cocos/renderer/gfx-gles2/GLES2Commands.h + cocos/renderer/gfx-gles2/GLES2Device.cpp + cocos/renderer/gfx-gles2/GLES2Device.h + cocos/renderer/gfx-gles2/GLES2Framebuffer.cpp + cocos/renderer/gfx-gles2/GLES2Framebuffer.h + cocos/renderer/gfx-gles2/GLES2GPUContext.cpp + cocos/renderer/gfx-gles2/GLES2GPUObjects.h + cocos/renderer/gfx-gles2/GLES2InputAssembler.cpp + cocos/renderer/gfx-gles2/GLES2InputAssembler.h + cocos/renderer/gfx-gles2/GLES2DescriptorSet.cpp + cocos/renderer/gfx-gles2/GLES2DescriptorSet.h + cocos/renderer/gfx-gles2/GLES2DescriptorSetLayout.cpp + cocos/renderer/gfx-gles2/GLES2DescriptorSetLayout.h + cocos/renderer/gfx-gles2/GLES2PipelineLayout.cpp + cocos/renderer/gfx-gles2/GLES2PipelineLayout.h + cocos/renderer/gfx-gles2/GLES2PipelineState.cpp + cocos/renderer/gfx-gles2/GLES2PipelineState.h + cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp + cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.h + cocos/renderer/gfx-gles2/GLES2Queue.cpp + cocos/renderer/gfx-gles2/GLES2Queue.h + cocos/renderer/gfx-gles2/GLES2QueryPool.cpp + cocos/renderer/gfx-gles2/GLES2QueryPool.h + cocos/renderer/gfx-gles2/GLES2RenderPass.cpp + cocos/renderer/gfx-gles2/GLES2RenderPass.h + cocos/renderer/gfx-gles2/GLES2Shader.cpp + cocos/renderer/gfx-gles2/GLES2Shader.h + cocos/renderer/gfx-gles2/GLES2Swapchain.cpp + cocos/renderer/gfx-gles2/GLES2Swapchain.h + cocos/renderer/gfx-gles2/GLES2Std.cpp + cocos/renderer/gfx-gles2/GLES2Std.h + cocos/renderer/gfx-gles2/GLES2Texture.cpp + cocos/renderer/gfx-gles2/GLES2Texture.h + cocos/renderer/gfx-gles2/GLES2Wrangler.cpp + cocos/renderer/gfx-gles2/GLES2Wrangler.h + cocos/renderer/gfx-gles2/states/GLES2Sampler.cpp + cocos/renderer/gfx-gles2/states/GLES2Sampler.h + ) +endif() + +if(CC_USE_GLES3) + cocos_source_files( + cocos/renderer/gfx-gles3/GLES3Buffer.cpp + cocos/renderer/gfx-gles3/GLES3Buffer.h + cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp + cocos/renderer/gfx-gles3/GLES3CommandBuffer.h + cocos/renderer/gfx-gles3/GLES3Commands.cpp + cocos/renderer/gfx-gles3/GLES3Commands.h + cocos/renderer/gfx-gles3/GLES3Device.cpp + cocos/renderer/gfx-gles3/GLES3Device.h + cocos/renderer/gfx-gles3/GLES3Framebuffer.cpp + cocos/renderer/gfx-gles3/GLES3Framebuffer.h + cocos/renderer/gfx-gles3/GLES3GPUContext.cpp + cocos/renderer/gfx-gles3/GLES3GPUObjects.h + cocos/renderer/gfx-gles3/GLES3InputAssembler.cpp + cocos/renderer/gfx-gles3/GLES3InputAssembler.h + cocos/renderer/gfx-gles3/GLES3DescriptorSet.cpp + cocos/renderer/gfx-gles3/GLES3DescriptorSet.h + cocos/renderer/gfx-gles3/GLES3DescriptorSetLayout.cpp + cocos/renderer/gfx-gles3/GLES3DescriptorSetLayout.h + cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp + cocos/renderer/gfx-gles3/GLES3PipelineLayout.h + cocos/renderer/gfx-gles3/GLES3PipelineState.cpp + cocos/renderer/gfx-gles3/GLES3PipelineState.h + cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp + cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.h + cocos/renderer/gfx-gles3/GLES3Queue.cpp + cocos/renderer/gfx-gles3/GLES3Queue.h + cocos/renderer/gfx-gles3/GLES3QueryPool.cpp + cocos/renderer/gfx-gles3/GLES3QueryPool.h + cocos/renderer/gfx-gles3/GLES3RenderPass.cpp + cocos/renderer/gfx-gles3/GLES3RenderPass.h + cocos/renderer/gfx-gles3/GLES3Shader.cpp + cocos/renderer/gfx-gles3/GLES3Shader.h + cocos/renderer/gfx-gles3/GLES3Swapchain.cpp + cocos/renderer/gfx-gles3/GLES3Swapchain.h + cocos/renderer/gfx-gles3/GLES3Std.cpp + cocos/renderer/gfx-gles3/GLES3Std.h + cocos/renderer/gfx-gles3/GLES3Texture.cpp + cocos/renderer/gfx-gles3/GLES3Texture.h + cocos/renderer/gfx-gles3/GLES3Wrangler.cpp + cocos/renderer/gfx-gles3/GLES3Wrangler.h + cocos/renderer/gfx-gles3/states/GLES3GeneralBarrier.cpp + cocos/renderer/gfx-gles3/states/GLES3GeneralBarrier.h + cocos/renderer/gfx-gles3/states/GLES3Sampler.cpp + cocos/renderer/gfx-gles3/states/GLES3Sampler.h + ) +endif() + +if(CC_USE_METAL) + cocos_source_files( + cocos/renderer/gfx-metal/MTLBuffer.h + cocos/renderer/gfx-metal/MTLBuffer.mm + cocos/renderer/gfx-metal/MTLCommandBuffer.h + cocos/renderer/gfx-metal/MTLCommandBuffer.mm + cocos/renderer/gfx-metal/MTLDevice.h + NO_WERROR NO_UBUILD cocos/renderer/gfx-metal/MTLDevice.mm # CAMetalLayer bug for apple + cocos/renderer/gfx-metal/MTLFramebuffer.mm + cocos/renderer/gfx-metal/MTLFramebuffer.h + cocos/renderer/gfx-metal/MTLGPUObjects.h + cocos/renderer/gfx-metal/MTLInputAssembler.h + cocos/renderer/gfx-metal/MTLInputAssembler.mm + cocos/renderer/gfx-metal/MTLDescriptorSetLayout.h + cocos/renderer/gfx-metal/MTLDescriptorSetLayout.mm + cocos/renderer/gfx-metal/MTLPipelineLayout.h + cocos/renderer/gfx-metal/MTLPipelineLayout.mm + cocos/renderer/gfx-metal/MTLPipelineState.h + cocos/renderer/gfx-metal/MTLPipelineState.mm + cocos/renderer/gfx-metal/MTLDescriptorSet.h + cocos/renderer/gfx-metal/MTLDescriptorSet.mm + cocos/renderer/gfx-metal/MTLQueue.h + cocos/renderer/gfx-metal/MTLQueue.mm + cocos/renderer/gfx-metal/MTLQueryPool.h + cocos/renderer/gfx-metal/MTLQueryPool.mm + cocos/renderer/gfx-metal/MTLRenderPass.h + cocos/renderer/gfx-metal/MTLRenderPass.mm + cocos/renderer/gfx-metal/MTLSampler.h + cocos/renderer/gfx-metal/MTLSampler.mm + cocos/renderer/gfx-metal/MTLShader.h + cocos/renderer/gfx-metal/MTLShader.mm + cocos/renderer/gfx-metal/MTLTexture.h + cocos/renderer/gfx-metal/MTLTexture.mm + cocos/renderer/gfx-metal/MTLUtils.h + cocos/renderer/gfx-metal/MTLUtils.mm + cocos/renderer/gfx-metal/MTLRenderCommandEncoder.h + cocos/renderer/gfx-metal/MTLComputeCommandEncoder.h + cocos/renderer/gfx-metal/MTLCommandEncoder.h + cocos/renderer/gfx-metal/MTLConfig.h + cocos/renderer/gfx-metal/MTLSemaphore.h + cocos/renderer/gfx-metal/MTLSwapchain.h + cocos/renderer/gfx-metal/MTLSwapchain.mm + ) +endif() + +if(CC_USE_VULKAN) + + cocos_source_files( + cocos/renderer/gfx-vulkan/vk_mem_alloc.h + cocos/renderer/gfx-vulkan/VKBuffer.cpp + cocos/renderer/gfx-vulkan/VKBuffer.h + cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp + cocos/renderer/gfx-vulkan/VKCommandBuffer.h + cocos/renderer/gfx-vulkan/VKCommands.cpp + cocos/renderer/gfx-vulkan/VKCommands.h + cocos/renderer/gfx-vulkan/VKDevice.cpp + cocos/renderer/gfx-vulkan/VKDevice.h + cocos/renderer/gfx-vulkan/VKFramebuffer.cpp + cocos/renderer/gfx-vulkan/VKFramebuffer.h + cocos/renderer/gfx-vulkan/VKGPUContext.cpp + cocos/renderer/gfx-vulkan/VKGPUObjects.h + cocos/renderer/gfx-vulkan/VKInputAssembler.cpp + cocos/renderer/gfx-vulkan/VKInputAssembler.h + cocos/renderer/gfx-vulkan/VKDescriptorSet.cpp + cocos/renderer/gfx-vulkan/VKDescriptorSet.h + cocos/renderer/gfx-vulkan/VKDescriptorSetLayout.cpp + cocos/renderer/gfx-vulkan/VKDescriptorSetLayout.h + cocos/renderer/gfx-vulkan/VKPipelineLayout.cpp + cocos/renderer/gfx-vulkan/VKPipelineLayout.h + cocos/renderer/gfx-vulkan/VKPipelineState.cpp + cocos/renderer/gfx-vulkan/VKPipelineState.h + cocos/renderer/gfx-vulkan/VKQueue.cpp + cocos/renderer/gfx-vulkan/VKQueue.h + cocos/renderer/gfx-vulkan/VKQueryPool.cpp + cocos/renderer/gfx-vulkan/VKQueryPool.h + cocos/renderer/gfx-vulkan/VKRenderPass.cpp + cocos/renderer/gfx-vulkan/VKRenderPass.h + cocos/renderer/gfx-vulkan/VKShader.cpp + cocos/renderer/gfx-vulkan/VKShader.h + cocos/renderer/gfx-vulkan/VKStd.cpp + cocos/renderer/gfx-vulkan/VKStd.h + cocos/renderer/gfx-vulkan/VKSwapchain.cpp + cocos/renderer/gfx-vulkan/VKSwapchain.h + cocos/renderer/gfx-vulkan/VKTexture.cpp + cocos/renderer/gfx-vulkan/VKTexture.h + cocos/renderer/gfx-vulkan/VKUtils.cpp + cocos/renderer/gfx-vulkan/VKUtils.h + cocos/renderer/gfx-vulkan/volk.c + cocos/renderer/gfx-vulkan/volk.h + cocos/renderer/gfx-vulkan/states/VKGeneralBarrier.cpp + cocos/renderer/gfx-vulkan/states/VKGeneralBarrier.h + cocos/renderer/gfx-vulkan/states/VKSampler.cpp + cocos/renderer/gfx-vulkan/states/VKSampler.h + cocos/renderer/gfx-vulkan/states/VKTextureBarrier.cpp + cocos/renderer/gfx-vulkan/states/VKTextureBarrier.h + cocos/renderer/gfx-vulkan/states/VKBufferBarrier.cpp + cocos/renderer/gfx-vulkan/states/VKBufferBarrier.h + ) + + if(ANDROID) + set_source_files_properties( + ${CWD}/cocos/renderer/gfx-vulkan/VKDevice.cpp + PROPERTIES + # supress warning on Android + COMPILE_FLAGS -Wno-nullability-completeness + ) + endif() +endif() + +if(NX) + include(${CMAKE_CURRENT_LIST_DIR}/platform-nx/source.cmake) +endif() + +cocos_source_files( + cocos/renderer/frame-graph/Blackboard.h + cocos/renderer/frame-graph/CallbackPass.h + cocos/renderer/frame-graph/DevicePass.cpp + cocos/renderer/frame-graph/DevicePass.h + cocos/renderer/frame-graph/DevicePassResourceTable.cpp + cocos/renderer/frame-graph/DevicePassResourceTable.h + cocos/renderer/frame-graph/FrameGraph.cpp + cocos/renderer/frame-graph/FrameGraph.h + cocos/renderer/frame-graph/Handle.h + cocos/renderer/frame-graph/PassInsertPointManager.cpp + cocos/renderer/frame-graph/PassInsertPointManager.h + cocos/renderer/frame-graph/PassNode.cpp + cocos/renderer/frame-graph/PassNode.h + cocos/renderer/frame-graph/PassNodeBuilder.cpp + cocos/renderer/frame-graph/PassNodeBuilder.h + cocos/renderer/frame-graph/RenderTargetAttachment.h + cocos/renderer/frame-graph/Resource.h + cocos/renderer/frame-graph/ResourceAllocator.h + cocos/renderer/frame-graph/ResourceEntry.h + cocos/renderer/frame-graph/ResourceNode.h + cocos/renderer/frame-graph/VirtualResource.cpp + cocos/renderer/frame-graph/VirtualResource.h + cocos/renderer/frame-graph/ImmutableState.h + cocos/renderer/frame-graph/ImmutableState.cpp +) + +##### physics + +if(USE_PHYSICS_PHYSX) + cocos_source_files( + cocos/physics/PhysicsSDK.h + cocos/physics/PhysicsSelector.h + cocos/physics/sdk/World.h + cocos/physics/sdk/World.cpp + cocos/physics/sdk/Shape.h + cocos/physics/sdk/Shape.cpp + cocos/physics/sdk/RigidBody.h + cocos/physics/sdk/RigidBody.cpp + cocos/physics/sdk/Joint.h + cocos/physics/sdk/Joint.cpp + cocos/physics/spec/IBody.h + cocos/physics/spec/IJoint.h + cocos/physics/spec/ILifecycle.h + cocos/physics/spec/IShape.h + cocos/physics/spec/IWorld.h + cocos/physics/physx/PhysX.h + cocos/physics/physx/PhysXInc.h + cocos/physics/physx/PhysXUtils.h + cocos/physics/physx/PhysXUtils.cpp + cocos/physics/physx/PhysXWorld.h + cocos/physics/physx/PhysXWorld.cpp + cocos/physics/physx/PhysXFilterShader.h + cocos/physics/physx/PhysXFilterShader.cpp + cocos/physics/physx/PhysXEventManager.h + cocos/physics/physx/PhysXEventManager.cpp + cocos/physics/physx/PhysXSharedBody.h + cocos/physics/physx/PhysXSharedBody.cpp + cocos/physics/physx/PhysXRigidBody.h + cocos/physics/physx/PhysXRigidBody.cpp + cocos/physics/physx/shapes/PhysXShape.h + cocos/physics/physx/shapes/PhysXShape.cpp + cocos/physics/physx/shapes/PhysXSphere.h + cocos/physics/physx/shapes/PhysXSphere.cpp + cocos/physics/physx/shapes/PhysXBox.h + cocos/physics/physx/shapes/PhysXBox.cpp + cocos/physics/physx/shapes/PhysXPlane.h + cocos/physics/physx/shapes/PhysXPlane.cpp + cocos/physics/physx/shapes/PhysXCapsule.h + cocos/physics/physx/shapes/PhysXCapsule.cpp + cocos/physics/physx/shapes/PhysXCone.h + cocos/physics/physx/shapes/PhysXCone.cpp + cocos/physics/physx/shapes/PhysXCylinder.h + cocos/physics/physx/shapes/PhysXCylinder.cpp + cocos/physics/physx/shapes/PhysXTerrain.h + cocos/physics/physx/shapes/PhysXTerrain.cpp + cocos/physics/physx/shapes/PhysXTrimesh.h + cocos/physics/physx/shapes/PhysXTrimesh.cpp + cocos/physics/physx/joints/PhysXJoint.h + cocos/physics/physx/joints/PhysXJoint.cpp + cocos/physics/physx/joints/PhysXRevolute.h + cocos/physics/physx/joints/PhysXRevolute.cpp + cocos/physics/physx/joints/PhysXDistance.h + cocos/physics/physx/joints/PhysXDistance.cpp + ) + cocos_source_files( + cocos/bindings/auto/jsb_physics_auto.cpp + cocos/bindings/auto/jsb_physics_auto.h + ) +endif() + +##### 2d +cocos_source_files( + cocos/2d/renderer/Batcher2d.h + cocos/2d/renderer/Batcher2d.cpp + cocos/2d/renderer/UIModelProxy.h + cocos/2d/renderer/UIModelProxy.cpp + cocos/2d/renderer/RenderDrawInfo.h + cocos/2d/renderer/RenderDrawInfo.cpp + cocos/2d/renderer/UIMeshBuffer.h + cocos/2d/renderer/UIMeshBuffer.cpp + cocos/2d/renderer/RenderEntity.h + cocos/2d/renderer/RenderEntity.cpp + cocos/2d/renderer/StencilManager.h + cocos/2d/renderer/StencilManager.cpp +) + +##### 3d +cocos_source_files( + cocos/3d/assets/Types.h + cocos/3d/assets/Types.cpp + cocos/3d/assets/Mesh.h + cocos/3d/assets/Mesh.cpp + cocos/3d/assets/Morph.h + cocos/3d/assets/Morph.cpp + cocos/3d/assets/MorphRendering.h + cocos/3d/assets/MorphRendering.cpp + cocos/3d/assets/Skeleton.h + cocos/3d/assets/Skeleton.cpp + + cocos/3d/misc/CreateMesh.h + cocos/3d/misc/CreateMesh.cpp + cocos/3d/misc/BufferBlob.h + cocos/3d/misc/BufferBlob.cpp + cocos/3d/misc/Buffer.h + cocos/3d/misc/Buffer.cpp + + # cocos/3d/skeletal-animation/DataPoolManager.h + # cocos/3d/skeletal-animation/DataPoolManager.cpp + cocos/3d/skeletal-animation/SkeletalAnimationUtils.h + cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp +) + +##### core + +cocos_source_files( + cocos/core/Any.h + cocos/core/ArrayBuffer.h + + cocos/core/DataView.h + cocos/core/DataView.cpp + # cocos/core/Director.cpp + # cocos/core/Director.h + # cocos/core/Game.cpp + # cocos/core/Game.h + cocos/core/Root.cpp + cocos/core/Root.h + + cocos/core/System.h + + # cocos/core/Scheduler.cpp + # cocos/core/Scheduler.h + # cocos/core/SplashScreen.cpp + # cocos/core/SplashScreen.h + cocos/core/Types.h + cocos/core/Types.cpp + cocos/core/TypedArray.h + cocos/core/TypedArray.cpp + + # memop + cocos/core/memop/CachedArray.h + cocos/core/memop/Pool.h + cocos/core/memop/Pool.cpp + cocos/core/memop/RecyclePool.h + cocos/core/memop/RecyclePool.cpp + + + # cocos/core/asset-manager/AssetManager.cpp + # cocos/core/asset-manager/AssetManager.h + # cocos/core/asset-manager/AssetManagerModuleHeader.h + # cocos/core/asset-manager/Bundle.cpp + # cocos/core/asset-manager/Bundle.h + # cocos/core/asset-manager/Cache.cpp + # cocos/core/asset-manager/Cache.h + # cocos/core/asset-manager/CacheManager.cpp + # cocos/core/asset-manager/CacheManager.h + # cocos/core/asset-manager/AssetManagerConfig.cpp + # cocos/core/asset-manager/AssetManagerConfig.h + # cocos/core/asset-manager/DependMaps.cpp + # cocos/core/asset-manager/DependMaps.h + # cocos/core/asset-manager/DependUtil.cpp + # cocos/core/asset-manager/DependUtil.h + # cocos/core/asset-manager/Deserialize.cpp + # cocos/core/asset-manager/Deserialize.h + # cocos/core/asset-manager/DownloadFile.cpp + # cocos/core/asset-manager/DownloadFile.h + # cocos/core/asset-manager/DownloadImage.cpp + # cocos/core/asset-manager/DownloadImage.h + # cocos/core/asset-manager/DownloadScript.cpp + # cocos/core/asset-manager/DownloadScript.h + # cocos/core/asset-manager/Downloader.cpp + # cocos/core/asset-manager/Downloader.h + # cocos/core/asset-manager/Factory.cpp + # cocos/core/asset-manager/Factory.h + # cocos/core/asset-manager/Fetch.cpp + # cocos/core/asset-manager/Fetch.h + # cocos/core/asset-manager/Helper.cpp + # cocos/core/asset-manager/Helper.h + # cocos/core/asset-manager/Load.cpp + # cocos/core/asset-manager/Load.h + # cocos/core/asset-manager/PackManager.cpp + # cocos/core/asset-manager/PackManager.h + # cocos/core/asset-manager/Parser.cpp + # cocos/core/asset-manager/Parser.h + # cocos/core/asset-manager/Pipeline.cpp + # cocos/core/asset-manager/Pipeline.h + # cocos/core/asset-manager/PlistParser.cpp + # cocos/core/asset-manager/PlistParser.h + # cocos/core/asset-manager/PreProcess.cpp + # cocos/core/asset-manager/PreProcess.h + # cocos/core/asset-manager/ReleaseManager.cpp + # cocos/core/asset-manager/ReleaseManager.h + # cocos/core/asset-manager/RequestItem.cpp + # cocos/core/asset-manager/RequestItem.h + # cocos/core/asset-manager/Shared.cpp + # cocos/core/asset-manager/Shared.h + # cocos/core/asset-manager/Task.cpp + # cocos/core/asset-manager/Task.h + # cocos/core/asset-manager/UrlTransformer.cpp + # cocos/core/asset-manager/UrlTransformer.h + # cocos/core/asset-manager/Utilities.cpp + # cocos/core/asset-manager/Utilities.h + # cocos/core/asset-manager/WeakCache.cpp + # cocos/core/asset-manager/WeakCache.h + + cocos/core/assets/Asset.cpp + cocos/core/assets/Asset.h + cocos/core/assets/AssetEnum.cpp + cocos/core/assets/AssetEnum.h + cocos/core/assets/AssetsModuleHeader.h + cocos/core/assets/BufferAsset.cpp + cocos/core/assets/BufferAsset.h + cocos/core/assets/EffectAsset.cpp + cocos/core/assets/EffectAsset.h + cocos/core/assets/ImageAsset.cpp + cocos/core/assets/ImageAsset.h + # cocos/core/assets/JsonAsset.cpp + # cocos/core/assets/JsonAsset.h + cocos/core/assets/Material.cpp + cocos/core/assets/Material.h + # cocos/core/assets/Prefab.cpp + # cocos/core/assets/Prefab.h + cocos/core/assets/RenderTexture.cpp + cocos/core/assets/RenderTexture.h + cocos/core/assets/RenderingSubMesh.cpp + cocos/core/assets/RenderingSubMesh.h + cocos/core/assets/SceneAsset.cpp + cocos/core/assets/SceneAsset.h + cocos/core/assets/SimpleTexture.cpp + cocos/core/assets/SimpleTexture.h + cocos/core/assets/TextAsset.cpp + cocos/core/assets/TextAsset.h + cocos/core/assets/Texture2D.cpp + cocos/core/assets/Texture2D.h + cocos/core/assets/TextureBase.cpp + cocos/core/assets/TextureBase.h + cocos/core/assets/TextureCube.cpp + cocos/core/assets/TextureCube.h + cocos/core/assets/BitmapFont.h + cocos/core/assets/BitmapFont.cpp + cocos/core/assets/Font.h + cocos/core/assets/Font.cpp + + # builtin + cocos/core/builtin/BuiltinResMgr.cpp + cocos/core/builtin/BuiltinResMgr.h + # cocos/core/builtin/ShaderSourceAssembly.cpp + # cocos/core/builtin/ShaderSourceAssembly.h + # cocos/core/builtin/Effects.cpp # generated + # cocos/core/builtin/Effects.h + # cocos/core/builtin/shader-sources/glsl1.cpp # generated + # cocos/core/builtin/shader-sources/glsl1.h + # cocos/core/builtin/shader-sources/glsl3.cpp # generated + # cocos/core/builtin/shader-sources/glsl3.h + # cocos/core/builtin/shader-sources/glsl4.cpp # generated + # cocos/core/builtin/shader-sources/glsl4.h + # + + cocos/core/data/Object.cpp + cocos/core/data/Object.h + cocos/core/data/JSBNativeDataHolder.h + # cocos/core/data/deserializer/EffectAssetDeserializer.cpp + # cocos/core/data/deserializer/EffectAssetDeserializer.h + # cocos/core/data/deserializer/MeshDeserializer.cpp + # cocos/core/data/deserializer/MeshDeserializer.h + # cocos/core/data/deserializer/MaterialDeserializer.cpp + # cocos/core/data/deserializer/MaterialDeserializer.h + # cocos/core/data/deserializer/ImageAssetDeserializer.cpp + # cocos/core/data/deserializer/ImageAssetDeserializer.h + # cocos/core/data/deserializer/TextureBaseDeserializer.h + # cocos/core/data/deserializer/TextureBaseDeserializer.cpp + # cocos/core/data/deserializer/Texture2DDeserializer.cpp + # cocos/core/data/deserializer/Texture2DDeserializer.h + # cocos/core/data/deserializer/TerrainAssetDeserializer.cpp + # cocos/core/data/deserializer/TerrainAssetDeserializer.h + # cocos/core/data/deserializer/IAssetDeserializer.h + # cocos/core/data/deserializer/AssetDeserializerFactory.cpp + # cocos/core/data/deserializer/AssetDeserializerFactory.h + + cocos/core/event/CallbacksInvoker.cpp + cocos/core/event/CallbacksInvoker.h + cocos/core/event/EventTypesToJS.h + cocos/core/event/EventTypesToJS.cpp + # cocos/core/event/Event.cpp + # cocos/core/event/Event.h + # cocos/core/scene-graph/Find.cpp + # cocos/core/scene-graph/Find.h + cocos/core/scene-graph/Layers.h + cocos/core/scene-graph/Node.cpp + cocos/core/scene-graph/Node.h + cocos/core/scene-graph/BaseNode.h + # cocos/core/scene-graph/ComponentScheduler.h + # cocos/core/scene-graph/ComponentScheduler.cpp + # cocos/core/scene-graph/NodeActivator.cpp + # cocos/core/scene-graph/NodeActivator.h + cocos/core/scene-graph/NodeEnum.h + cocos/core/scene-graph/NodeEvent.cpp + cocos/core/scene-graph/NodeEvent.h + cocos/core/scene-graph/NodeEventProcessor.cpp + cocos/core/scene-graph/NodeEventProcessor.h + # cocos/core/scene-graph/NodeUIProperties.cpp + # cocos/core/scene-graph/NodeUIProperties.h + cocos/core/scene-graph/Scene.cpp + cocos/core/scene-graph/Scene.h + cocos/core/scene-graph/SceneGlobals.cpp + cocos/core/scene-graph/SceneGlobals.h + cocos/core/scene-graph/SceneGraphModuleHeader.h + + cocos/core/utils/IDGenerator.cpp + cocos/core/utils/IDGenerator.h + cocos/core/utils/Path.cpp + cocos/core/utils/Path.h + cocos/core/utils/MutableForwardIterator.cpp + cocos/core/utils/MutableForwardIterator.h + cocos/core/utils/Pool.h + cocos/core/utils/ImageUtils.h + cocos/core/utils/ImageUtils.cpp + + # cocos/core/platform/native/SystemInfo.h + # cocos/core/platform/native/SystemInfo.cpp + + cocos/core/platform/Debug.h + cocos/core/platform/Debug.cpp + cocos/core/platform/Macro.h + cocos/core/platform/Macro.cpp + # cocos/core/platform/Screen.h + # cocos/core/platform/Screen.cpp + # cocos/core/platform/View.h + # cocos/core/platform/View.cpp + # cocos/core/platform/VisibleRect.h + # cocos/core/platform/VisibleRect.cpp + +) + +# FreeTypeFont is used in DebugRenderer currently +if (USE_DEBUG_RENDERER) +cocos_source_files( + cocos/core/assets/FreeTypeFont.h + cocos/core/assets/FreeTypeFont.cpp +) +endif() + +cocos_source_files(MODULE ccgeometry + cocos/core/geometry/AABB.cpp + cocos/core/geometry/AABB.h + cocos/core/geometry/Capsule.cpp + cocos/core/geometry/Capsule.h + # cocos/core/geometry/Curve.cpp + # cocos/core/geometry/Curve.h + cocos/core/geometry/Distance.cpp + cocos/core/geometry/Distance.h + cocos/core/geometry/Enums.h + cocos/core/geometry/Frustum.cpp + cocos/core/geometry/Frustum.h + cocos/core/geometry/Intersect.cpp + cocos/core/geometry/Intersect.h + cocos/core/geometry/Line.cpp + cocos/core/geometry/Line.h + cocos/core/geometry/Obb.cpp + cocos/core/geometry/Obb.h + cocos/core/geometry/Plane.cpp + cocos/core/geometry/Plane.h + cocos/core/geometry/Ray.cpp + cocos/core/geometry/Ray.h + cocos/core/geometry/Spec.cpp + cocos/core/geometry/Spec.h + cocos/core/geometry/Sphere.cpp + cocos/core/geometry/Sphere.h + cocos/core/geometry/Spline.cpp + cocos/core/geometry/Spline.h + cocos/core/geometry/Triangle.cpp + cocos/core/geometry/Triangle.h +) + +##### script bindings + +######## utils +cocos_source_files( + cocos/bindings/utils/BindingUtils.cpp + cocos/bindings/utils/BindingUtils.h +) + +######## dop +cocos_source_files( + NO_UBUILD cocos/bindings/dop/BufferPool.cpp + cocos/bindings/dop/BufferPool.h + NO_UBUILD cocos/bindings/dop/jsb_dop.cpp + cocos/bindings/dop/jsb_dop.h + cocos/bindings/dop/PoolType.h + cocos/bindings/dop/BufferAllocator.h + NO_UBUILD cocos/bindings/dop/BufferAllocator.cpp +) + +######## auto +cocos_source_files( + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_cocos_auto.cpp + cocos/bindings/auto/jsb_cocos_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_extension_auto.cpp + cocos/bindings/auto/jsb_extension_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_gfx_auto.cpp + cocos/bindings/auto/jsb_gfx_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_network_auto.cpp + cocos/bindings/auto/jsb_network_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_pipeline_auto.cpp + cocos/bindings/auto/jsb_pipeline_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_scene_auto.cpp + cocos/bindings/auto/jsb_scene_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_assets_auto.cpp + cocos/bindings/auto/jsb_assets_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_geometry_auto.cpp + cocos/bindings/auto/jsb_geometry_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_render_auto.cpp + cocos/bindings/auto/jsb_render_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_2d_auto.cpp + cocos/bindings/auto/jsb_2d_auto.h +) + +if(USE_AUDIO) + cocos_source_files( + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_audio_auto.cpp + cocos/bindings/auto/jsb_audio_auto.h + ) +endif() + +if(USE_VIDEO) + cocos_source_files( + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_video_auto.cpp + cocos/bindings/auto/jsb_video_auto.h + ) +endif() + +if(USE_WEBVIEW) + cocos_source_files( + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_webview_auto.cpp + cocos/bindings/auto/jsb_webview_auto.h + ) +endif() + +if(USE_XR) + cocos_source_files( + NO_WERROR cocos/bindings/auto/jsb_xr_auto.cpp + cocos/bindings/auto/jsb_xr_auto.h + ) +endif() + +if(USE_MIDDLEWARE) + cocos_source_files( + cocos/editor-support/IOBuffer.cpp + cocos/editor-support/IOBuffer.h + cocos/editor-support/IOTypedArray.cpp + cocos/editor-support/IOTypedArray.h + cocos/editor-support/MeshBuffer.cpp + cocos/editor-support/MeshBuffer.h + cocos/editor-support/middleware-adapter.cpp + cocos/editor-support/middleware-adapter.h + cocos/editor-support/MiddlewareMacro.h + cocos/editor-support/MiddlewareManager.cpp + cocos/editor-support/MiddlewareManager.h + cocos/editor-support/SharedBufferManager.cpp + cocos/editor-support/SharedBufferManager.h + cocos/editor-support/TypedArrayPool.cpp + cocos/editor-support/TypedArrayPool.h + ) + + cocos_source_files( + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_editor_support_auto.cpp + cocos/bindings/auto/jsb_editor_support_auto.h + ) + + if(USE_SPINE) + cocos_source_files( + NO_WERROR NO_UBUILD cocos/editor-support/spine/Animation.cpp + cocos/editor-support/spine/Animation.h + NO_WERROR NO_UBUILD cocos/editor-support/spine/AnimationState.cpp + cocos/editor-support/spine/AnimationState.h + NO_WERROR cocos/editor-support/spine/AnimationStateData.cpp + cocos/editor-support/spine/AnimationStateData.h + NO_WERROR cocos/editor-support/spine/Atlas.cpp + cocos/editor-support/spine/Atlas.h + NO_WERROR cocos/editor-support/spine/AtlasAttachmentLoader.cpp + cocos/editor-support/spine/AtlasAttachmentLoader.h + NO_WERROR cocos/editor-support/spine/Attachment.cpp + cocos/editor-support/spine/Attachment.h + NO_WERROR cocos/editor-support/spine/AttachmentLoader.cpp + cocos/editor-support/spine/AttachmentLoader.h + NO_WERROR cocos/editor-support/spine/AttachmentTimeline.cpp + cocos/editor-support/spine/AttachmentTimeline.h + cocos/editor-support/spine/AttachmentType.h + cocos/editor-support/spine/BlendMode.h + NO_WERROR cocos/editor-support/spine/Bone.cpp + cocos/editor-support/spine/Bone.h + NO_WERROR cocos/editor-support/spine/BoneData.cpp + cocos/editor-support/spine/BoneData.h + NO_WERROR cocos/editor-support/spine/BoundingBoxAttachment.cpp + cocos/editor-support/spine/BoundingBoxAttachment.h + NO_WERROR cocos/editor-support/spine/ClippingAttachment.cpp + cocos/editor-support/spine/ClippingAttachment.h + cocos/editor-support/spine/Color.h + NO_WERROR cocos/editor-support/spine/ColorTimeline.cpp + cocos/editor-support/spine/ColorTimeline.h + NO_WERROR cocos/editor-support/spine/Constraint.cpp + cocos/editor-support/spine/Constraint.h + NO_WERROR NO_UBUILD cocos/editor-support/spine/ConstraintData.cpp + cocos/editor-support/spine/ConstraintData.h + cocos/editor-support/spine/ContainerUtil.h + NO_WERROR cocos/editor-support/spine/CurveTimeline.cpp + cocos/editor-support/spine/CurveTimeline.h + cocos/editor-support/spine/Debug.h + NO_WERROR cocos/editor-support/spine/DeformTimeline.cpp + cocos/editor-support/spine/DeformTimeline.h + cocos/editor-support/spine/dll.h + NO_WERROR cocos/editor-support/spine/DrawOrderTimeline.cpp + cocos/editor-support/spine/DrawOrderTimeline.h + NO_WERROR cocos/editor-support/spine/Event.cpp + cocos/editor-support/spine/Event.h + NO_WERROR cocos/editor-support/spine/EventData.cpp + cocos/editor-support/spine/EventData.h + NO_WERROR cocos/editor-support/spine/EventTimeline.cpp + cocos/editor-support/spine/EventTimeline.h + NO_WERROR cocos/editor-support/spine/Extension.cpp + cocos/editor-support/spine/Extension.h + cocos/editor-support/spine/HashMap.h + cocos/editor-support/spine/HasRendererObject.h + NO_WERROR cocos/editor-support/spine/IkConstraint.cpp + cocos/editor-support/spine/IkConstraint.h + NO_WERROR cocos/editor-support/spine/IkConstraintData.cpp + cocos/editor-support/spine/IkConstraintData.h + NO_WERROR cocos/editor-support/spine/IkConstraintTimeline.cpp + cocos/editor-support/spine/IkConstraintTimeline.h + NO_WERROR cocos/editor-support/spine/Json.cpp + cocos/editor-support/spine/Json.h + NO_WERROR cocos/editor-support/spine/LinkedMesh.cpp + cocos/editor-support/spine/LinkedMesh.h + NO_WERROR cocos/editor-support/spine/MathUtil.cpp + cocos/editor-support/spine/MathUtil.h + NO_WERROR cocos/editor-support/spine/MeshAttachment.cpp + cocos/editor-support/spine/MeshAttachment.h + cocos/editor-support/spine/MixBlend.h + cocos/editor-support/spine/MixDirection.h + NO_WERROR cocos/editor-support/spine/PathAttachment.cpp + cocos/editor-support/spine/PathAttachment.h + NO_WERROR cocos/editor-support/spine/PathConstraint.cpp + cocos/editor-support/spine/PathConstraint.h + NO_WERROR cocos/editor-support/spine/PathConstraintData.cpp + cocos/editor-support/spine/PathConstraintData.h + NO_WERROR cocos/editor-support/spine/PathConstraintMixTimeline.cpp + cocos/editor-support/spine/PathConstraintMixTimeline.h + NO_WERROR cocos/editor-support/spine/PathConstraintPositionTimeline.cpp + cocos/editor-support/spine/PathConstraintPositionTimeline.h + NO_WERROR cocos/editor-support/spine/PathConstraintSpacingTimeline.cpp + cocos/editor-support/spine/PathConstraintSpacingTimeline.h + NO_WERROR cocos/editor-support/spine/PointAttachment.cpp + cocos/editor-support/spine/PointAttachment.h + cocos/editor-support/spine/Pool.h + cocos/editor-support/spine/PositionMode.h + NO_WERROR cocos/editor-support/spine/RegionAttachment.cpp + cocos/editor-support/spine/RegionAttachment.h + cocos/editor-support/spine/RotateMode.h + NO_WERROR cocos/editor-support/spine/RotateTimeline.cpp + cocos/editor-support/spine/RotateTimeline.h + NO_WERROR cocos/editor-support/spine/RTTI.cpp + cocos/editor-support/spine/RTTI.h + NO_WERROR cocos/editor-support/spine/ScaleTimeline.cpp + cocos/editor-support/spine/ScaleTimeline.h + NO_WERROR cocos/editor-support/spine/ShearTimeline.cpp + cocos/editor-support/spine/ShearTimeline.h + NO_WERROR cocos/editor-support/spine/Skeleton.cpp + cocos/editor-support/spine/Skeleton.h + NO_WERROR cocos/editor-support/spine/SkeletonBinary.cpp + cocos/editor-support/spine/SkeletonBinary.h + NO_WERROR cocos/editor-support/spine/SkeletonBounds.cpp + cocos/editor-support/spine/SkeletonBounds.h + NO_WERROR cocos/editor-support/spine/SkeletonClipping.cpp + cocos/editor-support/spine/SkeletonClipping.h + NO_WERROR cocos/editor-support/spine/SkeletonData.cpp + cocos/editor-support/spine/SkeletonData.h + NO_WERROR cocos/editor-support/spine/SkeletonJson.cpp + cocos/editor-support/spine/SkeletonJson.h + NO_WERROR cocos/editor-support/spine/Skin.cpp + cocos/editor-support/spine/Skin.h + NO_WERROR cocos/editor-support/spine/Slot.cpp + cocos/editor-support/spine/Slot.h + NO_WERROR cocos/editor-support/spine/SlotData.cpp + cocos/editor-support/spine/SlotData.h + cocos/editor-support/spine/SpacingMode.h + cocos/editor-support/spine/spine.h + NO_WERROR cocos/editor-support/spine/SpineObject.cpp + cocos/editor-support/spine/SpineObject.h + cocos/editor-support/spine/SpineString.h + NO_WERROR cocos/editor-support/spine/TextureLoader.cpp + cocos/editor-support/spine/TextureLoader.h + NO_WERROR cocos/editor-support/spine/Timeline.cpp + cocos/editor-support/spine/Timeline.h + cocos/editor-support/spine/TimelineType.h + NO_WERROR cocos/editor-support/spine/TransformConstraint.cpp + cocos/editor-support/spine/TransformConstraint.h + NO_WERROR cocos/editor-support/spine/TransformConstraintData.cpp + cocos/editor-support/spine/TransformConstraintData.h + NO_WERROR cocos/editor-support/spine/TransformConstraintTimeline.cpp + cocos/editor-support/spine/TransformConstraintTimeline.h + cocos/editor-support/spine/TransformMode.h + NO_WERROR cocos/editor-support/spine/TranslateTimeline.cpp + cocos/editor-support/spine/TranslateTimeline.h + NO_WERROR cocos/editor-support/spine/Triangulator.cpp + cocos/editor-support/spine/Triangulator.h + NO_WERROR cocos/editor-support/spine/TwoColorTimeline.cpp + cocos/editor-support/spine/TwoColorTimeline.h + NO_WERROR cocos/editor-support/spine/Updatable.cpp + cocos/editor-support/spine/Updatable.h + cocos/editor-support/spine/Vector.h + NO_WERROR cocos/editor-support/spine/VertexAttachment.cpp + cocos/editor-support/spine/VertexAttachment.h + NO_WERROR cocos/editor-support/spine/VertexEffect.cpp + cocos/editor-support/spine/VertexEffect.h + cocos/editor-support/spine/Vertices.h + NO_WERROR cocos/editor-support/spine-creator-support/AttachmentVertices.cpp + cocos/editor-support/spine-creator-support/AttachmentVertices.h + NO_WERROR cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp + cocos/editor-support/spine-creator-support/SkeletonAnimation.h + NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCache.cpp + cocos/editor-support/spine-creator-support/SkeletonCache.h + NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.cpp + cocos/editor-support/spine-creator-support/SkeletonCacheAnimation.h + NO_WERROR cocos/editor-support/spine-creator-support/SkeletonCacheMgr.cpp + cocos/editor-support/spine-creator-support/SkeletonCacheMgr.h + NO_WERROR cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp + cocos/editor-support/spine-creator-support/SkeletonDataMgr.h + NO_WERROR NO_UBUILD cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp + cocos/editor-support/spine-creator-support/SkeletonRenderer.h + NO_WERROR cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp + cocos/editor-support/spine-creator-support/spine-cocos2dx.h + NO_WERROR cocos/editor-support/spine-creator-support/VertexEffectDelegate.cpp + cocos/editor-support/spine-creator-support/VertexEffectDelegate.h + + ) + cocos_source_files( + NO_WERROR cocos/bindings/auto/jsb_spine_auto.cpp + cocos/bindings/auto/jsb_spine_auto.h + NO_WERROR cocos/bindings/manual/jsb_spine_manual.cpp + cocos/bindings/manual/jsb_spine_manual.h + ) + endif() + + if(USE_DRAGONBONES) + cocos_source_files( + cocos/editor-support/dragonbones/DragonBonesHeaders.h + NO_WERROR cocos/editor-support/dragonbones/animation/Animation.cpp + cocos/editor-support/dragonbones/animation/Animation.h + NO_WERROR cocos/editor-support/dragonbones/animation/AnimationState.cpp + cocos/editor-support/dragonbones/animation/AnimationState.h + NO_WERROR cocos/editor-support/dragonbones/animation/BaseTimelineState.cpp + cocos/editor-support/dragonbones/animation/BaseTimelineState.h + cocos/editor-support/dragonbones/animation/IAnimatable.h + NO_WERROR cocos/editor-support/dragonbones/animation/TimelineState.cpp + cocos/editor-support/dragonbones/animation/TimelineState.h + NO_WERROR cocos/editor-support/dragonbones/animation/WorldClock.cpp + cocos/editor-support/dragonbones/animation/WorldClock.h + NO_WERROR cocos/editor-support/dragonbones/armature/Armature.cpp + cocos/editor-support/dragonbones/armature/Armature.h + NO_WERROR cocos/editor-support/dragonbones/armature/Bone.cpp + cocos/editor-support/dragonbones/armature/Bone.h + NO_WERROR cocos/editor-support/dragonbones/armature/Constraint.cpp + cocos/editor-support/dragonbones/armature/Constraint.h + NO_WERROR cocos/editor-support/dragonbones/armature/DeformVertices.cpp + cocos/editor-support/dragonbones/armature/DeformVertices.h + cocos/editor-support/dragonbones/armature/IArmatureProxy.h + NO_WERROR cocos/editor-support/dragonbones/armature/Slot.cpp + cocos/editor-support/dragonbones/armature/Slot.h + NO_WERROR cocos/editor-support/dragonbones/armature/TransformObject.cpp + cocos/editor-support/dragonbones/armature/TransformObject.h + NO_WERROR cocos/editor-support/dragonbones/core/BaseObject.cpp + cocos/editor-support/dragonbones/core/BaseObject.h + NO_WERROR cocos/editor-support/dragonbones/core/DragonBones.cpp + cocos/editor-support/dragonbones/core/DragonBones.h + NO_WERROR cocos/editor-support/dragonbones/event/EventObject.cpp + cocos/editor-support/dragonbones/event/EventObject.h + cocos/editor-support/dragonbones/event/IEventDispatcher.h + NO_WERROR cocos/editor-support/dragonbones/factory/BaseFactory.cpp + cocos/editor-support/dragonbones/factory/BaseFactory.h + cocos/editor-support/dragonbones/geom/ColorTransform.h + cocos/editor-support/dragonbones/geom/Matrix.h + NO_WERROR cocos/editor-support/dragonbones/geom/Point.cpp + cocos/editor-support/dragonbones/geom/Point.h + cocos/editor-support/dragonbones/geom/Rectangle.h + NO_WERROR cocos/editor-support/dragonbones/geom/Transform.cpp + cocos/editor-support/dragonbones/geom/Transform.h + NO_WERROR cocos/editor-support/dragonbones/model/AnimationConfig.cpp + cocos/editor-support/dragonbones/model/AnimationConfig.h + NO_WERROR cocos/editor-support/dragonbones/model/AnimationData.cpp + cocos/editor-support/dragonbones/model/AnimationData.h + NO_WERROR cocos/editor-support/dragonbones/model/ArmatureData.cpp + cocos/editor-support/dragonbones/model/ArmatureData.h + NO_WERROR cocos/editor-support/dragonbones/model/BoundingBoxData.cpp + cocos/editor-support/dragonbones/model/BoundingBoxData.h + NO_WERROR cocos/editor-support/dragonbones/model/CanvasData.cpp + cocos/editor-support/dragonbones/model/CanvasData.h + NO_WERROR cocos/editor-support/dragonbones/model/ConstraintData.cpp + cocos/editor-support/dragonbones/model/ConstraintData.h + NO_WERROR cocos/editor-support/dragonbones/model/DisplayData.cpp + cocos/editor-support/dragonbones/model/DisplayData.h + NO_WERROR cocos/editor-support/dragonbones/model/DragonBonesData.cpp + cocos/editor-support/dragonbones/model/DragonBonesData.h + NO_WERROR cocos/editor-support/dragonbones/model/SkinData.cpp + cocos/editor-support/dragonbones/model/SkinData.h + NO_WERROR cocos/editor-support/dragonbones/model/TextureAtlasData.cpp + cocos/editor-support/dragonbones/model/TextureAtlasData.h + NO_WERROR cocos/editor-support/dragonbones/model/UserData.cpp + cocos/editor-support/dragonbones/model/UserData.h + NO_WERROR cocos/editor-support/dragonbones/parser/BinaryDataParser.cpp + cocos/editor-support/dragonbones/parser/BinaryDataParser.h + NO_WERROR cocos/editor-support/dragonbones/parser/DataParser.cpp + cocos/editor-support/dragonbones/parser/DataParser.h + NO_WERROR NO_UBUILD cocos/editor-support/dragonbones/parser/JSONDataParser.cpp + cocos/editor-support/dragonbones/parser/JSONDataParser.h + NO_WERROR cocos/editor-support/dragonbones-creator-support/ArmatureCache.cpp + cocos/editor-support/dragonbones-creator-support/ArmatureCache.h + NO_WERROR cocos/editor-support/dragonbones-creator-support/ArmatureCacheMgr.cpp + cocos/editor-support/dragonbones-creator-support/ArmatureCacheMgr.h + NO_WERROR cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.cpp + cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h + NO_WERROR NO_UBUILD cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.cpp + cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h + cocos/editor-support/dragonbones-creator-support/CCDragonBonesHeaders.h + NO_WERROR cocos/editor-support/dragonbones-creator-support/CCFactory.cpp + cocos/editor-support/dragonbones-creator-support/CCFactory.h + NO_WERROR cocos/editor-support/dragonbones-creator-support/CCSlot.cpp + cocos/editor-support/dragonbones-creator-support/CCSlot.h + NO_WERROR cocos/editor-support/dragonbones-creator-support/CCTextureAtlasData.cpp + cocos/editor-support/dragonbones-creator-support/CCTextureAtlasData.h + + ) + cocos_source_files( + NO_WERROR cocos/bindings/auto/jsb_dragonbones_auto.cpp + cocos/bindings/auto/jsb_dragonbones_auto.h + NO_WERROR cocos/bindings/manual/jsb_dragonbones_manual.cpp + cocos/bindings/manual/jsb_dragonbones_manual.h + ) + endif() +endif() + +######## manual +cocos_source_files( + cocos/bindings/manual/jsb_classtype.cpp + cocos/bindings/manual/jsb_classtype.h + cocos/bindings/manual/jsb_cocos_manual.cpp + cocos/bindings/manual/jsb_cocos_manual.h + cocos/bindings/manual/jsb_conversions.h + cocos/bindings/manual/jsb_conversions_spec.cpp + cocos/bindings/manual/jsb_conversions_spec.h + cocos/bindings/manual/jsb_gfx_manual.cpp + cocos/bindings/manual/jsb_gfx_manual.h + cocos/bindings/manual/jsb_global.cpp + cocos/bindings/manual/jsb_global.h + cocos/bindings/manual/jsb_helper.cpp + cocos/bindings/manual/jsb_helper.h + cocos/bindings/manual/jsb_module_register.h + cocos/bindings/manual/jsb_module_register.cpp + cocos/bindings/manual/jsb_platform.h + cocos/bindings/manual/jsb_scene_manual.cpp + cocos/bindings/manual/jsb_scene_manual.h + cocos/bindings/manual/jsb_assets_manual.cpp + cocos/bindings/manual/jsb_assets_manual.h + cocos/bindings/manual/jsb_network_manual.cpp + cocos/bindings/manual/jsb_network_manual.h + cocos/bindings/manual/jsb_xmlhttprequest.cpp + cocos/bindings/manual/jsb_xmlhttprequest.h + cocos/bindings/manual/jsb_pipeline_manual.h + cocos/bindings/manual/jsb_pipeline_manual.cpp +) +if(USE_AUDIO) + cocos_source_files( + cocos/bindings/manual/jsb_audio_manual.cpp + cocos/bindings/manual/jsb_audio_manual.h + ) +endif() +if(USE_SOCKET) + cocos_source_files( + cocos/bindings/manual/jsb_socketio.cpp + cocos/bindings/manual/jsb_socketio.h + cocos/bindings/manual/jsb_websocket.cpp + cocos/bindings/manual/jsb_websocket.h + ) +endif() + +if(NOT IOS AND USE_WEBSOCKET_SERVER) + cocos_source_files( + cocos/bindings/manual/jsb_websocket_server.cpp + cocos/bindings/manual/jsb_websocket_server.h + ) +endif() + +if(ANDROID) + cocos_source_files( + cocos/bindings/manual/jsb_platform_android.cpp + cocos/bindings/manual/JavaScriptJavaBridge.cpp + cocos/bindings/manual/JavaScriptJavaBridge.h + ) +elseif(OHOS) + cocos_source_files( + cocos/bindings/manual/jsb_platform_ohos.cpp + cocos/bindings/manual/JavaScriptJavaBridge.cpp + cocos/bindings/manual/JavaScriptJavaBridge.h + ) +elseif(APPLE) + cocos_source_files( + cocos/bindings/manual/jsb_platform_apple.mm + cocos/bindings/manual/JavaScriptObjCBridge.h + cocos/bindings/manual/JavaScriptObjCBridge.mm + cocos/platform/apple/JsbBridge.h + cocos/platform/apple/JsbBridge.mm + cocos/platform/apple/JsbBridgeWrapper.h + cocos/platform/apple/JsbBridgeWrapper.mm + ) +elseif(WIN32) + cocos_source_files( + NO_WERROR cocos/bindings/manual/jsb_platform_win32.cpp + ) +elseif(LINUX) + cocos_source_files( + NO_WERROR cocos/bindings/manual/jsb_platform_linux.cpp + ) +endif() + +############# module bindings +cocos_source_files(MODULE ccbindings + cocos/bindings/sebind/intl/common.h + cocos/bindings/sebind/intl/common.cpp + cocos/bindings/sebind/class.inl + cocos/bindings/sebind/sebind.h +) + +if(USE_SE_V8) + cocos_source_files(MODULE ccbindings + cocos/bindings/sebind/class_v8.h + cocos/bindings/sebind/class_v8.cpp + cocos/bindings/jswrapper/v8/Base.h + cocos/bindings/jswrapper/v8/Class.cpp + cocos/bindings/jswrapper/v8/Class.h + cocos/bindings/jswrapper/v8/HelperMacros.h + cocos/bindings/jswrapper/v8/HelperMacros.cpp + cocos/bindings/jswrapper/v8/Object.cpp + cocos/bindings/jswrapper/v8/Object.h + cocos/bindings/jswrapper/v8/ObjectWrap.cpp + cocos/bindings/jswrapper/v8/ObjectWrap.h + cocos/bindings/jswrapper/v8/ScriptEngine.cpp + cocos/bindings/jswrapper/v8/ScriptEngine.h + cocos/bindings/jswrapper/v8/SeApi.h + cocos/bindings/jswrapper/v8/Utils.cpp + cocos/bindings/jswrapper/v8/Utils.h + cocos/bindings/jswrapper/v8/MissingSymbols.cpp + cocos/bindings/jswrapper/v8/MissingSymbols.h + ) + if(USE_V8_DEBUGGER) + cocos_source_files(MODULE ccbindings + cocos/bindings/jswrapper/v8/debugger/base64.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/env.cpp + cocos/bindings/jswrapper/v8/debugger/env.h + NO_WERROR NO_UBUILD cocos/bindings/jswrapper/v8/debugger/http_parser.cpp + cocos/bindings/jswrapper/v8/debugger/http_parser.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/inspector_agent.cpp + cocos/bindings/jswrapper/v8/debugger/inspector_agent.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/inspector_io.cpp + cocos/bindings/jswrapper/v8/debugger/inspector_io.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/inspector_socket.cpp + cocos/bindings/jswrapper/v8/debugger/inspector_socket.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/inspector_socket_server.cpp + cocos/bindings/jswrapper/v8/debugger/inspector_socket_server.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/node.cpp + cocos/bindings/jswrapper/v8/debugger/node.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/node_debug_options.cpp + cocos/bindings/jswrapper/v8/debugger/node_debug_options.h + cocos/bindings/jswrapper/v8/debugger/node_mutex.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/SHA1.cpp + cocos/bindings/jswrapper/v8/debugger/SHA1.h + cocos/bindings/jswrapper/v8/debugger/util-inl.h + NO_WERROR cocos/bindings/jswrapper/v8/debugger/util.cpp + cocos/bindings/jswrapper/v8/debugger/util.h + cocos/bindings/jswrapper/v8/debugger/v8_inspector_protocol_json.h + ) + endif() +endif() + +if(USE_SE_SM) + cocos_source_files(MODULE ccbindings + cocos/bindings/jswrapper/sm/Base.h + NO_WERROR cocos/bindings/jswrapper/sm/Class.cpp + cocos/bindings/jswrapper/sm/Class.h + cocos/bindings/jswrapper/sm/HelperMacros.h + NO_WERROR cocos/bindings/jswrapper/sm/HelperMacros.cpp + NO_WERROR cocos/bindings/jswrapper/sm/Object.cpp + cocos/bindings/jswrapper/sm/Object.h + NO_WERROR cocos/bindings/jswrapper/sm/ScriptEngine.cpp + cocos/bindings/jswrapper/sm/ScriptEngine.h + cocos/bindings/jswrapper/sm/SeApi.h + NO_WERROR cocos/bindings/jswrapper/sm/Utils.cpp + cocos/bindings/jswrapper/sm/Utils.h + ) +endif() + +cocos_source_files(MODULE ccbindings + cocos/bindings/jswrapper/config.h + cocos/bindings/jswrapper/config.cpp + cocos/bindings/jswrapper/HandleObject.cpp + cocos/bindings/jswrapper/HandleObject.h + cocos/bindings/jswrapper/MappingUtils.cpp + cocos/bindings/jswrapper/MappingUtils.h + cocos/bindings/jswrapper/Object.h + cocos/bindings/jswrapper/RefCounter.cpp + cocos/bindings/jswrapper/RefCounter.h + cocos/bindings/jswrapper/SeApi.h + cocos/bindings/jswrapper/State.cpp + cocos/bindings/jswrapper/State.h + cocos/bindings/jswrapper/PrivateObject.h + cocos/bindings/jswrapper/Value.cpp + cocos/bindings/jswrapper/Value.h + cocos/bindings/jswrapper/ValueArrayPool.cpp + cocos/bindings/jswrapper/ValueArrayPool.h +) + +cocos_source_files( + cocos/bindings/manual/jsb_global_init.cpp + cocos/bindings/manual/jsb_global_init.h +) + +cocos_source_files( + cocos/bindings/event/CustomEventTypes.h + cocos/bindings/event/EventDispatcher.cpp + cocos/bindings/event/EventDispatcher.h +) + +#### storage +if(NOT ANDROID) + cocos_source_files( + cocos/storage/local-storage/LocalStorage.cpp + cocos/storage/local-storage/LocalStorage.h + ) +else() + cocos_source_files( + cocos/storage/local-storage/LocalStorage-android.cpp + ) +endif() + +#### ui +if(USE_EDIT_BOX) + cocos_source_files( + cocos/ui/edit-box/EditBox.h + ) +endif() + +if(ANDROID OR IOS OR OHOS) + if(USE_VIDEO) + cocos_source_files( + cocos/ui/videoplayer/VideoPlayer.h + ) + endif() + if(USE_WEBVIEW) + cocos_source_files( + cocos/ui/webview/WebView-inl.h + cocos/ui/webview/WebView.h + ) + endif() +endif() + +if(ANDROID) + if(USE_EDIT_BOX) + cocos_source_files( + cocos/ui/edit-box/EditBox-android.cpp + ) + endif() + if(USE_VIDEO) + cocos_source_files( + cocos/ui/videoplayer/VideoPlayer-java.cpp + ) + endif() + if(USE_WEBVIEW) + cocos_source_files( + cocos/ui/webview/WebViewImpl-java.h + cocos/ui/webview/WebViewImpl-android.cpp + ) + endif() +elseif(OHOS) + if(USE_EDIT_BOX) + cocos_source_files( + cocos/ui/edit-box/EditBox-ohos.cpp + ) + endif() + if(USE_VIDEO) + cocos_source_files( + cocos/ui/videoplayer/VideoPlayer-java.cpp + ) + endif() + if(USE_WEBVIEW) + cocos_source_files( + cocos/ui/webview/WebViewImpl-java.h + cocos/ui/webview/WebViewImpl-ohos.cpp + ) + endif() +elseif(MACOSX) + if(USE_EDIT_BOX) + cocos_source_files( + cocos/ui/edit-box/EditBox-mac.mm + ) + endif() +elseif(IOS) + if(USE_EDIT_BOX) + cocos_source_files( + NO_WERROR NO_UBUILD cocos/ui/edit-box/EditBox-ios.mm + ) + endif() + if(USE_VIDEO) + cocos_source_files( + cocos/ui/videoplayer/VideoPlayer-ios.mm + ) + endif() + if(USE_WEBVIEW) + cocos_source_files( + cocos/ui/webview/WebViewImpl-ios.h + NO_WERROR NO_UBUILD cocos/ui/webview/WebViewImpl-ios.mm + + ) + endif() +elseif(WIN32) + if(USE_EDIT_BOX) + cocos_source_files( + NO_WERROR cocos/ui/edit-box/EditBox-win32.cpp + ) + endif() +elseif(LINUX OR QNX) + if(USE_EDIT_BOX) + cocos_source_files( + NO_WERROR cocos/ui/edit-box/EditBox-linux.cpp + ) + endif() +endif() + +##### extensions + +cocos_source_files( + extensions/assets-manager/AssetsManagerEx.cpp + extensions/assets-manager/AssetsManagerEx.h + extensions/assets-manager/AsyncTaskPool.cpp + extensions/assets-manager/AsyncTaskPool.h + extensions/assets-manager/EventAssetsManagerEx.cpp + extensions/assets-manager/EventAssetsManagerEx.h + extensions/assets-manager/Manifest.cpp + extensions/assets-manager/Manifest.h + extensions/cocos-ext.h + extensions/ExtensionExport.h + extensions/ExtensionMacros.h +) + +list(APPEND COCOS_SOURCE_LIST ${CC_EXTERNAL_SOURCES}) + +### generate source files + +set(CC_GENERATED_FILES + ${CWD}/cocos/core/builtin/DebugInfos.cpp +) + +add_custom_target(builtin-res + COMMAND ${CMAKE_COMMAND} -E echo "Generate builtin resources ..." + COMMAND ${NODE_EXECUTABLE} ${CWD}/cmake/scripts/gen_debugInfos.js + ${CWD}/../EngineErrorMap.md + ${CWD}/cocos/core/builtin/DebugInfos.cpp.in + ${CWD}/cocos/core/builtin/DebugInfos.cpp + DEPENDS + ${CWD}/cocos/core/builtin/DebugInfos.cpp.in + VERBATIM USES_TERMINAL +) +set_target_properties(builtin-res PROPERTIES FOLDER Utils) + + +list(APPEND COCOS_SOURCE_LIST ${CC_GENERATED_FILES}) + +if(USE_MODULES) + add_library(ccmath ${ccmath_SOURCE_LIST}) + add_library(cclog ${cclog_SOURCE_LIST}) + add_library(ccfilesystem ${ccfilesystem_SOURCE_LIST} ${CC_TINYDIR_SOURCES}) + add_library(ccutils ${ccutils_SOURCE_LIST} ${CC_UTILS_SOURCES}) + add_library(ccunzip ${ccunzip_SOURCE_LIST} ${CC_UNZIP_SOURCES}) + add_library(ccbindings ${ccbindings_SOURCE_LIST}) + add_library(ccgeometry ${ccgeometry_SOURCE_LIST}) + + target_include_directories(ccmath PRIVATE + ${CWD}/cocos + ) + target_include_directories(ccgeometry PRIVATE + ${CWD}/cocos + ) + target_include_directories(ccunzip PRIVATE + ${CWD}/external/sources/unzip + ${CWD}/external/sources + ${CWD}/cocos + ) + target_include_directories(cclog PRIVATE + ${CWD}/cocos + ) + target_include_directories(ccfilesystem PRIVATE + ${CWD} + ${CWD}/cocos + ${CWD}/external/sources + ) + target_include_directories(ccutils PRIVATE + ${CWD}/cocos + ${CWD}/external/sources + ) + target_include_directories(ccbindings PRIVATE + ${CWD}/cocos + ${CWD}/cocos/bindings/jswrapper + ${CWD}/cocos/editor-support # TODO: refactor include path + ${CWD} + ${CC_EXTERNAL_INCLUDES} + ) + target_link_libraries(ccunzip PUBLIC + ${ZLIB} + ) + target_link_libraries(ccfilesystem PUBLIC + ccunzip + ccutils + cclog + ) + target_link_libraries(ccbindings PUBLIC + ccfilesystem + cclog + ${se_libs_name} + uv + ) + target_link_libraries(ccgeometry PUBLIC + ccmath + ) + if(ANDROID) + target_link_libraries(ccmath PUBLIC + android_platform + ) + target_link_libraries(cclog PUBLIC + log + ) + target_link_libraries(ccfilesystem PUBLIC + cocos_jni + ) + elseif(OHOS) + target_link_libraries(cclog PUBLIC + hilog_ndk.z + ) + target_link_libraries(ccfilesystem PUBLIC + cocos_jni + rawfile.z + ) + elseif(APPLE) + target_link_libraries(ccfilesystem PUBLIC + "-framework Foundation" + "-framework SystemConfiguration" + ) + endif() +else() + list(APPEND COCOS_SOURCE_LIST + ${ccmath_SOURCE_LIST} + ${ccgeometry_SOURCE_LIST} + ${cclog_SOURCE_LIST} + ${ccfilesystem_SOURCE_LIST} + ${ccunzip_SOURCE_LIST} + ${ccbindings_SOURCE_LIST} + ${ccutils_SOURCE_LIST} + ${CC_UNZIP_SOURCES} + ${CC_TINYDIR_SOURCES} + ) +endif() + + +if(QNX) + include(${QNX_PATH}/source.cmake) + qnx_source_list(ccqnx_SOURCE_LIST ${QNX_PATH}) + source_group(TREE ${QNX_PATH} PREFIX "Source Files" FILES ${ccqnx_SOURCE_LIST}}) + list(APPEND COCOS_SOURCE_LIST ${ccqnx_SOURCE_LIST}) +endif() + +if(DEFINED COCOS_SOURCE_PLUGIN_EXCULDE) + list(REMOVE_ITEM COCOS_SOURCE_LIST ${COCOS_SOURCE_PLUGIN_EXCULDE}) +endif() + +if(DEFINED COCOS_SOURCE_PLUGIN_LIST) + list(APPEND COCOS_SOURCE_LIST ${COCOS_SOURCE_PLUGIN_LIST}) +endif() + +add_library(${ENGINE_NAME} ${COCOS_SOURCE_LIST}) + +if(USE_MODULES) + target_link_libraries(${ENGINE_NAME} PUBLIC + ccmath + cclog + ccfilesystem + ccunzip + ccbindings + ccutils + ) +endif() + + +if(ANDROID OR OHOS) + cc_enable_werror("${CC_JNI_SRC_FILES}") + add_library(cocos_jni STATIC ${CC_JNI_SRC_FILES}) + target_include_directories(cocos_jni PUBLIC + ${CWD} + ${CWD}/cocos + ${CC_EXTERNAL_INCLUDES} + ) + if(ANDROID) + target_link_libraries(cocos_jni PUBLIC + android_platform + android + log + ) + # Export GameActivity_onCreate(), + # Refer to: https://github.com/android-ndk/ndk/issues/381. + set(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} -u GameActivity_onCreate") + endif() +endif() + +################################# cc_apply_definations ################################### +function(cc_apply_definations target) + target_compile_definitions(${target} PUBLIC + $,CC_USE_VIDEO=1,CC_USE_VIDEO=0> + $,CC_USE_WEBVIEW=1,CC_USE_WEBVIEW=0> + $,CC_USE_AUDIO=1,CC_USE_AUDIO=0> + $,CC_USE_XR=1,CC_USE_XR=0> + $,CC_USE_SOCKET=1,CC_USE_SOCKET=0> + $,CC_USE_WEBSOCKET_SERVER=1,CC_USE_WEBSOCKET_SERVER=0> + $,CC_USE_EDITBOX=1,CC_USE_EDITBOX=0> + # USE_V8_DEBUGGER = USE_V8_DEBUGGER && (in_debug_mode OR USE_V8_DEBUGGER_FORCEON) + $,$>,$>,USE_V8_DEBUGGER=1,USE_V8_DEBUGGER=0> + $,CC_USE_MIDDLEWARE=1,CC_USE_MIDDLEWARE=0> + $,CC_USE_SPINE=1,CC_USE_SPINE=0> + $,CC_USE_DRAGONBONES=1,CC_USE_DRAGONBONES=0> + $,CC_USE_JOB_SYSTEM_TBB=1,CC_USE_JOB_SYSTEM_TBB=0> + $,CC_USE_JOB_SYSTEM_TASKFLOW=1,CC_USE_JOB_SYSTEM_TASKFLOW=0> + $,CC_USE_PHYSICS_PHYSX=1,CC_USE_PHYSICS_PHYSX=0> + $,CC_USE_OCCLUSION_QUERY=1,CC_USE_OCCLUSION_QUERY=0> + $,CC_USE_DEBUG_RENDERER=1,CC_USE_DEBUG_RENDERER=0> + $,CC_USE_GEOMETRY_RENDERER=1,CC_USE_GEOMETRY_RENDERER=0> + $,CC_USE_WEBP=1,CC_USE_WEBP=0> + $,CC_EDITOR=1,CC_EDITOR=0> + $<$:CC_REMOTE_LOG=1> + $<$:SCRIPT_ENGINE_TYPE=1> + $<$,$>:CC_DEBUG=1> + ) +endfunction() + +# setup default flags +cc_apply_definations(${ENGINE_NAME}) + +if(USE_MODULES) + cc_apply_definations(ccmath) + cc_apply_definations(cclog) + cc_apply_definations(ccfilesystem) + cc_apply_definations(ccunzip) + cc_apply_definations(ccbindings) + cc_apply_definations(ccutils) +endif() + +if(USE_XR) + cc_xr_apply_definations(${ENGINE_NAME}) + if(USE_MODULES) + cc_xr_apply_definations(ccmath) + cc_xr_apply_definations(cclog) + cc_xr_apply_definations(ccfilesystem) + cc_xr_apply_definations(ccunzip) + cc_xr_apply_definations(ccbindings) + cc_xr_apply_definations(ccutils) + endif() +endif() + +if(MSVC) + set(V8_DIR + ${CWD}/external/win64/libs/v8 + ) + file(GLOB V8_DLLS + ${CWD}/external/win64/libs/v8/Release/*.dll + ) + + file(GLOB WINDOWS_DLLS + ${CWD}/external/win64/libs/*.dll + ${CWD}/external/win64/libs/msvcr/*.dll + ) + target_compile_options(${ENGINE_NAME} PUBLIC /MP + /bigobj + /wd4018 # signed/unsigned mismatch + /wd4244 # type conversion data lost + /wd4267 # conversion from 'size_t' to 'type', possible loss of data + /wd4305 # truncation from 'type1' to 'type2' + /wd4309 # truncation of constant value + /wd4819 # file contains a character that cannot be represented in the current code page + /wd4996 # deprecated + ) +endif() + +if(CC_USE_VULKAN) + + target_compile_definitions(${ENGINE_NAME} PUBLIC VK_NO_PROTOTYPES) + target_compile_definitions(${ENGINE_NAME} PUBLIC CC_USE_VULKAN) + + if(WIN32) + target_compile_definitions(${ENGINE_NAME} PUBLIC VK_USE_PLATFORM_WIN32_KHR) + elseif(NX) + target_compile_definitions(${ENGINE_NAME} PUBLIC VK_USE_PLATFORM_VI_NN) + elseif(ANDROID) + target_compile_definitions(${ENGINE_NAME} PUBLIC VK_USE_PLATFORM_ANDROID_KHR) + elseif(IOS) + target_compile_definitions(${ENGINE_NAME} PUBLIC VK_USE_PLATFORM_IOS_MVK) + elseif(MACOSX) + target_compile_definitions(${ENGINE_NAME} PUBLIC VK_USE_PLATFORM_MACOS_MVK) + else() + target_compile_definitions(${ENGINE_NAME} PUBLIC VK_USE_PLATFORM_XCB_KHR) + endif() +endif() + +if(CC_USE_METAL) + target_compile_definitions(${ENGINE_NAME} PUBLIC CC_USE_METAL) +endif() + +if(CC_USE_GLES3) + target_compile_definitions(${ENGINE_NAME} PUBLIC CC_USE_GLES3) +endif() + +if(CC_USE_GLES2) + target_compile_definitions(${ENGINE_NAME} PUBLIC CC_USE_GLES2) +endif() + +set(COCOS_SOURCE_INCLUDES) +if(DEFINED COCOS_SOURCE_PLUGIN_INCLUDES) + list(APPEND COCOS_SOURCE_INCLUDES ${COCOS_SOURCE_PLUGIN_INCLUDES}) +endif() + +target_include_directories(${ENGINE_NAME} + PUBLIC + ${COCOS_SOURCE_INCLUDES} + ${CC_EXTERNAL_INCLUDES} + ${CWD} + ${CWD}/cocos + ${CWD}/cocos/renderer + ${CWD}/cocos/platform + ${CWD}/cocos/renderer/core + ${CWD}/cocos/editor-support + $<$:${CWD}/cocos/bindings/jswrapper> + PRIVATE + ${CC_EXTERNAL_PRIVATE_INCLUDES} +) + +target_compile_definitions(${ENGINE_NAME} + PRIVATE + ${CC_EXTERNAL_PRIVATE_DEFINITIONS} +) + +if(NOT APPLE) + target_include_directories(${ENGINE_NAME} PUBLIC + ${CWD}/external/sources/EGL + ) +endif() + +target_include_directories(${ENGINE_NAME} PUBLIC + ${CWD}/external/sources/khronos +) + +if(NX) + include(${CMAKE_CURRENT_LIST_DIR}/platform-nx/setup.cmake) +elseif(WINDOWS) + target_link_libraries(${ENGINE_NAME} PUBLIC + ws2_32 userenv psapi winmm Iphlpapi + ${CC_EXTERNAL_LIBS} + ) + cc_win32_definations(${ENGINE_NAME}) + + if(USE_MODULES) + cc_win32_definations(ccmath) + cc_win32_definations(cclog) + cc_win32_definations(ccunzip) + cc_win32_definations(ccfilesystem) + cc_win32_definations(ccutils) + cc_win32_definations(ccbindings) + + target_link_libraries(ccutils PUBLIC + ws2_32 psapi userenv Iphlpapi + ) + target_link_libraries(ccbindings PUBLIC + ws2_32 + ) + endif() +endif() + +if(ANDROID) + target_compile_options(${ENGINE_NAME} PRIVATE + -Wno-comment # nested block comments are actually useful sometimes + ) + + find_library(LIB_EGL NAMES EGL) + target_link_libraries(${ENGINE_NAME} PUBLIC + android + paddleboat_static + OpenSLES + ${LIB_EGL} + jnigraphics + ${CC_EXTERNAL_LIBS} + ) +endif() + +if(OHOS) + target_link_libraries(${ENGINE_NAME} PUBLIC + EGL + GLESv3 + zgraphic.z + image_pixelmap.z + rawfile.z + z + OpenSLES + hilog_ndk.z + ${CC_EXTERNAL_LIBS} + ) +endif() + +if(APPLE) + + target_compile_options(${ENGINE_NAME} PRIVATE + -Wno-objc-method-access + ) + + target_include_directories(${ENGINE_NAME} PUBLIC + ${CWD}/cocos/platform/ios + ) + target_link_libraries(${ENGINE_NAME} PUBLIC + "-liconv" + "-framework AudioToolbox" + "-framework Foundation" + "-framework OpenAL" + "-framework GameController" + "-framework Metal" + "-framework MetalKit" + "-framework QuartzCore" + "-framework MetalPerformanceShaders" + "-lsqlite3" + "-framework Security" + "-framework SystemConfiguration" + "$(inherited)" + ${CC_EXTERNAL_LIBS} + ) + set_target_properties(${ENGINE_NAME} PROPERTIES + XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "YES" + OSX_ARCHITECTURES "arm64;x86_64" + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/archives + ) + if(MACOSX) + target_link_libraries(${ENGINE_NAME} PUBLIC + "-framework OpenGL" + "-framework AppKit" + ) + target_compile_definitions(${ENGINE_NAME} PUBLIC + CC_KEYBOARD_SUPPORT + ) + elseif(IOS) + target_link_libraries(${ENGINE_NAME} PUBLIC + "-framework QuartzCore" + "-framework MetalPerformanceShaders" + "-framework UIKit" + "-framework AVKit" + "-framework WebKit" + "-framework CoreVideo" + "-framework CoreMotion" + "-framework CFNetwork" + "-framework CoreMedia" + "-framework CoreText" + "-framework CoreGraphics" + "-framework AVFoundation" + "-lz" + "-framework OpenGLES" + "-framework JavaScriptCore" + ) + set_property(TARGET ${ENGINE_NAME} PROPERTY XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${TARGET_IOS_VERSION}) + set_property(TARGET ${ENGINE_NAME} PROPERTY XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") + endif() + +endif() + +if(QNX) + include(${QNX_PATH}/setup.cmake) +elseif(LINUX) + set(LINUX_GRAPHIC_LIBS "") + if(NOT USE_SERVER_MODE) + list(APPEND LINUX_GRAPHIC_LIBS X11) + endif() + target_link_libraries(${ENGINE_NAME} PUBLIC + ${LINUX_GRAPHIC_LIBS} + ${CC_EXTERNAL_LIBS} + ) +endif() + +set(COCOS_SOURCE_PLUGIN_LIST_TEMP) +if(DEFINED COCOS_SOURCE_PLUGIN_LIST) + list(APPEND COCOS_SOURCE_PLUGIN_LIST_TEMP ${COCOS_SOURCE_PLUGIN_LIST}) +endif() + +if(USE_BUILTIN_EXTERNAL) + set(EXCLUDE_EXTERANL_LIST ${COCOS_SOURCE_LIST}) + foreach(x IN LISTS CC_EXTERNAL_SOURCES) + list(REMOVE_ITEM EXCLUDE_EXTERANL_LIST ${x}) + endforeach() + foreach(x IN LISTS COCOS_SOURCE_PLUGIN_LIST_TEMP) + list(REMOVE_ITEM EXCLUDE_EXTERANL_LIST ${x}) + endforeach() + source_group(TREE ${CWD} PREFIX "Source Files" FILES ${EXCLUDE_EXTERANL_LIST}) + source_group(TREE ${EXTERNAL_ROOT} PREFIX "Source Files/external" FILES ${CC_EXTERNAL_SOURCES}) + source_group("Plugin Files" FILES ${COCOS_SOURCE_PLUGIN_LIST_TEMP}) +else() + set(EXCLUDE_EXTERANL_LIST ${COCOS_SOURCE_LIST}) + foreach(x IN LISTS COCOS_SOURCE_PLUGIN_LIST_TEMP) + list(REMOVE_ITEM EXCLUDE_EXTERANL_LIST ${x}) + endforeach() + source_group(TREE ${CWD} PREFIX "Source Files" FILES ${EXCLUDE_EXTERANL_LIST}) + source_group("Plugin Files" FILES ${COCOS_SOURCE_PLUGIN_LIST_TEMP}) +endif() diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/Batcher2d.cpp b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/Batcher2d.cpp new file mode 100644 index 0000000..c757992 --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/Batcher2d.cpp @@ -0,0 +1,660 @@ +/**************************************************************************** + Copyright (c) 2019-2021 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + 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. +****************************************************************************/ + +#include "2d/renderer/Batcher2d.h" +#include "application/ApplicationManager.h" +#include "base/TypeDef.h" +#include "core/Root.h" +#include "editor-support/MiddlewareManager.h" +#include "renderer/pipeline/Define.h" +#include "scene/Pass.h" +#include + +namespace cc { + +Batcher2d::Batcher2d() : Batcher2d(nullptr) { + +} + +Batcher2d::Batcher2d(Root* root) +: _drawBatchPool([]() { return ccnew scene::DrawBatch2D(); }, [](auto* obj) { delete obj; }, 10U) { + if (root == nullptr) { + root = Root::getInstance(); + } + _root = root; + _device = _root->getDevice(); + _stencilManager = StencilManager::getInstance(); + + // LCC_UI_SORTING_GROUP + rendererCache.reserve(1024); + rendererOrder = false; +} + +Batcher2d::~Batcher2d() { // NOLINT + _drawBatchPool.destroy(); + + for (auto iter : _descriptorSetCache) { + delete iter.second; + } + + for (auto* drawBatch : _batches) { + delete drawBatch; + } + _attributes.clear(); + + if(_maskClearModel != nullptr) { + Root::getInstance()->destroyModel(_maskClearModel); + _maskClearModel = nullptr; + } + if (_maskModelMesh != nullptr) { + _maskModelMesh->destroy(); + _maskModelMesh = nullptr; + } + _maskClearMtl = nullptr; + _maskAttributes.clear(); + +} + +void Batcher2d::syncMeshBuffersToNative(uint16_t accId, ccstd::vector&& buffers) { + _meshBuffersMap[accId] = std::move(buffers); +} + +UIMeshBuffer* Batcher2d::getMeshBuffer(uint16_t accId, uint16_t bufferId) { // NOLINT(bugprone-easily-swappable-parameters) + const auto& map = _meshBuffersMap[accId]; + return map[bufferId]; +} + +gfx::Device* Batcher2d::getDevice() { + if (_device == nullptr) { + _device = Root::getInstance()->getDevice(); + } + return _device; +} + +void Batcher2d::updateDescriptorSet() { +} + +void Batcher2d::syncRootNodesToNative(ccstd::vector&& rootNodes) { + _rootNodeArr = std::move(rootNodes); +} + +void Batcher2d::fillBuffersAndMergeBatches() { + for (auto* rootNode : _rootNodeArr) { + walk(rootNode, 1, true, 0); + // CC_LOG_INFO("-------------- flushRendererCache 1 -------------- %d", _rootNodeArr.size()); + flushRendererCache(); // LCC_UI_SORTING_GROUP + generateBatch(_currEntity, _currDrawInfo); + } +} + +void Batcher2d::walk(Node* node, float parentOpacity, bool cacheEnable, float sortingPriority) { // NOLINT(misc-no-recursion) + if (!node->isActiveInHierarchy()) { + return; + } + sortingPriority = node->isUISortingEnabled() ? node->getUISortingPriority() : sortingPriority; + + bool breakWalk = false; + auto* entity = static_cast(node->getUserData()); + if (entity) { + if (entity->getColorDirty()) { + float localOpacity = entity->getLocalOpacity(); + float localColorAlpha = entity->getColorAlpha(); + entity->setOpacity(parentOpacity * localOpacity * localColorAlpha); + entity->setColorDirty(false); + entity->setVBColorDirty(true); + } + + // LCC_UI_SORTING_GROUP + if (entity->isEnabled()) { + if(entity->getIsMask() || !cacheEnable){ + // CC_LOG_INFO("-------------- flushRendererCache 2 --------------"); + flushRendererCache(); + uint32_t size = entity->getRenderDrawInfosSize(); + for (uint32_t i = 0; i < size; i++) { + auto* drawInfo = entity->getRenderDrawInfoAt(i); + handleDrawInfo(entity, drawInfo, node); + } + entity->setVBColorDirty(false); + }else{ + rendererCache.push_back(entity); + entity->setRenderPriority(sortingPriority); + if(sortingPriority != 0){ + rendererOrder = true; + } + } + } + + if (entity->getRenderEntityType() == RenderEntityType::CROSSED) { + breakWalk = true; + } + } + + if (!breakWalk) { + const auto& children = node->getChildren(); + float thisOpacity = entity ? entity->getOpacity() : parentOpacity; + for (const auto& child : children) { + // we should find parent opacity recursively upwards if it doesn't have an entity. + walk(child, thisOpacity, cacheEnable, sortingPriority); + } + } + + // post assembler + if (_stencilManager->getMaskStackSize() > 0 && entity && entity->isEnabled()) { + handlePostRender(entity); + } +} + +void Batcher2d::handlePostRender(RenderEntity* entity) { + bool isMask = entity->getIsMask(); + if (isMask) { + // CC_LOG_INFO("-------------- flushRendererCache 3 --------------"); + flushRendererCache(); // LCC_UI_SORTING_GROUP + + generateBatch(_currEntity, _currDrawInfo); + resetRenderStates(); + _stencilManager->exitMask(); + } +} +CC_FORCE_INLINE void Batcher2d::handleComponentDraw(RenderEntity* entity, RenderDrawInfo* drawInfo, Node* node) { + ccstd::hash_t dataHash = drawInfo->getDataHash(); + if (drawInfo->getIsMeshBuffer()) { + dataHash = 0; + } + + // may slow + bool isMask = entity->getIsMask(); + if (isMask) { + // Mask subComp + insertMaskBatch(entity); + } else { + entity->setEnumStencilStage(_stencilManager->getStencilStage()); + } + auto tempStage = static_cast(entity->getStencilStage()); + + if (_currHash != dataHash || dataHash == 0 || _currMaterial != drawInfo->getMaterial() || _currStencilStage != tempStage) { + // CC_LOG_INFO("handleComponentDraw break %u-%u %p-%p %d-%d", _currHash,dataHash, _currMaterial, drawInfo->getMaterial(), _currStencilStage, tempStage); + // Generate a batch if not batching + generateBatch(_currEntity, _currDrawInfo); + + if (!drawInfo->getIsMeshBuffer()) { + UIMeshBuffer* buffer = drawInfo->getMeshBuffer(); + if (_currMeshBuffer != buffer) { + _currMeshBuffer = buffer; + _indexStart = _currMeshBuffer->getIndexOffset(); + } + } + + _currHash = dataHash; + _currMaterial = drawInfo->getMaterial(); + _currStencilStage = tempStage; + _currLayer = entity->getNode()->getLayer(); + _currEntity = entity; + _currDrawInfo = drawInfo; + + _currTexture = drawInfo->getTexture(); + _currSampler = drawInfo->getSampler(); + if (_currSampler == nullptr) { + _currSamplerHash = 0; + } else { + _currSamplerHash = _currSampler->getHash(); + } + } + + if (!drawInfo->getIsMeshBuffer()) { + if (node->getChangedFlags() || drawInfo->getVertDirty()) { + fillVertexBuffers(entity, drawInfo); + drawInfo->setVertDirty(false); + } + if (entity->getVBColorDirty()) { + fillColors(entity, drawInfo); + } + + fillIndexBuffers(drawInfo); + } + + if (isMask) { + _stencilManager->enableMask(); + } +} + +CC_FORCE_INLINE void Batcher2d::handleModelDraw(RenderEntity* entity, RenderDrawInfo* drawInfo) { + generateBatch(_currEntity, _currDrawInfo); + resetRenderStates(); + + // stencil stage + gfx::DepthStencilState* depthStencil = nullptr; + ccstd::hash_t dssHash = 0; + Material* renderMat = drawInfo->getMaterial(); + + bool isMask = entity->getIsMask(); + if (isMask) { + //Mask Comp + insertMaskBatch(entity); + } else { + entity->setEnumStencilStage(_stencilManager->getStencilStage()); + } + + StencilStage entityStage = entity->getEnumStencilStage(); + depthStencil = _stencilManager->getDepthStencilState(entityStage, renderMat); + dssHash = _stencilManager->getStencilHash(entityStage); + + // Model + auto* model = drawInfo->getModel(); + if (model == nullptr) return; + auto stamp = CC_CURRENT_ENGINE()->getTotalFrames(); + model->updateTransform(stamp); + model->updateUBOs(stamp); + + const auto& subModelList = model->getSubModels(); + for (const auto& submodel : subModelList) { + auto* curdrawBatch = _drawBatchPool.alloc(); + curdrawBatch->setVisFlags(entity->getNode()->getLayer()); + curdrawBatch->setModel(model); + curdrawBatch->setInputAssembler(submodel->getInputAssembler()); + curdrawBatch->setDescriptorSet(submodel->getDescriptorSet()); + + curdrawBatch->fillPass(renderMat, depthStencil, dssHash, &(submodel->getPatches())); + _batches.push_back(curdrawBatch); + } + + if(isMask) { + _stencilManager->enableMask(); + } +} + +CC_FORCE_INLINE void Batcher2d::handleMiddlewareDraw(RenderEntity* entity, RenderDrawInfo* drawInfo) { + auto layer = entity->getNode()->getLayer(); + Material* material = drawInfo->getMaterial(); + auto* texture = drawInfo->getTexture(); + auto* sampler = drawInfo->getSampler(); + auto* meshBuffer = drawInfo->getMeshBuffer(); + + // check for merge draw + auto enableBatch = !entity->getUseLocal(); + if (enableBatch && _currTexture == texture && _currMeshBuffer == meshBuffer + && !_currEntity->getUseLocal() + && material->getHash() == _currMaterial->getHash() + && drawInfo->getIndexOffset() == _currDrawInfo->getIndexOffset() + _currDrawInfo->getIbCount() + && layer == _currLayer) { + auto ibCount = _currDrawInfo->getIbCount(); + _currDrawInfo->setIbCount(ibCount + drawInfo->getIbCount()); + } else { + generateBatch(_currEntity, _currDrawInfo); + _currLayer = layer; + _currMaterial = material; + _currTexture = texture; + _currMeshBuffer = meshBuffer; + _currEntity = entity; + _currDrawInfo = drawInfo; + _currHash = 0; + } +} + +CC_FORCE_INLINE void Batcher2d::handleSubNode(RenderEntity* entity, RenderDrawInfo* drawInfo) { // NOLINT + if (drawInfo->getSubNode()) { + walk(drawInfo->getSubNode(), entity->getOpacity(), false, 0); + } +} + +CC_FORCE_INLINE void Batcher2d::handleDrawInfo(RenderEntity* entity, RenderDrawInfo* drawInfo, Node* node) { //NOLINT(misc-no-recursion) + CC_ASSERT(entity); + CC_ASSERT(drawInfo); + RenderDrawInfoType drawInfoType = drawInfo->getEnumDrawInfoType(); + + switch (drawInfoType) { + case RenderDrawInfoType::COMP: + handleComponentDraw(entity, drawInfo, node); + break; + case RenderDrawInfoType::MODEL: + handleModelDraw(entity, drawInfo); + break; + case RenderDrawInfoType::MIDDLEWARE: + handleMiddlewareDraw(entity, drawInfo); + break; + case RenderDrawInfoType::SUB_NODE: + handleSubNode(entity, drawInfo); + break; + default: + break; + } +} + +void Batcher2d::generateBatch(RenderEntity* entity, RenderDrawInfo* drawInfo) { + if (drawInfo == nullptr) { + return; + } + if (drawInfo->getEnumDrawInfoType() == RenderDrawInfoType::MIDDLEWARE) { + generateBatchForMiddleware(entity, drawInfo); + return; + } + if (_currMaterial == nullptr) { + return; + } + gfx::InputAssembler* ia = nullptr; + if (drawInfo->getIsMeshBuffer()) { + // Todo MeshBuffer RenderData + ia = drawInfo->requestIA(getDevice()); + _meshRenderDrawInfo.emplace_back(drawInfo); + } else { + UIMeshBuffer* currMeshBuffer = drawInfo->getMeshBuffer(); + + currMeshBuffer->setDirty(true); + + ia = currMeshBuffer->requireFreeIA(getDevice()); + uint32_t indexCount = currMeshBuffer->getIndexOffset() - _indexStart; + if (ia == nullptr) { + return; + } + + ia->setFirstIndex(_indexStart); + ia->setIndexCount(indexCount); + _indexStart = currMeshBuffer->getIndexOffset(); + } + + _currMeshBuffer = nullptr; + + // stencilStage + gfx::DepthStencilState* depthStencil = nullptr; + ccstd::hash_t dssHash = 0; + StencilStage entityStage = entity->getEnumStencilStage(); + depthStencil = _stencilManager->getDepthStencilState(entityStage, _currMaterial); + dssHash = _stencilManager->getStencilHash(entityStage); + + auto* curdrawBatch = _drawBatchPool.alloc(); + curdrawBatch->setVisFlags(_currLayer); + curdrawBatch->setInputAssembler(ia); + curdrawBatch->fillPass(_currMaterial, depthStencil, dssHash); + const auto& pass = curdrawBatch->getPasses().at(0); + + if (entity->getUseLocal()) { + drawInfo->updateLocalDescriptorSet(entity->getRenderTransform(), pass->getLocalSetLayout()); + curdrawBatch->setDescriptorSet(drawInfo->getLocalDes()); + } else { + curdrawBatch->setDescriptorSet(getDescriptorSet(_currTexture, _currSampler, pass->getLocalSetLayout())); + } + _batches.push_back(curdrawBatch); +} + +void Batcher2d::generateBatchForMiddleware(RenderEntity* entity, RenderDrawInfo* drawInfo) { + auto layer = entity->getNode()->getLayer(); + auto* material = drawInfo->getMaterial(); + auto* texture = drawInfo->getTexture(); + auto* sampler = drawInfo->getSampler(); + auto* meshBuffer = drawInfo->getMeshBuffer(); + //set meshbuffer offset + auto indexOffset = drawInfo->getIndexOffset(); + auto indexCount = drawInfo->getIbCount(); + indexOffset += indexCount; + if (meshBuffer->getIndexOffset() < indexOffset) { + meshBuffer->setIndexOffset(indexOffset); + } + + meshBuffer->setDirty(true); + gfx::InputAssembler* ia = meshBuffer->requireFreeIA(getDevice()); + ia->setFirstIndex(drawInfo->getIndexOffset()); + ia->setIndexCount(drawInfo->getIbCount()); + + // stencilstage + auto stencilStage = _stencilManager->getStencilStage(); + gfx::DepthStencilState* depthStencil = _stencilManager->getDepthStencilState(stencilStage, material); + ccstd::hash_t dssHash = _stencilManager->getStencilHash(stencilStage); + + auto* curdrawBatch = _drawBatchPool.alloc(); + curdrawBatch->setVisFlags(_currLayer); + curdrawBatch->setInputAssembler(ia); + curdrawBatch->fillPass(material, depthStencil, dssHash); + const auto& pass = curdrawBatch->getPasses().at(0); + if (entity->getUseLocal()) { + drawInfo->updateLocalDescriptorSet(entity->getNode(), pass->getLocalSetLayout()); + curdrawBatch->setDescriptorSet(drawInfo->getLocalDes()); + } else { + curdrawBatch->setDescriptorSet(getDescriptorSet(texture, sampler, pass->getLocalSetLayout())); + } + _batches.push_back(curdrawBatch); + // make sure next generateBatch return. + resetRenderStates(); + _currMeshBuffer = nullptr; +} + +void Batcher2d::resetRenderStates() { + _currMaterial = nullptr; + _currTexture = nullptr; + _currSampler = nullptr; + _currSamplerHash = 0; + _currLayer = 0; + _currEntity = nullptr; + _currDrawInfo = nullptr; +} + +gfx::DescriptorSet* Batcher2d::getDescriptorSet(gfx::Texture* texture, gfx::Sampler* sampler, gfx::DescriptorSetLayout* dsLayout) { + ccstd::hash_t hash = 2; + size_t textureHash; + if (texture != nullptr) { + textureHash = boost::hash_value(texture); + ccstd::hash_combine(hash, textureHash); + } + if (sampler != nullptr) { + ccstd::hash_combine(hash, sampler->getHash()); + } + auto iter = _descriptorSetCache.find(hash); + if (iter != _descriptorSetCache.end()) { + if (texture != nullptr && sampler != nullptr) { + iter->second->bindTexture(static_cast(pipeline::ModelLocalBindings::SAMPLER_SPRITE), texture); + iter->second->bindSampler(static_cast(pipeline::ModelLocalBindings::SAMPLER_SPRITE), sampler); + } + iter->second->forceUpdate(); + return iter->second; + } + _dsInfo.layout = dsLayout; + auto* ds = getDevice()->createDescriptorSet(_dsInfo); + + if (texture != nullptr && sampler != nullptr) { + ds->bindTexture(static_cast(pipeline::ModelLocalBindings::SAMPLER_SPRITE), texture); + ds->bindSampler(static_cast(pipeline::ModelLocalBindings::SAMPLER_SPRITE), sampler); + } + ds->update(); + _descriptorSetCache.emplace(hash, ds); + + return ds; +} + +void Batcher2d::releaseDescriptorSetCache(gfx::Texture* texture, gfx::Sampler* sampler) { + ccstd::hash_t hash = 2; + size_t textureHash; + if (texture != nullptr) { + textureHash = boost::hash_value(texture); + ccstd::hash_combine(hash, textureHash); + } + if (sampler != nullptr) { + ccstd::hash_combine(hash, sampler->getHash()); + } + auto iter = _descriptorSetCache.find(hash); + if (iter != _descriptorSetCache.end()) { + delete iter->second; + _descriptorSetCache.erase(hash); + } +} + +bool Batcher2d::initialize() { + _isInit = true; + return _isInit; +} + +void Batcher2d::update() { + fillBuffersAndMergeBatches(); + resetRenderStates(); + + for (const auto& scene : Root::getInstance()->getScenes()) { + for (auto* batch : _batches) { + scene->addBatch(batch); + } + } +} + +void Batcher2d::uploadBuffers() { + if (_batches.empty()) { + return; + } + + for (auto& meshRenderData : _meshRenderDrawInfo) { + meshRenderData->uploadBuffers(); + } + + for (auto& map : _meshBuffersMap) { + for (auto& buffer : map.second) { + buffer->uploadBuffers(); + buffer->reset(); + } + } + updateDescriptorSet(); +} + +void Batcher2d::reset() { + for (auto& batch : _batches) { + batch->clear(); + _drawBatchPool.free(batch); + } + _batches.clear(); + + for (auto& meshRenderData : _meshRenderDrawInfo) { + meshRenderData->resetMeshIA(); + } + _meshRenderDrawInfo.clear(); + + // meshDataArray + for (auto& map : _meshBuffersMap) { + for (auto& buffer : map.second) { + if (buffer) { + buffer->resetIA(); + } + } + } + //meshBuffer cannot clear because it is not transported at every frame. + + _currMeshBuffer = nullptr; + _indexStart = 0; + _currHash = 0; + _currLayer = 0; + _currMaterial = nullptr; + _currTexture = nullptr; + _currSampler = nullptr; + + // stencilManager +} + +void Batcher2d::insertMaskBatch(RenderEntity* entity){ + generateBatch(_currEntity, _currDrawInfo); + resetRenderStates(); + createClearModel(); + _maskClearModel->setNode(entity->getNode()); + _maskClearModel->setTransform(entity->getNode()); + _stencilManager->pushMask(); + auto stage = _stencilManager->clear(entity); + + gfx::DepthStencilState* depthStencil = nullptr; + ccstd::hash_t dssHash = 0; + if(_maskClearMtl != nullptr){ + depthStencil = _stencilManager->getDepthStencilState(stage, _maskClearMtl); + dssHash = _stencilManager->getStencilHash(stage); + } + + // Model + if (_maskClearModel == nullptr) return; + auto stamp = CC_CURRENT_ENGINE()->getTotalFrames(); + _maskClearModel->updateTransform(stamp); + _maskClearModel->updateUBOs(stamp); + + const auto& subModelList = _maskClearModel->getSubModels(); + for (const auto& submodel : subModelList) { + auto* curdrawBatch = _drawBatchPool.alloc(); + curdrawBatch->setVisFlags(entity->getNode()->getLayer()); + curdrawBatch->setModel(_maskClearModel); + curdrawBatch->setInputAssembler(submodel->getInputAssembler()); + curdrawBatch->setDescriptorSet(submodel->getDescriptorSet()); + + curdrawBatch->fillPass(_maskClearMtl, depthStencil, dssHash, &(submodel->getPatches())); + _batches.push_back(curdrawBatch); + } + + _stencilManager->enterLevel(entity); +} + +void Batcher2d::createClearModel() { + if (_maskClearModel == nullptr) { + _maskClearMtl = BuiltinResMgr::getInstance()->get(ccstd::string("default-clear-stencil")); + + _maskClearModel = Root::getInstance()->createModel(); + uint32_t stride = 12;// vfmt + + auto* vertexBuffer = _device->createBuffer({ + gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + 4 * stride, + stride, + }); + const float vertices[] = {-1, -1, 0, 1, -1, 0, -1, 1, 0, 1, 1, 0}; + vertexBuffer->update(vertices); + auto* indexBuffer = _device->createBuffer({ + gfx::BufferUsageBit::INDEX | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + 6 * sizeof(uint16_t), + sizeof(uint16_t), + }); + const uint16_t indices[] = {0, 2, 1, 2, 1, 3}; + indexBuffer->update(indices); + + gfx::BufferList vbReference; + vbReference.emplace_back(vertexBuffer); + _maskModelMesh = ccnew RenderingSubMesh(vbReference, _maskAttributes, _primitiveMode, indexBuffer); + _maskModelMesh->setSubMeshIdx(0); + + _maskClearModel->initSubModel(0, _maskModelMesh, _maskClearMtl); + } +} + +// LCC_UI_SORTING_GROUP +void Batcher2d::flushRendererCache() { + if(rendererCache.size() > 0){ + if(rendererOrder){ + std::stable_sort(rendererCache.begin(), rendererCache.end(), [](RenderEntity* a, RenderEntity* b) { return a->getRenderPriority() < b->getRenderPriority(); }); + } + // CC_LOG_INFO("flushRendererCache %d", rendererCache.size()); + for(ccstd::vector::iterator it = rendererCache.begin(); it != rendererCache.end(); it++) + { + RenderEntity* entity = *it; + // CC_LOG_INFO("%f", entity->getRenderPriority()); + uint32_t size = entity->getRenderDrawInfosSize(); + for (uint32_t i = 0; i < size; i++) { + auto* drawInfo = entity->getRenderDrawInfoAt(i); + handleDrawInfo(entity, drawInfo, entity->getNode()); + } + entity->setVBColorDirty(false); + } + rendererCache.clear(); + } + rendererOrder = false; +} + +} // namespace cc diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/Batcher2d.h b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/Batcher2d.h new file mode 100644 index 0000000..3af2e0b --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/Batcher2d.h @@ -0,0 +1,208 @@ +/**************************************************************************** + Copyright (c) 2019-2021 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + 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. +****************************************************************************/ + +#pragma once +#include "2d/renderer/RenderDrawInfo.h" +#include "2d/renderer/RenderEntity.h" +#include "2d/renderer/UIMeshBuffer.h" +#include "base/Macros.h" +#include "base/Ptr.h" +#include "base/TypeDef.h" +#include "core/assets/Material.h" +#include "core/memop/Pool.h" +#include "renderer/gfx-base/GFXTexture.h" +#include "renderer/gfx-base/states/GFXSampler.h" +#include "scene/DrawBatch2D.h" + +namespace cc { +class Root; +using UIMeshBufferArray = ccstd::vector; +using UIMeshBufferMap = ccstd::unordered_map; + +class Batcher2d final { +public: + Batcher2d(); + explicit Batcher2d(Root* root); + ~Batcher2d(); + + void syncMeshBuffersToNative(uint16_t accId, ccstd::vector&& buffers); + + bool initialize(); + void update(); + void uploadBuffers(); + void reset(); + + void syncRootNodesToNative(ccstd::vector&& rootNodes); + void releaseDescriptorSetCache(gfx::Texture* texture, gfx::Sampler* sampler); + + UIMeshBuffer* getMeshBuffer(uint16_t accId, uint16_t bufferId); + gfx::Device* getDevice(); + inline ccstd::vector* getDefaultAttribute() { return &_attributes; } + + void updateDescriptorSet(); + + void fillBuffersAndMergeBatches(); + void walk(Node* node, float parentOpacity, bool cacheEnable, float sortingPriority); + void handlePostRender(RenderEntity* entity); + void handleDrawInfo(RenderEntity* entity, RenderDrawInfo* drawInfo, Node* node); + void handleComponentDraw(RenderEntity* entity, RenderDrawInfo* drawInfo, Node* node); + void handleModelDraw(RenderEntity* entity, RenderDrawInfo* drawInfo); + void handleMiddlewareDraw(RenderEntity* entity, RenderDrawInfo* drawInfo); + void handleSubNode(RenderEntity* entity, RenderDrawInfo* drawInfo); + void generateBatch(RenderEntity* entity, RenderDrawInfo* drawInfo); + void generateBatchForMiddleware(RenderEntity* entity, RenderDrawInfo* drawInfo); + void resetRenderStates(); + +private: + bool _isInit = false; + + inline void fillIndexBuffers(RenderDrawInfo* drawInfo) { // NOLINT(readability-convert-member-functions-to-static) + uint16_t* ib = drawInfo->getIDataBuffer(); + + UIMeshBuffer* buffer = drawInfo->getMeshBuffer(); + uint32_t indexOffset = buffer->getIndexOffset(); + + uint16_t* indexb = drawInfo->getIbBuffer(); + uint32_t indexCount = drawInfo->getIbCount(); + + memcpy(&ib[indexOffset], indexb, indexCount * sizeof(uint16_t)); + indexOffset += indexCount; + + buffer->setIndexOffset(indexOffset); + } + + inline void fillVertexBuffers(RenderEntity* entity, RenderDrawInfo* drawInfo) { // NOLINT(readability-convert-member-functions-to-static) + Node* node = entity->getNode(); + const Mat4& matrix = node->getWorldMatrix(); + uint8_t stride = drawInfo->getStride(); + uint32_t size = drawInfo->getVbCount() * stride; + float* vbBuffer = drawInfo->getVbBuffer(); + for (int i = 0; i < size; i += stride) { + Render2dLayout* curLayout = drawInfo->getRender2dLayout(i); + // make sure that the layout of Vec3 is three consecutive floats + static_assert(sizeof(Vec3) == 3 * sizeof(float)); + // cast to reduce value copy instructions + reinterpret_cast(vbBuffer + i)->transformMat4(curLayout->position, matrix); + } + } + + inline void setIndexRange(RenderDrawInfo* drawInfo) { // NOLINT(readability-convert-member-functions-to-static) + UIMeshBuffer* buffer = drawInfo->getMeshBuffer(); + uint32_t indexOffset = drawInfo->getIndexOffset(); + uint32_t indexCount = drawInfo->getIbCount(); + indexOffset += indexCount; + if (buffer->getIndexOffset() < indexOffset) { + buffer->setIndexOffset(indexOffset); + } + } + + inline void fillColors(RenderEntity* entity, RenderDrawInfo* drawInfo) { // NOLINT(readability-convert-member-functions-to-static) + Color temp = entity->getColor(); + + uint8_t stride = drawInfo->getStride(); + uint32_t size = drawInfo->getVbCount() * stride; + float* vbBuffer = drawInfo->getVbBuffer(); + + uint32_t offset = 0; + for (int i = 0; i < size; i += stride) { + offset = i + 5; + vbBuffer[offset++] = static_cast(temp.r) / 255.0F; + vbBuffer[offset++] = static_cast(temp.g) / 255.0F; + vbBuffer[offset++] = static_cast(temp.b) / 255.0F; + vbBuffer[offset++] = entity->getOpacity(); + } + } + + void insertMaskBatch(RenderEntity* entity); + void createClearModel (); + + // LCC_UI_SORTING_GROUP + ccstd::vector rendererCache; + bool rendererOrder; + void flushRendererCache(); + + gfx::DescriptorSet* getDescriptorSet(gfx::Texture* texture, gfx::Sampler* sampler, gfx::DescriptorSetLayout* dsLayout); + + StencilManager* _stencilManager{nullptr}; + + // weak reference + Root* _root{nullptr}; + // weak reference + ccstd::vector _rootNodeArr; + + // manage memory manually + ccstd::vector _batches; + memop::Pool _drawBatchPool; + + // weak reference + gfx::Device* _device{nullptr}; // use getDevice() + + // weak reference + RenderEntity* _currEntity{nullptr}; + // weak reference + RenderDrawInfo* _currDrawInfo{nullptr}; + // weak reference + UIMeshBuffer* _currMeshBuffer{nullptr}; + uint32_t _indexStart{0}; + ccstd::hash_t _currHash{0}; + uint32_t _currLayer{0}; + StencilStage _currStencilStage{StencilStage::DISABLED}; + + // weak reference + Material* _currMaterial{nullptr}; + // weak reference + gfx::Texture* _currTexture{nullptr}; + // weak reference + gfx::Sampler* _currSampler{nullptr}; + ccstd::hash_t _currSamplerHash{0}; + + // weak reference + ccstd::vector _meshRenderDrawInfo; + + // manage memory manually + ccstd::unordered_map _descriptorSetCache; + gfx::DescriptorSetInfo _dsInfo; + + UIMeshBufferMap _meshBuffersMap; + + // DefaultAttribute + ccstd::vector _attributes{ + gfx::Attribute{gfx::ATTR_NAME_POSITION, gfx::Format::RGB32F}, + gfx::Attribute{gfx::ATTR_NAME_TEX_COORD, gfx::Format::RG32F}, + gfx::Attribute{gfx::ATTR_NAME_COLOR, gfx::Format::RGBA32F}, + }; + + // Mask use + IntrusivePtr _maskClearModel; + IntrusivePtr _maskClearMtl; + IntrusivePtr _maskModelMesh; + ccstd::vector _maskAttributes{ + gfx::Attribute{gfx::ATTR_NAME_POSITION, gfx::Format::RGB32F}, + }; + gfx::PrimitiveMode _primitiveMode{gfx::PrimitiveMode::TRIANGLE_LIST}; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Batcher2d); +}; +} // namespace cc diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/RenderEntity.cpp b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/RenderEntity.cpp new file mode 100644 index 0000000..98a741b --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/RenderEntity.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** + Copyright (c) 2019-2021 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + 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. +****************************************************************************/ + +#include "2d/renderer/RenderEntity.h" +#include "2d/renderer/Batcher2d.h" +#include "bindings/utils/BindingUtils.h" + +namespace cc { +RenderEntity::RenderEntity(RenderEntityType type) : _renderEntityType(type) { + if (type == RenderEntityType::STATIC) { + ccnew_placement(&_staticDrawInfos) std::array(); + } else { + ccnew_placement(&_dynamicDrawInfos) ccstd::vector(); + } + _entitySharedBufferActor.initialize(&_entityAttrLayout, sizeof(EntityAttrLayout)); +} + +RenderEntity::~RenderEntity() { + if (_renderEntityType == RenderEntityType::STATIC) { + _staticDrawInfos.~array(); + } else { + _dynamicDrawInfos.~vector(); + } +}; + +void RenderEntity::addDynamicRenderDrawInfo(RenderDrawInfo* drawInfo) { + CC_ASSERT(_renderEntityType != RenderEntityType::STATIC); + _dynamicDrawInfos.push_back(drawInfo); +} +void RenderEntity::setDynamicRenderDrawInfo(RenderDrawInfo* drawInfo, uint32_t index) { + CC_ASSERT(_renderEntityType != RenderEntityType::STATIC); + if (index < _dynamicDrawInfos.size()) { + _dynamicDrawInfos[index] = drawInfo; + } +} +void RenderEntity::removeDynamicRenderDrawInfo() { + CC_ASSERT(_renderEntityType != RenderEntityType::STATIC); + if (_dynamicDrawInfos.empty()) return; + _dynamicDrawInfos.pop_back(); // warning: memory leaking & crash +} + +void RenderEntity::clearDynamicRenderDrawInfos() { + CC_ASSERT(_renderEntityType != RenderEntityType::STATIC); + _dynamicDrawInfos.clear(); +} + +void RenderEntity::clearStaticRenderDrawInfos() { + CC_ASSERT(_renderEntityType == RenderEntityType::STATIC); + + for (uint32_t i = 0; i < _staticDrawInfoSize; i++) { + RenderDrawInfo& drawInfo = _staticDrawInfos[i]; + drawInfo.resetDrawInfo(); + } + _staticDrawInfoSize = 0; +} + +void RenderEntity::setNode(Node* node) { + if (_node) { + _node->setUserData(nullptr); + } + _node = node; + if (_node) { + _node->setUserData(this); + } +} + +void RenderEntity::setRenderTransform(Node* renderTransform) { + _renderTransform = renderTransform; +} + +RenderDrawInfo* RenderEntity::getDynamicRenderDrawInfo(uint32_t index) { + CC_ASSERT(_renderEntityType != RenderEntityType::STATIC); + if (index >= _dynamicDrawInfos.size()) { + return nullptr; + } + return _dynamicDrawInfos[index]; +} +ccstd::vector& RenderEntity::getDynamicRenderDrawInfos() { + CC_ASSERT(_renderEntityType != RenderEntityType::STATIC); + return _dynamicDrawInfos; +} +void RenderEntity::setStaticDrawInfoSize(uint32_t size) { + CC_ASSERT(_renderEntityType == RenderEntityType::STATIC && size <= RenderEntity::STATIC_DRAW_INFO_CAPACITY); + _staticDrawInfoSize = size; +} +RenderDrawInfo* RenderEntity::getStaticRenderDrawInfo(uint32_t index) { + CC_ASSERT(_renderEntityType == RenderEntityType::STATIC && index < _staticDrawInfoSize); + return &(_staticDrawInfos[index]); +} +std::array& RenderEntity::getStaticRenderDrawInfos() { + CC_ASSERT(_renderEntityType == RenderEntityType::STATIC); + return _staticDrawInfos; +} +} // namespace cc diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/RenderEntity.h b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/RenderEntity.h new file mode 100644 index 0000000..05a5075 --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/2d/renderer/RenderEntity.h @@ -0,0 +1,164 @@ +/**************************************************************************** + Copyright (c) 2019-2021 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + 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. +****************************************************************************/ + +#pragma once +#include +#include "2d/renderer/RenderDrawInfo.h" +#include "2d/renderer/StencilManager.h" +#include "base/Macros.h" +#include "base/TypeDef.h" +#include "bindings/utils/BindingUtils.h" +#include "core/ArrayBuffer.h" +#include "core/scene-graph/Node.h" + +namespace cc { +class Batcher2d; + +enum class RenderEntityType : uint8_t { + STATIC, + DYNAMIC, + CROSSED, +}; + +enum class MaskMode : uint8_t { + NONE, + MASK, + MASK_INVERTED, + MASK_NODE, + MASK_NODE_INVERTED +}; + +struct EntityAttrLayout { + float localOpacity{1.0F}; + uint8_t colorR{255}; + uint8_t colorG{255}; + uint8_t colorB{255}; + uint8_t colorA{255}; + uint8_t maskMode{0}; + uint8_t colorDirtyBit{1}; + uint8_t enabledIndex{0}; + uint8_t useLocal{0}; +}; + +class RenderEntity final : public Node::UserData { +public: + static constexpr uint32_t STATIC_DRAW_INFO_CAPACITY = 4; + + explicit RenderEntity(RenderEntityType type); + ~RenderEntity() override; + + void addDynamicRenderDrawInfo(RenderDrawInfo* drawInfo); + void setDynamicRenderDrawInfo(RenderDrawInfo* drawInfo, uint32_t index); + void removeDynamicRenderDrawInfo(); + void clearDynamicRenderDrawInfos(); + void clearStaticRenderDrawInfos(); + + inline bool getIsMask() const { + return static_cast(_entityAttrLayout.maskMode) == MaskMode::MASK || static_cast(_entityAttrLayout.maskMode) == MaskMode::MASK_INVERTED; + } + + inline bool getIsSubMask() const { + return static_cast(_entityAttrLayout.maskMode) == MaskMode::MASK_NODE || static_cast(_entityAttrLayout.maskMode) == MaskMode::MASK_NODE_INVERTED; + } + + inline bool getIsMaskInverted() const { + return static_cast(_entityAttrLayout.maskMode) == MaskMode::MASK_INVERTED || static_cast(_entityAttrLayout.maskMode) == MaskMode::MASK_NODE_INVERTED; + } + + inline bool getUseLocal() const { return _entityAttrLayout.useLocal; } + inline void setUseLocal(bool useLocal) { + _entityAttrLayout.useLocal = useLocal; + } + + inline Node* getNode() const { return _node; } + void setNode(Node* node); + + inline Node* getRenderTransform() const { return _renderTransform; } + void setRenderTransform(Node* renderTransform); + + inline uint32_t getStencilStage() const { return static_cast(_stencilStage); } + inline void setStencilStage(uint32_t stage) { + _stencilStage = static_cast(stage); + } + inline StencilStage getEnumStencilStage() const { return _stencilStage; } + inline void setEnumStencilStage(StencilStage stage) { + _stencilStage = stage; + } + + inline RenderEntityType getRenderEntityType() const { return _renderEntityType; }; + + inline uint32_t getStaticDrawInfoSize() const { return _staticDrawInfoSize; }; + void setStaticDrawInfoSize(uint32_t size); + + RenderDrawInfo* getStaticRenderDrawInfo(uint32_t index); + std::array& getStaticRenderDrawInfos(); + RenderDrawInfo* getDynamicRenderDrawInfo(uint32_t index); + ccstd::vector& getDynamicRenderDrawInfos(); + + inline se::Object* getEntitySharedBufferForJS() const { return _entitySharedBufferActor.getSharedArrayBufferObject(); } + inline bool getColorDirty() const { return _entityAttrLayout.colorDirtyBit != 0; } + inline void setColorDirty(bool dirty) { _entityAttrLayout.colorDirtyBit = dirty ? 1 : 0; } + inline bool getVBColorDirty() const { return _vbColorDirty; } + inline void setVBColorDirty(bool vbColorDirty) { _vbColorDirty = vbColorDirty; } + inline Color getColor() const { return Color(_entityAttrLayout.colorR, _entityAttrLayout.colorG, _entityAttrLayout.colorB, _entityAttrLayout.colorA); } + inline float getColorAlpha() const { return static_cast(_entityAttrLayout.colorA) / 255.F; } + inline float getLocalOpacity() const { return _entityAttrLayout.localOpacity; } + inline float getOpacity() const { return _opacity; } + inline void setOpacity(float opacity) { _opacity = opacity; } + inline bool isEnabled() const { return _entityAttrLayout.enabledIndex != 0; } + inline uint32_t getRenderDrawInfosSize() const { + return _renderEntityType == RenderEntityType::STATIC ? _staticDrawInfoSize : static_cast(_dynamicDrawInfos.size()); + } + inline RenderDrawInfo* getRenderDrawInfoAt(uint32_t index) { + return _renderEntityType == RenderEntityType::STATIC ? &(_staticDrawInfos[index]) : _dynamicDrawInfos[index]; + } + + inline float getRenderPriority() const { return _renderPriority; } + inline void setRenderPriority(float value) { _renderPriority = value; } + +private: + CC_DISALLOW_COPY_MOVE_ASSIGN(RenderEntity); + // weak reference + Node* _node{nullptr}; + + // weak reference + Node* _renderTransform{nullptr}; + + EntityAttrLayout _entityAttrLayout; + float _opacity{1.0F}; + + bindings::NativeMemorySharedToScriptActor _entitySharedBufferActor; + union { + std::array _staticDrawInfos; + ccstd::vector _dynamicDrawInfos; + }; + StencilStage _stencilStage{StencilStage::DISABLED}; + RenderEntityType _renderEntityType{RenderEntityType::STATIC}; + uint8_t _staticDrawInfoSize{0}; + bool _vbColorDirty{true}; + + float _renderPriority{0.0F}; +}; +} // namespace cc diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/core/scene-graph/Node.cpp b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/core/scene-graph/Node.cpp new file mode 100644 index 0000000..6bf3afe --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/core/scene-graph/Node.cpp @@ -0,0 +1,984 @@ +/**************************************************************************** + Copyright (c) 2021 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + 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. + ****************************************************************************/ + +#include "core/scene-graph/Node.h" +#include "base/StringUtil.h" +#include "core/data/Object.h" +#include "core/memop/CachedArray.h" +#include "core/platform/Debug.h" +#include "core/scene-graph/NodeEnum.h" +#include "core/scene-graph/Scene.h" +#include "core/utils/IDGenerator.h" +#include "math/Utils.h" + +namespace cc { + +// static variables + +uint32_t Node::clearFrame{0}; +uint32_t Node::clearRound{1000}; +const uint32_t Node::TRANSFORM_ON{1 << 0}; +uint32_t Node::globalFlagChangeVersion{0}; + +namespace { +const ccstd::string EMPTY_NODE_NAME; +IDGenerator idGenerator("Node"); + +ccstd::vector dirtyNodes; +CC_FORCE_INLINE void setDirtyNode(const index_t idx, Node *node) { + if (idx >= dirtyNodes.size()) { + if (idx >= dirtyNodes.capacity()) { + size_t minCapacity = std::max((idx + 1) * 2, 32); + if (minCapacity > dirtyNodes.capacity()) { + dirtyNodes.reserve(minCapacity); // Make a pre-allocated size for dirtyNode vector for better grow performance. + } + } + dirtyNodes.resize(idx + 1, nullptr); + } + dirtyNodes[idx] = node; +} + +CC_FORCE_INLINE Node *getDirtyNode(const index_t idx) { + if (idx < 0 || idx >= dirtyNodes.size()) { + return nullptr; + } + return dirtyNodes[idx]; +} + +} // namespace + +Node::Node() : Node(EMPTY_NODE_NAME) { +} + +Node::Node(const ccstd::string &name) { +#define NODE_SHARED_MEMORY_BYTE_LENGTH (24) + static_assert(offsetof(Node, _uiSortingEnabled) + sizeof(_uiSortingEnabled) - offsetof(Node, _eventMask) == NODE_SHARED_MEMORY_BYTE_LENGTH, "Wrong shared memory size"); + _sharedMemoryActor.initialize(&_eventMask, NODE_SHARED_MEMORY_BYTE_LENGTH); +#undef NODE_SHARED_MEMORY_BYTE_LENGTH + + _id = idGenerator.getNewId(); + if (name.empty()) { + _name.append("New Node"); + } else { + _name = name; + } + _eventProcessor = ccnew NodeEventProcessor(this); +} + +Node::~Node() { + CC_SAFE_DELETE(_eventProcessor); + if (!_children.empty()) { + // Reset children's _parent to nullptr to avoid dangerous pointer + for (const auto &child : _children) { + child->_parent = nullptr; + } + } +} + +void Node::onBatchCreated(bool dontChildPrefab) { + // onBatchCreated was implemented in TS, so code should never go here. + CC_ASSERT(false); + emit(EventTypesToJS::NODE_ON_BATCH_CREATED, dontChildPrefab); +} + +Node *Node::instantiate(Node *cloned, bool isSyncedNode) { + if (!cloned) { + CC_ASSERT(false); + // TODO(): cloned = legacyCC.instantiate._clone(this, this); + return nullptr; + } + // TODO(): + // const newPrefabInfo = cloned._prefab; + // if (EDITOR && newPrefabInfo) { + // if (cloned == = newPrefabInfo.root) { + // // newPrefabInfo.fileId = ''; + // } else { + // // var PrefabUtils = Editor.require('scene://utils/prefab'); + // // PrefabUtils.unlinkPrefab(cloned); + // } + //} + // if (EDITOR && legacyCC.GAME_VIEW) { + // const syncing = newPrefabInfo&& cloned == = newPrefabInfo.root && newPrefabInfo.sync; + // if (!syncing) { + // cloned._name += ' (Clone)'; + // } + //} + cloned->_parent = nullptr; + cloned->onBatchCreated(isSyncedNode); + return cloned; +} + +void Node::onHierarchyChangedBase(Node *oldParent) { // NOLINT(misc-unused-parameters) + Node *newParent = _parent; + auto *scene = dynamic_cast(newParent); + if (isPersistNode() && scene == nullptr) { + emit(EventTypesToJS::NODE_REMOVE_PERSIST_ROOT_NODE); +#if CC_EDITOR + debug::warnID(1623); +#endif + } +#if CC_EDITOR + auto *curScene = getScene(); + const bool inCurrentSceneBefore = oldParent && oldParent->isChildOf(curScene); + const bool inCurrentSceneNow = newParent && newParent->isChildOf(curScene); + if (!inCurrentSceneBefore && inCurrentSceneNow) { + // attached + this->notifyEditorAttached(true); + } else if (inCurrentSceneBefore && !inCurrentSceneNow) { + // detached + this->notifyEditorAttached(false); + } + // conflict detection + // _Scene.DetectConflict.afterAddChild(this); +#endif + + bool shouldActiveNow = isActive() && !!(newParent && newParent->isActiveInHierarchy()); + if (isActiveInHierarchy() != shouldActiveNow) { + // Director::getInstance()->getNodeActivator()->activateNode(this, shouldActiveNow); // TODO(xwx): use TS temporarily + emit(EventTypesToJS::NODE_ACTIVE_NODE, shouldActiveNow); + } +} + +void Node::off(const CallbacksInvoker::KeyType &type, bool useCapture) { + _eventProcessor->offAll(type, useCapture); + bool hasListeners = _eventProcessor->hasEventListener(type); + if (!hasListeners) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask &= ~TRANSFORM_ON; + } + } +} + +void Node::off(const CallbacksInvoker::KeyType &type, const CallbackID &cbID, bool useCapture) { + _eventProcessor->off(type, cbID, useCapture); + bool hasListeners = _eventProcessor->hasEventListener(type); + if (!hasListeners) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask &= ~TRANSFORM_ON; + } + } +} + +void Node::off(const CallbacksInvoker::KeyType &type, void *target, bool useCapture) { + _eventProcessor->off(type, target, useCapture); + bool hasListeners = _eventProcessor->hasEventListener(type); + if (!hasListeners) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask &= ~TRANSFORM_ON; + } + } +} + +//void Node::dispatchEvent(event::Event *eve) { +// _eventProcessor->dispatchEvent(eve); +//} + +bool Node::hasEventListener(const CallbacksInvoker::KeyType &type) const { + return _eventProcessor->hasEventListener(type); +} + +bool Node::hasEventListener(const CallbacksInvoker::KeyType &type, const CallbackID &cbID) const { + return _eventProcessor->hasEventListener(type, cbID); +} +bool Node::hasEventListener(const CallbacksInvoker::KeyType &type, void *target) const { + return _eventProcessor->hasEventListener(type, target); +} +bool Node::hasEventListener(const CallbacksInvoker::KeyType &type, void *target, const CallbackID &cbID) const { + return _eventProcessor->hasEventListener(type, target, cbID); +} + +void Node::targetOff(const CallbacksInvoker::KeyType &type) { + _eventProcessor->targetOff(type); + if ((_eventMask & TRANSFORM_ON) && !_eventProcessor->hasEventListener(NodeEventType::TRANSFORM_CHANGED)) { + _eventMask &= ~TRANSFORM_ON; + } +} + +void Node::setActive(bool isActive) { + uint8_t isActiveU8 = isActive ? 1 : 0; + if (_active != isActiveU8) { + _active = isActiveU8; + Node *parent = _parent; + if (parent) { + bool couldActiveInScene = parent->isActiveInHierarchy(); + if (couldActiveInScene) { + // Director::getInstance()->getNodeActivator()->activateNode(this, isActive); // TODO(xwx): use TS temporarily + emit(EventTypesToJS::NODE_ACTIVE_NODE, isActive); + } + } + } +} + +void Node::setParent(Node *parent, bool isKeepWorld /* = false */) { + if (isKeepWorld) { + updateWorldTransform(); + } + + if (_parent == parent) { + return; + } + + Node *oldParent = _parent; + Node *newParent = parent; +#if CC_DEBUG > 0 + if (oldParent && (oldParent->_objFlags & Flags::DEACTIVATING) == Flags::DEACTIVATING) { + debug::errorID(3821); + } +#endif + _parent = newParent; + _siblingIndex = 0; + onSetParent(oldParent, isKeepWorld); + emit(NodeEventType::PARENT_CHANGED, oldParent); + if (oldParent) { + if (!(oldParent->_objFlags & Flags::DESTROYING)) { + index_t removeAt = getIdxOfChild(oldParent->_children, this); + // TODO(): DEV + /*if (DEV && removeAt < 0) { + errorID(1633); + return; + }*/ + if (removeAt < 0) { + return; + } + oldParent->_children.erase(oldParent->_children.begin() + removeAt); + oldParent->updateSiblingIndex(); + oldParent->emit(NodeEventType::CHILD_REMOVED, this); + } + } + if (newParent) { +#if CC_DEBUG > 0 + if ((newParent->_objFlags & Flags::DEACTIVATING) == Flags::DEACTIVATING) { + debug::errorID(3821); + } +#endif + newParent->_children.emplace_back(this); + _siblingIndex = static_cast(newParent->_children.size() - 1); + newParent->emit(NodeEventType::CHILD_ADDED, this); + } + onHierarchyChanged(oldParent); +} + +void Node::walk(const WalkCallback &preFunc) { + walk(preFunc, nullptr); +} + +void Node::walk(const WalkCallback &preFunc, const WalkCallback &postFunc) { //NOLINT(misc-no-recursion) + if (preFunc) { + preFunc(this); + } + + for (const auto &child : _children) { + if (child) { + child->walk(preFunc, postFunc); + } + } + + if (postFunc) { + postFunc(this); + } +} + +//Component *Node::addComponent(Component *comp) { +// comp->_node = this; // cjh TODO: shared_ptr +// _components.emplace_back(comp); +// +// if (isActiveInHierarchy()) { +// NodeActivator::activateComp(comp); +// } +// +// return comp; +//} +// +//void Node::removeComponent(Component *comp) { +// auto iteComp = std::find(_components.begin(), _components.end(), comp); +// if (iteComp != _components.end()) { +// _components.erase(iteComp); +// } +//} + +bool Node::onPreDestroyBase() { + Flags destroyingFlag = Flags::DESTROYING; + _objFlags |= destroyingFlag; + bool destroyByParent = (!!_parent) && (!!(_parent->_objFlags & destroyingFlag)); +#if CC_EDITOR + if (!destroyByParent) { + this->notifyEditorAttached(false); + } +#endif + if (isPersistNode()) { + emit(EventTypesToJS::NODE_REMOVE_PERSIST_ROOT_NODE); + } + if (!destroyByParent) { + if (_parent) { + emit(NodeEventType::PARENT_CHANGED, this); + index_t childIdx = getIdxOfChild(_parent->_children, this); + if (childIdx != -1) { + _parent->_children.erase(_parent->_children.begin() + childIdx); + } + _siblingIndex = 0; + _parent->updateSiblingIndex(); + _parent->emit(NodeEventType::CHILD_REMOVED, this); + } + } + + //NOTE: The following code is not needed now since we override Node._onPreDestroy in node.jsb.ts + // and the logic will be done in TS. + // emit(NodeEventType::NODE_DESTROYED, this); + // for (const auto &child : _children) { + // child->destroyImmediate(); + // } + // + // emit(EventTypesToJS::NODE_DESTROY_COMPONENTS); + + _eventProcessor->destroy(); + return destroyByParent; +} + +Node *Node::getChildByName(const ccstd::string &name) const { + if (name.empty()) { + CC_LOG_INFO("Invalid name"); + return nullptr; + } + for (const auto &child : _children) { + if (child->_name == name) { + return child; + } + } + return nullptr; +} + +void Node::setScene(Node *node) { + node->updateScene(); +} + +void Node::updateScene() { + if (_parent == nullptr) { + return; + } + _scene = _parent->_scene; + emit(EventTypesToJS::NODE_SCENE_UPDATED, _scene); +} + +/* static */ +index_t Node::getIdxOfChild(const ccstd::vector> &child, Node *target) { + auto iteChild = std::find(child.begin(), child.end(), target); + if (iteChild != child.end()) { + return static_cast(iteChild - child.begin()); + } + return CC_INVALID_INDEX; +} + +Node *Node::getChildByUuid(const ccstd::string &uuid) const { + if (uuid.empty()) { + CC_LOG_INFO("Invalid uuid"); + return nullptr; + } + for (const auto &child : _children) { + if (child->_id == uuid) { + return child; + } + } + return nullptr; +} + +bool Node::isChildOf(Node *parent) const { + const Node *child = this; + do { + if (child == parent) { + return true; + } + child = child->_parent; + } while (child); + return false; +} + +void Node::removeAllChildren() { + for (auto i = static_cast(_children.size() - 1); i >= 0; --i) { + if (_children[i]) { + _children[i]->setParent(nullptr); + } + } + _children.clear(); +} + +void Node::setSiblingIndex(index_t index) { + if (!_parent) { + return; + } + if (!!(_parent->_objFlags & Flags::DEACTIVATING)) { + debug::errorID(3821); + return; + } + ccstd::vector> &siblings = _parent->_children; + index = index != -1 ? index : static_cast(siblings.size()) - 1; + index_t oldIdx = getIdxOfChild(siblings, this); + if (index != oldIdx) { + if (oldIdx != CC_INVALID_INDEX) { + siblings.erase(siblings.begin() + oldIdx); + } + if (index < siblings.size()) { + siblings.insert(siblings.begin() + index, this); + } else { + siblings.emplace_back(this); + } + _parent->updateSiblingIndex(); + if (onSiblingIndexChanged != nullptr) { + onSiblingIndexChanged(index); + } + } +} + +Node *Node::getChildByPath(const ccstd::string &path) const { + size_t end = 0; + ccstd::vector segments = StringUtil::split(path, "/"); + auto *lastNode = const_cast(this); + for (const ccstd::string &segment : segments) { + if (segment.empty()) { + continue; + } + Node *next{nullptr}; + if (lastNode) { + for (const auto &child : lastNode->_children) { + if (child->_name == segment) { + next = child; + break; + } + } + lastNode = next; + } else { + break; + } + } + return lastNode; +} + +// +void Node::setPositionInternal(float x, float y, float z, bool calledFromJS) { + _localPosition.set(x, y, z); + invalidateChildren(TransformBit::POSITION); + + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::POSITION); + } + + if (!calledFromJS) { + notifyLocalPositionUpdated(); + } +} + +void Node::setRotationInternal(float x, float y, float z, float w, bool calledFromJS) { + _localRotation.set(x, y, z, w); + _eulerDirty = true; + + invalidateChildren(TransformBit::ROTATION); + + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::ROTATION); + } + + if (!calledFromJS) { + notifyLocalRotationUpdated(); + } +} + +void Node::setRotationFromEuler(float x, float y, float z) { + _euler.set(x, y, z); + Quaternion::fromEuler(x, y, z, &_localRotation); + _eulerDirty = false; + invalidateChildren(TransformBit::ROTATION); + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::ROTATION); + } + + notifyLocalRotationUpdated(); +} + +void Node::setScaleInternal(float x, float y, float z, bool calledFromJS) { + _localScale.set(x, y, z); + + invalidateChildren(TransformBit::SCALE); + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::SCALE); + } + + if (!calledFromJS) { + notifyLocalScaleUpdated(); + } +} + +void Node::updateWorldTransform() { //NOLINT(misc-no-recursion) + if (!getDirtyFlag()) { + return; + } + + index_t i = 0; + Node *curr = this; + Mat3 mat3; + Mat3 m43; + Quaternion quat; + while (curr && curr->getDirtyFlag()) { + setDirtyNode(i++, curr); + curr = curr->getParent(); + } + Node *child{nullptr}; + uint32_t dirtyBits = 0; + while (i) { + child = getDirtyNode(--i); + if (!child) { + continue; + } + dirtyBits |= child->getDirtyFlag(); + auto *currChild = child; + if (curr) { + if (dirtyBits & static_cast(TransformBit::POSITION)) { + currChild->_worldPosition.transformMat4(currChild->_localPosition, curr->_worldMatrix); + currChild->_worldMatrix.m[12] = currChild->_worldPosition.x; + currChild->_worldMatrix.m[13] = currChild->_worldPosition.y; + currChild->_worldMatrix.m[14] = currChild->_worldPosition.z; + } + if (dirtyBits & static_cast(TransformBit::RS)) { + Mat4::fromRTS(currChild->_localRotation, currChild->_localPosition, currChild->_localScale, &currChild->_worldMatrix); + Mat4::multiply(curr->_worldMatrix, currChild->_worldMatrix, &currChild->_worldMatrix); + if (dirtyBits & static_cast(TransformBit::ROTATION)) { + Quaternion::multiply(curr->_worldRotation, currChild->_localRotation, &currChild->_worldRotation); + } + quat = currChild->_worldRotation; + quat.conjugate(); + Mat3::fromQuat(quat, &mat3); + Mat3::fromMat4(currChild->_worldMatrix, &m43); + Mat3::multiply(mat3, m43, &mat3); + currChild->_worldScale.set(mat3.m[0], mat3.m[4], mat3.m[8]); + } + } else if (child) { + if (dirtyBits & static_cast(TransformBit::POSITION)) { + currChild->_worldPosition.set(currChild->_localPosition); + currChild->_worldMatrix.m[12] = currChild->_worldPosition.x; + currChild->_worldMatrix.m[13] = currChild->_worldPosition.y; + currChild->_worldMatrix.m[14] = currChild->_worldPosition.z; + } + if (dirtyBits & static_cast(TransformBit::RS)) { + if (dirtyBits & static_cast(TransformBit::ROTATION)) { + currChild->_worldRotation.set(currChild->_localRotation); + } + if (dirtyBits & static_cast(TransformBit::SCALE)) { + currChild->_worldScale.set(currChild->_localScale); + Mat4::fromRTS(currChild->_worldRotation, currChild->_worldPosition, currChild->_worldScale, &currChild->_worldMatrix); + } + } + } + child->setDirtyFlag(static_cast(TransformBit::NONE)); + curr = child; + } +} + +const Mat4 &Node::getWorldMatrix() const { //NOLINT(misc-no-recursion) + const_cast(this)->updateWorldTransform(); + return _worldMatrix; +} + +Mat4 Node::getWorldRS() { + updateWorldTransform(); + Mat4 target{_worldMatrix}; + target.m[12] = target.m[13] = target.m[14] = 0; + return target; +} + +Mat4 Node::getWorldRT() { + updateWorldTransform(); + Mat4 target; + Mat4::fromRT(_worldRotation, _worldPosition, &target); + return target; +} + +void Node::invalidateChildren(TransformBit dirtyBit) { + auto curDirtyBit{static_cast(dirtyBit)}; + const uint32_t childDirtyBit{curDirtyBit | static_cast(TransformBit::POSITION)}; + setDirtyNode(0, this); + int i{0}; + while (i >= 0) { + Node *cur = getDirtyNode(i--); + if (cur == nullptr) { + continue; + } + + const uint32_t hasChangedFlags = cur->getChangedFlags(); + if (cur->isValid() && (cur->getDirtyFlag() & hasChangedFlags & curDirtyBit) != curDirtyBit) { + cur->setDirtyFlag(cur->getDirtyFlag() | curDirtyBit); + cur->setChangedFlags(hasChangedFlags | curDirtyBit); + + for (Node *curChild : cur->getChildren()) { + setDirtyNode(++i, curChild); + } + } + curDirtyBit = childDirtyBit; + } +} + +void Node::setWorldPosition(float x, float y, float z) { + _worldPosition.set(x, y, z); + if (_parent) { + _parent->updateWorldTransform(); + Mat4 invertWMat{_parent->_worldMatrix}; + invertWMat.inverse(); + _localPosition.transformMat4(_worldPosition, invertWMat); + } else { + _localPosition.set(_worldPosition); + } + notifyLocalPositionUpdated(); + + invalidateChildren(TransformBit::POSITION); + + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::POSITION); + } +} + +const Vec3 &Node::getWorldPosition() const { + const_cast(this)->updateWorldTransform(); + return _worldPosition; +} + +void Node::setWorldRotation(float x, float y, float z, float w) { + _worldRotation.set(x, y, z, w); + if (_parent) { + _parent->updateWorldTransform(); + _localRotation.set(_parent->_worldRotation.getConjugated()); + _localRotation.multiply(_worldRotation); + } else { + _localRotation.set(_worldRotation); + } + + _eulerDirty = true; + + invalidateChildren(TransformBit::ROTATION); + + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::ROTATION); + } + + notifyLocalRotationUpdated(); +} + +const Quaternion &Node::getWorldRotation() const { //NOLINT(misc-no-recursion) + const_cast(this)->updateWorldTransform(); + return _worldRotation; +} + +void Node::setWorldScale(float x, float y, float z) { + _worldScale.set(x, y, z); + if (_parent != nullptr) { + _parent->updateWorldTransform(); + Mat3 mat3; + Mat3::fromQuat(_parent->_worldRotation.getConjugated(), &mat3); + Mat3 b; + Mat3::fromMat4(_parent->_worldMatrix, &b); + Mat3::multiply(mat3, b, &mat3); + Mat3 mat3Scaling; + mat3Scaling.m[0] = _worldScale.x; + mat3Scaling.m[4] = _worldScale.y; + mat3Scaling.m[8] = _worldScale.z; + + mat3.inverse(); + Mat3::multiply(mat3Scaling, mat3, &mat3); + _localScale.x = Vec3{mat3.m[0], mat3.m[1], mat3.m[2]}.length(); + _localScale.y = Vec3{mat3.m[3], mat3.m[4], mat3.m[5]}.length(); + _localScale.z = Vec3{mat3.m[6], mat3.m[7], mat3.m[8]}.length(); + } else { + _localScale = _worldScale; + } + + notifyLocalScaleUpdated(); + + invalidateChildren(TransformBit::SCALE); + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::SCALE); + } +} + +const Vec3 &Node::getWorldScale() const { + const_cast(this)->updateWorldTransform(); + return _worldScale; +} + +void Node::setForward(const Vec3 &dir) { + const float len = dir.length(); + Vec3 v3Temp = dir * (-1.F / len); + Quaternion qTemp{Quaternion::identity()}; + Quaternion::fromViewUp(v3Temp, &qTemp); + setWorldRotation(qTemp); +} + +void Node::setAngle(float val) { + _euler.set(0, 0, val); + Quaternion::createFromAngleZ(val, &_localRotation); + _eulerDirty = false; + invalidateChildren(TransformBit::ROTATION); + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::ROTATION); + } + + notifyLocalRotationUpdated(); +} + +void Node::onSetParent(Node *oldParent, bool keepWorldTransform) { + if (_parent) { + if ((oldParent == nullptr || oldParent->_scene != _parent->_scene) && _parent->_scene != nullptr) { + walk(setScene); + } + } + + if (keepWorldTransform) { + if (_parent) { + _parent->updateWorldTransform(); + if (mathutils::approx(_parent->_worldMatrix.determinant(), 0.F, mathutils::EPSILON)) { + CC_LOG_WARNING("14300"); + _dirtyFlag |= static_cast(TransformBit::TRS); + updateWorldTransform(); + } else { + Mat4 tmpMat4 = _parent->_worldMatrix.getInversed() * _worldMatrix; + Mat4::toRTS(tmpMat4, &_localRotation, &_localPosition, &_localScale); + } + } else { + _localPosition.set(_worldPosition); + _localRotation.set(_worldRotation); + _localScale.set(_worldScale); + } + + notifyLocalPositionRotationScaleUpdated(); + _eulerDirty = true; + } + invalidateChildren(TransformBit::TRS); +} + +void Node::rotate(const Quaternion &rot, NodeSpace ns /* = NodeSpace::LOCAL*/, bool calledFromJS /* = false*/) { + Quaternion qTempA{rot}; + qTempA.normalize(); + if (ns == NodeSpace::LOCAL) { + _localRotation *= qTempA; + } else if (ns == NodeSpace::WORLD) { + Quaternion qTempB{Quaternion::identity()}; + qTempB = qTempA * getWorldRotation(); + qTempA = _worldRotation; + qTempA.inverse(); + qTempB = qTempA * qTempB; + _localRotation = _localRotation * qTempB; + } + _eulerDirty = true; + invalidateChildren(TransformBit::ROTATION); + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::ROTATION); + } + + if (!calledFromJS) { + notifyLocalRotationUpdated(); + } +} + +void Node::lookAt(const Vec3 &pos, const Vec3 &up) { + Vec3 vTemp = getWorldPosition(); + Quaternion qTemp{Quaternion::identity()}; + vTemp -= pos; + vTemp.normalize(); + Quaternion::fromViewUp(vTemp, up, &qTemp); + setWorldRotation(qTemp); +} + +Vec3 Node::inverseTransformPoint(const Vec3 &p) { + Vec3 out; + out.set(p.x, p.y, p.z); + Node *cur{this}; + index_t i{0}; + while (cur != nullptr && cur->getParent()) { + setDirtyNode(i++, cur); + cur = cur->getParent(); + } + while (i >= 0) { + Vec3::transformInverseRTS(out, cur->getRotation(), cur->getPosition(), cur->getScale(), &out); + --i; + cur = getDirtyNode(i); + } + return out; +} + +void Node::setMatrix(const Mat4 &val) { + val.decompose(&_localScale, &_localRotation, &_localPosition); + notifyLocalPositionRotationScaleUpdated(); + + invalidateChildren(TransformBit::TRS); + _eulerDirty = true; + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::TRS); + } +} + +void Node::setWorldRotationFromEuler(float x, float y, float z) { + Quaternion::fromEuler(x, y, z, &_worldRotation); + if (_parent) { + _parent->updateWorldTransform(); + _localRotation = _parent->_worldRotation.getConjugated() * _worldRotation; + } else { + _localRotation = _worldRotation; + } + _eulerDirty = true; + + invalidateChildren(TransformBit::ROTATION); + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::ROTATION); + } + + notifyLocalRotationUpdated(); +} + +void Node::setRTSInternal(Quaternion *rot, Vec3 *pos, Vec3 *scale, bool calledFromJS) { + uint32_t dirtyBit = 0; + if (rot) { + dirtyBit |= static_cast(TransformBit::ROTATION); + _localRotation = *rot; + _eulerDirty = true; + } + if (pos) { + _localPosition = *pos; + dirtyBit |= static_cast(TransformBit::POSITION); + } + if (scale) { + _localScale = *scale; + dirtyBit |= static_cast(TransformBit::SCALE); + } + + if (!calledFromJS) { + notifyLocalPositionRotationScaleUpdated(); + } + + if (dirtyBit) { + invalidateChildren(static_cast(dirtyBit)); + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, dirtyBit); + } + } +} + +void Node::resetChangedFlags() { + globalFlagChangeVersion++; +} + +void Node::clearNodeArray() { + if (clearFrame < clearRound) { + clearFrame++; + } else { + clearFrame = 0; + dirtyNodes.clear(); + } +} + +ccstd::string Node::getPathInHierarchy() const { + ccstd::string result = getName(); + Node *curNode = getParent(); + while (curNode && curNode->getParent()) { + result.insert(0, "/").insert(0, curNode->getName()); + curNode = curNode->getParent(); + } + return result; +} + +void Node::translate(const Vec3 &trans, NodeSpace ns) { + Vec3 v3Temp{trans}; + if (ns == NodeSpace::LOCAL) { + v3Temp.transformQuat(_localRotation); + _localPosition.x += v3Temp.x; + _localPosition.y += v3Temp.y; + _localPosition.z += v3Temp.z; + } else if (ns == NodeSpace::WORLD) { + if (_parent) { + Quaternion qTemp = _parent->getWorldRotation(); + qTemp.inverse(); + v3Temp.transformQuat(qTemp); + Vec3 scale{_worldScale}; + _localPosition.x += v3Temp.x / scale.x; + _localPosition.y += v3Temp.y / scale.y; + _localPosition.z += v3Temp.z / scale.z; + } else { + _localPosition.x += trans.x; + _localPosition.y += trans.y; + _localPosition.z += trans.z; + } + } + + notifyLocalPositionUpdated(); + + invalidateChildren(TransformBit::POSITION); + if (_eventMask & TRANSFORM_ON) { + emit(NodeEventType::TRANSFORM_CHANGED, TransformBit::POSITION); + } +} + +bool Node::onPreDestroy() { + bool result = onPreDestroyBase(); + // TODO(Lenovo): bookOfChange free + return result; +} + +void Node::onHierarchyChanged(Node *oldParent) { + emit(EventTypesToJS::NODE_REATTACH); + _eventProcessor->reattach(); + onHierarchyChangedBase(oldParent); +} + +/* static */ +//Node *Node::find(const ccstd::string &path, Node *referenceNode /* = nullptr*/) { +// return cc::find(path, referenceNode); +//} + +// For deserialization +// void Node::_setChild(index_t i, Node *child) { +// if (i < _children.size()) { +// _children[i] = child; +// } else { +// CC_LOG_ERROR("Invalid index (%d) for Node children (size: %u)", i, static_cast(_children.size())); +// } +//} +// +// Node *Node::_getChild(index_t i) { +// if (i < _children.size()) { +// return _children[i]; +// } +// CC_LOG_ERROR("Invalid index (%d) for Node children (size: %u)", i, static_cast(_children.size())); +// return nullptr; +//} +// +// void Node::_setChildrenSize(uint32_t size) { +// _children.resize(size); +//} +// +// uint32_t Node::_getChildrenSize() { +// return _children.size(); +//} +// +void Node::_setChildren(ccstd::vector> &&children) { + _children = std::move(children); +} + +// + +} // namespace cc diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/core/scene-graph/Node.h b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/core/scene-graph/Node.h new file mode 100644 index 0000000..4f364ef --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/native/cocos/core/scene-graph/Node.h @@ -0,0 +1,861 @@ +/**************************************************************************** + Copyright (c) 2021 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + 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. + ****************************************************************************/ + +#pragma once + +#include "base/Ptr.h" +#include "base/std/any.h" +#include "bindings/utils/BindingUtils.h" +//#include "core/components/Component.h" +//#include "core/event/Event.h" +#include "core/event/EventTypesToJS.h" +#include "core/scene-graph/BaseNode.h" +#include "core/scene-graph/Layers.h" +#include "core/scene-graph/NodeEnum.h" +#include "core/scene-graph/NodeEvent.h" +#include "core/scene-graph/NodeEventProcessor.h" + +#include "math/Mat3.h" +#include "math/Mat4.h" +#include "math/Quaternion.h" +#include "math/Vec3.h" +#include "math/Vec4.h" + +namespace cc { + +class Scene; +class NodeEventProcessor; + +/** + * Event types emitted by Node + */ +using EventType = NodeEventType; +/** + * Bit masks for Node transformation parts + */ +using TransformDirtyBit = TransformBit; + +class Node : public BaseNode { +public: + class UserData : public RefCounted { + public: + ~UserData() override = default; + + protected: + UserData() = default; + }; + + using Super = BaseNode; + + static const uint32_t TRANSFORM_ON; + + static Node *instantiate(Node *cloned, bool isSyncedNode); + static void setScene(Node *); + + /** + * @en Finds a node by hierarchy path, the path is case-sensitive. + * It will traverse the hierarchy by splitting the path using '/' character. + * This function will still returns the node even if it is inactive. + * It is recommended to not use this function every frame instead cache the result at startup. + * @zh 通过路径从节点树中查找节点的方法,路径是大小写敏感的,并且通过 `/` 来分隔节点层级。 + * 即使节点的状态是未启用的也可以找到,建议将结果缓存,而不是每次需要都去查找。 + * @param path The path of the target node + * @param referenceNode If given, the search will be limited in the sub node tree of the reference node + */ + // static Node *find(const ccstd::string &path, Node *referenceNode = nullptr); + + /** + * @en Determine whether the given object is a normal Node. Will return false if [[Scene]] given. + * @zh 指定对象是否是普通的节点?如果传入 [[Scene]] 会返回 false。 + */ + template + static bool isNode(T *obj); + + static void resetChangedFlags(); + static void clearNodeArray(); + + Node(); + explicit Node(const ccstd::string &name); + ~Node() override; + + virtual void onPostActivated(bool active) {} + + void setParent(Node *parent, bool isKeepWorld = false); + + inline Scene *getScene() const { return _scene; }; + + using WalkCallback = std::function; + void walk(const WalkCallback &preFunc); + void walk(const WalkCallback &preFunc, const WalkCallback &postFunc); + + template + void on(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture = false); + + template + void on(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackID &cbID, bool useCapture = false); + + template + void on(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackID &cbID, bool useCapture = false); + + template + void on(const CallbacksInvoker::KeyType &type, std::function &&callback, bool useCapture = false); + + template + void on(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, bool useCapture = false); + + template + std::enable_if_t::value, void> + on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, bool useCapture = false); + + template + std::enable_if_t::value, void> + on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, bool useCapture = false); + + template + void once(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture = false); + + template + void once(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackID &cbID, bool useCapture = false); + + template + void once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackID &cbID, bool useCapture = false); + + template + std::enable_if_t::value, void> + once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackID &cbID, bool useCapture = false); + + template + void once(const CallbacksInvoker::KeyType &type, std::function &&callback, bool useCapture = false); + + template + void once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, bool useCapture = false); + + template + std::enable_if_t::value, void> + once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, bool useCapture = false); + + template + std::enable_if_t::value, void> + once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, bool useCapture = false); + + void off(const CallbacksInvoker::KeyType &type, bool useCapture = false); + + void off(const CallbacksInvoker::KeyType &type, const CallbackID &cbID, bool useCapture = false); + + void off(const CallbacksInvoker::KeyType &type, void *target, bool useCapture = false); + + template + void off(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture = false); + + template + void emit(const CallbacksInvoker::KeyType &type, Args &&...args); + + // void dispatchEvent(event::Event *event); + bool hasEventListener(const CallbacksInvoker::KeyType &type) const; + bool hasEventListener(const CallbacksInvoker::KeyType &type, const CallbackID &cbID) const; + bool hasEventListener(const CallbacksInvoker::KeyType &type, void *target) const; + bool hasEventListener(const CallbacksInvoker::KeyType &type, void *target, const CallbackID &cbID) const; + + template + bool hasEventListener(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target) const; + + void targetOff(const CallbacksInvoker::KeyType &type); + + bool destroy() override { + if (CCObject::destroy()) { + setActive(false); + return true; + } + return false; + } + + inline void destroyAllChildren() { + for (const auto &child : _children) { + child->destroy(); + } + } + + inline void updateSiblingIndex() { + index_t i = 0; + for (const auto &child : _children) { + child->_siblingIndex = i++; + } + emit(NodeEventType::SIBLING_ORDER_CHANGED); + } + + inline void addChild(Node *node) { node->setParent(this); } + + inline void removeChild(Node *node) const { + auto idx = getIdxOfChild(_children, node); + if (idx != -1) { + node->setParent(nullptr); + } + } + inline void removeFromParent() { + if (_parent) { + _parent->removeChild(this); + } + } + void removeAllChildren(); + + bool isChildOf(Node *parent) const; + + void setActive(bool isActive); + + void setSiblingIndex(index_t index); + + inline bool isPersistNode() const { + return static_cast(_objFlags & Flags::DONT_DESTROY) > 0; + } + + inline void setPersistNode(bool val) { + val ? _objFlags |= Flags::DONT_DESTROY : _objFlags &= ~Flags::DONT_DESTROY; + } + + inline const ccstd::string &getUuid() const { + return _id; + } + + inline bool isActive() const { return _active != 0; } + + inline bool isActiveInHierarchy() const { return _activeInHierarchy != 0; } + inline void setActiveInHierarchy(bool v) { + _activeInHierarchy = (v ? 1 : 0); + } + + inline const ccstd::vector> &getChildren() const { return _children; } + inline Node *getParent() const { return _parent; } + inline NodeEventProcessor *getEventProcessor() const { return _eventProcessor; } + + Node *getChildByUuid(const ccstd::string &uuid) const; + Node *getChildByName(const ccstd::string &name) const; + Node *getChildByPath(const ccstd::string &path) const; + inline index_t getSiblingIndex() const { return _siblingIndex; } + inline UserData *getUserData() { return _userData.get(); } + inline void setUserData(UserData *data) { _userData = data; } + inline void insertChild(Node *child, index_t siblingIndex) { + child->setParent(this); + child->setSiblingIndex(siblingIndex); + } + + void invalidateChildren(TransformBit dirtyBit); + + void translate(const Vec3 &, NodeSpace ns = NodeSpace::LOCAL); + void rotate(const Quaternion &rot, NodeSpace ns = NodeSpace::LOCAL, bool calledFromJS = false); + inline void rotateForJS(float x, float y, float z, float w, NodeSpace ns = NodeSpace::LOCAL) { + rotate(Quaternion(x, y, z, w), ns, true); + } + void lookAt(const Vec3 &pos, const Vec3 &up = Vec3::UNIT_Y); + + void pauseSystemEvents(bool recursive) {} // cjh TODO: + void resumeSystemEvents(bool recursive) {} // cjh TODO: + + ccstd::string getPathInHierarchy() const; + // =============================== + // transform + // =============================== + + /** + * @en Set position in local coordinate system + * @zh 设置本地坐标 + * @param position Target position + */ + inline void setPosition(const Vec3 &pos) { setPosition(pos.x, pos.y, pos.z); } + inline void setPosition(float x, float y) { setPosition(x, y, _localPosition.z); } + inline void setPosition(float x, float y, float z) { setPositionInternal(x, y, z, false); } + inline void setPositionInternal(float x, float y, bool calledFromJS) { setPositionInternal(x, y, _localPosition.z, calledFromJS); } + void setPositionInternal(float x, float y, float z, bool calledFromJS); + // It is invoked after deserialization. It only sets position value, not triggers other logic. + inline void setPositionForJS(float x, float y, float z) { _localPosition.set(x, y, z); } + /** + * @en Get position in local coordinate system, please try to pass `out` vector and reuse it to avoid garbage. + * @zh 获取本地坐标,注意,尽可能传递复用的 [[Vec3]] 以避免产生垃圾。 + * @param out Set the result to out vector + * @return If `out` given, the return value equals to `out`, otherwise a new vector will be generated and return + */ + inline const Vec3 &getPosition() const { return _localPosition; } + + /** + * @en Set rotation in local coordinate system with a quaternion representing the rotation + * @zh 用四元数设置本地旋转 + * @param rotation Rotation in quaternion + */ + inline void setRotation(const Quaternion &rotation) { setRotation(rotation.x, rotation.y, rotation.z, rotation.w); } + inline void setRotation(float x, float y, float z, float w) { setRotationInternal(x, y, z, w, false); } + void setRotationInternal(float x, float y, float z, float w, bool calledFromJS); + inline void setRotationForJS(float x, float y, float z, float w) { _localRotation.set(x, y, z, w); } + + inline void setEulerAngles(const Vec3 &val) { setRotationFromEuler(val.x, val.y, val.z); } + inline void setRotationFromEuler(const Vec3 &val) { setRotationFromEuler(val.x, val.y, val.z); } + inline void setRotationFromEuler(float x, float y) { setRotationFromEuler(x, y, _euler.z); } + void setRotationFromEuler(float x, float y, float z); + inline void setRotationFromEulerForJS(float x, float y, float z) { _euler.set(x, y, z); } + /** + * @en Get rotation as quaternion in local coordinate system, please try to pass `out` quaternion and reuse it to avoid garbage. + * @zh 获取本地旋转,注意,尽可能传递复用的 [[Quat]] 以避免产生垃圾。 + * @param out Set the result to out quaternion + * @return If `out` given, the return value equals to `out`, otherwise a new quaternion will be generated and return + */ + inline const Quaternion &getRotation() const { return _localRotation; } + + /** + * @en Set scale in local coordinate system + * @zh 设置本地缩放 + * @param scale Target scale + */ + inline void setScale(const Vec3 &scale) { setScale(scale.x, scale.y, scale.z); } + inline void setScale(float x, float y) { setScale(x, y, _localScale.z); } + inline void setScale(float x, float y, float z) { setScaleInternal(x, y, z, false); } + inline void setScaleInternal(float x, float y, bool calledFromJS) { setScaleInternal(x, y, _localScale.z, calledFromJS); } + void setScaleInternal(float x, float y, float z, bool calledFromJS); + inline void setScaleForJS(float x, float y, float z) { _localScale.set(x, y, z); } + /** + * @en Get scale in local coordinate system, please try to pass `out` vector and reuse it to avoid garbage. + * @zh 获取本地缩放,注意,尽可能传递复用的 [[Vec3]] 以避免产生垃圾。 + * @param out Set the result to out vector + * @return If `out` given, the return value equals to `out`, otherwise a new vector will be generated and return + */ + inline const Vec3 &getScale() const { return _localScale; } + + /** + * @en Inversely transform a point from world coordinate system to local coordinate system. + * @zh 逆向变换一个空间点,一般用于将世界坐标转换到本地坐标系中。 + * @param p A position in world coordinate system + * @return The result point in local coordinate system will be stored in this vector + */ + Vec3 inverseTransformPoint(const Vec3 &p); + + /** + * @en Set position in world coordinate system + * @zh 设置世界坐标 + * @param position Target position + */ + inline void setWorldPosition(const Vec3 &pos) { setWorldPosition(pos.x, pos.y, pos.z); } + void setWorldPosition(float x, float y, float z); + + /** + * @en Get position in world coordinate system, please try to pass `out` vector and reuse it to avoid garbage. + * @zh 获取世界坐标,注意,尽可能传递复用的 [[Vec3]] 以避免产生垃圾。 + * @param out Set the result to out vector + * @return If `out` given, the return value equals to `out`, otherwise a new vector will be generated and return + */ + const Vec3 &getWorldPosition() const; + + /** + * @en Set rotation in world coordinate system with a quaternion representing the rotation + * @zh 用四元数设置世界坐标系下的旋转 + * @param rotation Rotation in quaternion + */ + inline void setWorldRotation(const Quaternion &rotation) { setWorldRotation(rotation.x, rotation.y, rotation.z, rotation.w); } + void setWorldRotation(float x, float y, float z, float w); + /** + * @en Get rotation as quaternion in world coordinate system, please try to pass `out` quaternion and reuse it to avoid garbage. + * @zh 获取世界坐标系下的旋转,注意,尽可能传递复用的 [[Quat]] 以避免产生垃圾。 + * @param out Set the result to out quaternion + * @return If `out` given, the return value equals to `out`, otherwise a new quaternion will be generated and return + */ + const Quaternion &getWorldRotation() const; + + /** + * @en Set rotation in world coordinate system with euler angles + * @zh 用欧拉角设置世界坐标系下的旋转 + * @param x X axis rotation + * @param y Y axis rotation + * @param z Z axis rotation + */ + inline void setWorldScale(const Vec3 &scale) { setWorldScale(scale.x, scale.y, scale.z); } + void setWorldScale(float x, float y, float z); + + /** + * @en Get scale in world coordinate system, please try to pass `out` vector and reuse it to avoid garbage. + * @zh 获取世界缩放,注意,尽可能传递复用的 [[Vec3]] 以避免产生垃圾。 + * @param out Set the result to out vector + * @return If `out` given, the return value equals to `out`, otherwise a new vector will be generated and return + */ + const Vec3 &getWorldScale() const; + + void setWorldRotationFromEuler(float x, float y, float z); + + /** + * @en Local transformation matrix + * @zh 本地坐标系变换矩阵 + */ + void setMatrix(const Mat4 &val); + + /** + * @en Update the world transform information if outdated + * @zh 更新节点的世界变换信息 + */ + void updateWorldTransform(); + + /** + * @en Get a world transform matrix + * @zh 获取世界变换矩阵 + * @param out Set the result to out matrix + * @return If `out` given, the return value equals to `out`, otherwise a new matrix will be generated and return + */ + const Mat4 &getWorldMatrix() const; + + /** + * @en Get a world transform matrix with only rotation and scale + * @zh 获取只包含旋转和缩放的世界变换矩阵 + * @param out Set the result to out matrix + * @return If `out` given, the return value equals to `out`, otherwise a new matrix will be generated and return + */ + Mat4 getWorldRS(); + + /** + * @en Get a world transform matrix with only rotation and translation + * @zh 获取只包含旋转和位移的世界变换矩阵 + * @param out Set the result to out matrix + * @return If `out` given, the return value equals to `out`, otherwise a new matrix will be generated and return + */ + Mat4 getWorldRT(); + + /** + * @en Set local transformation with rotation, position and scale separately. + * @zh 一次性设置所有局部变换(平移、旋转、缩放)信息 + * @param rot The rotation + * @param pos The position + * @param scale The scale + */ + void setRTSInternal(Quaternion *rot, Vec3 *pos, Vec3 *scale, bool calledFromJS); + inline void setRTS(Quaternion *rot, Vec3 *pos, Vec3 *scale) { setRTSInternal(rot, pos, scale, false); } + + void setForward(const Vec3 &dir); + + void setAngle(float); + + inline const Vec3 &getEulerAngles() { + if (_eulerDirty) { + Quaternion::toEuler(_localRotation, false, &_euler); + _eulerDirty = false; + } + return _euler; + } + + inline float getAngle() const { + return _euler.z; + } + + inline Vec3 getForward() const { + Vec3 forward{0, 0, -1}; + forward.transformQuat(getWorldRotation()); + return forward; + } + + inline Vec3 getUp() const { + Vec3 up{0, 1, 0}; + up.transformQuat(getWorldRotation()); + return up; + } + + inline Vec3 getRight() const { + Vec3 right{1, 0, 0}; + right.transformQuat(getWorldRotation()); + return right; + } + + inline bool isStatic() const { + return _isStatic != 0; + } + + inline void setStatic(bool v) { + _isStatic = v ? 1 : 0; + } + + /** + * @en Whether the node's transformation have changed during the current frame. + * @zh 这个节点的空间变换信息在当前帧内是否有变过? + */ + inline uint32_t getChangedFlags() const { + return _hasChangedFlagsVersion == globalFlagChangeVersion ? _hasChangedFlags : 0; + } + inline void setChangedFlags(uint32_t value) { + _hasChangedFlagsVersion = globalFlagChangeVersion; + _hasChangedFlags = value; + } + + inline void setDirtyFlag(uint32_t value) { _dirtyFlag = value; } + inline uint32_t getDirtyFlag() const { return _dirtyFlag; } + inline void setLayer(uint32_t layer) { + _layer = layer; + emit(NodeEventType::LAYER_CHANGED, layer); + } + inline uint32_t getLayer() const { return _layer; } + + inline float getUISortingPriority() const { return _uiSortingPriority; } + + inline bool isUISortingEnabled() const { return _uiSortingEnabled != 0; } + + // inline NodeUiProperties *getUIProps() const { return _uiProps.get(); } + + // // ------------------ Component code start ----------------------------- + // // TODO(Lenovo): + // + // template ::value>> + // static Component *findComponent(Node * /*node*/) { + // // cjh TODO: + // CC_ASSERT(false); + // return nullptr; + // } + // + // template ::value>> + // static Component *findComponents(Node * /*node*/, const ccstd::vector & /*components*/) { + // // cjh TODO: + // CC_ASSERT(false); + // return nullptr; + // } + // + // template ::value>> + // static Component *findChildComponent(const ccstd::vector & /*children*/) { + // // cjh TODO: + // CC_ASSERT(false); + // return nullptr; + // } + // + // template ::value>> + // static void findChildComponents(const ccstd::vector & /*children*/, ccstd::vector & /*components*/) { + // // cjh TODO: + // CC_ASSERT(false); + // } + // + // template , T>> + // T *addComponent() { + // T *comp = new T(); + // return static_cast(addComponent(comp)); + // } + // + // template ::value>> + // void removeComponent() { + // for (auto iter = _components.begin(); iter != _components.end(); ++iter) { + // if (dynamic_cast(*iter) != nullptr) { + // _components.erase(iter); + // } + // } + // } + // + // Component *addComponent(Component *comp); + // void removeComponent(Component *comp); + // + // template ::value>> + // Component *getComponent() const { + // for (auto *component : _components) { + // if (dynamic_cast(component) != nullptr) { + // return component; + // } + // } + // return nullptr; + // } + // + // // TODO(Lenovo): + // template ::value>> + // ccstd::vector getComponents() const { + // // cjh TODO: + // CC_ASSERT(false); + // return {}; + // }; + // + // template ::value>> + // Component *getComponentInChildren(const T & /*comp*/) const { + // // cjh TODO: + // CC_ASSERT(false); + // return nullptr; + // } + // + // template ::value>> + // ccstd::vector getComponentsInChildren() const { + // // cjh TODO: + // CC_ASSERT(false); + // return {}; + // } + // + // inline ccstd::vector getComponents() const { return _components; } + // + // void checkMultipleComp(Component *comp) {} + // ccstd::vector _components; + // + // friend void componentCorrupted(Node *node, Component *comp, uint32_t index); + // ------------------ Component code end ----------------------------- + + // For deserialization + // void _setChild(index_t i, Node *child); + // Node * _getChild(index_t i); + // void _setChildrenSize(uint32_t size); + // uint32_t _getChildrenSize(); + void _setChildren(ccstd::vector> &&children); // NOLINT + + inline se::Object *_getSharedArrayBufferObject() const { return _sharedMemoryActor.getSharedArrayBufferObject(); } // NOLINT + + bool onPreDestroy() override; + bool onPreDestroyBase(); + + std::function onSiblingIndexChanged{nullptr}; + // For deserialization + ccstd::string _id; + Node *_parent{nullptr}; + +private: + static index_t getIdxOfChild(const ccstd::vector> &, Node *); + + virtual void onBatchCreated(bool dontChildPrefab); + virtual void updateScene(); + + void onSetParent(Node *oldParent, bool keepWorldTransform); + void onHierarchyChanged(Node *); + void onHierarchyChangedBase(Node *oldParent); + + inline void notifyLocalPositionUpdated() { + emit(EventTypesToJS::NODE_LOCAL_POSITION_UPDATED, _localPosition.x, _localPosition.y, _localPosition.z); + } + + inline void notifyLocalRotationUpdated() { + emit(EventTypesToJS::NODE_LOCAL_ROTATION_UPDATED, _localRotation.x, _localRotation.y, _localRotation.z, _localRotation.w); + } + + inline void notifyLocalScaleUpdated() { + emit(EventTypesToJS::NODE_LOCAL_SCALE_UPDATED, _localScale.x, _localScale.y, _localScale.z); + } + + inline void notifyLocalPositionRotationScaleUpdated() { + emit(EventTypesToJS::NODE_LOCAL_POSITION_ROTATION_SCALE_UPDATED, + _localPosition.x, _localPosition.y, _localPosition.z, + _localRotation.x, _localRotation.y, _localRotation.z, _localRotation.w, + _localScale.x, _localScale.y, _localScale.z); + } + +#if CC_EDITOR + inline void notifyEditorAttached(bool attached) { + emit(EventTypesToJS::NODE_EDITOR_ATTACHED, attached); + } +#endif + + // increase on every frame, used to identify the frame + static uint32_t globalFlagChangeVersion; + + static uint32_t clearFrame; + static uint32_t clearRound; + + Scene *_scene{nullptr}; + NodeEventProcessor *_eventProcessor{nullptr}; + IntrusivePtr _userData; + + ccstd::vector> _children; + bindings::NativeMemorySharedToScriptActor _sharedMemoryActor; + // local transform + Vec3 _localPosition{Vec3::ZERO}; + Vec3 _localScale{Vec3::ONE}; + Quaternion _localRotation{Quaternion::identity()}; + // world transform + Vec3 _worldPosition{Vec3::ZERO}; + Vec3 _worldScale{Vec3::ONE}; + Vec3 _euler{0, 0, 0}; + Quaternion _worldRotation{Quaternion::identity()}; + Mat4 _worldMatrix{Mat4::IDENTITY}; + + // Shared memory with JS + // NOTE: TypeArray created in node.jsb.ts _ctor should have the same memory layout + uint32_t _eventMask{0}; // Uint32: 0 + uint32_t _layer{static_cast(Layers::LayerList::DEFAULT)}; // Uint32: 1 + uint32_t _dirtyFlag{0}; // Uint32: 2 + index_t _siblingIndex{0}; // Int32: 0 + float _uiSortingPriority{0.0F}; // Float: 0 + uint8_t _activeInHierarchy{0}; // Uint8: 0 + uint8_t _active{1}; // Uint8: 1 + uint8_t _isStatic{0}; // Uint8: 2 + uint8_t _uiSortingEnabled{0}; // Uint8: 3 + + /* set _hasChangedFlagsVersion to globalFlagChangeVersion when `_hasChangedFlags` updated. + * `globalFlagChangeVersion == _hasChangedFlagsVersion` means that "_hasChangedFlags is dirty in current frametime". + */ + uint32_t _hasChangedFlagsVersion{0}; + uint32_t _hasChangedFlags{0}; + + bool _eulerDirty{false}; + + friend class NodeActivator; + friend class Scene; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Node); +}; + +template +bool Node::isNode(T *obj) { + return dynamic_cast(obj) != nullptr && dynamic_cast(obj) == nullptr; +} + +template +void Node::emit(const CallbacksInvoker::KeyType &type, Args &&...args) { + _eventProcessor->emit(type, std::forward(args)...); +} + +template +void Node::on(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask |= TRANSFORM_ON; + } + _eventProcessor->on(type, memberFn, target, useCapture); +} + +template +void Node::on(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackID &cbID, bool useCapture) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask |= TRANSFORM_ON; + } + _eventProcessor->on(type, std::forward>(callback), cbID, useCapture); +} + +template +void Node::on(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackID &cbID, bool useCapture) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask |= TRANSFORM_ON; + } + _eventProcessor->on(type, std::forward>(callback), target, cbID, useCapture); +} + +template +std::enable_if_t::value, void> +Node::on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackID &cbID, bool useCapture) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask |= TRANSFORM_ON; + } + _eventProcessor->on(type, callback, target, cbID, useCapture); +} + +template +std::enable_if_t::value, void> +Node::on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackID &cbID, bool useCapture) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask |= TRANSFORM_ON; + } + _eventProcessor->on(type, callback, cbID, useCapture); +} + +template +void Node::on(const CallbacksInvoker::KeyType &type, std::function &&callback, bool useCapture) { + CallbackID unusedID{0}; + on(type, callback, unusedID, useCapture); +} + +template +void Node::on(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, bool useCapture) { + CallbackID unusedID{0}; + on(type, callback, target, unusedID, useCapture); +} + +template +std::enable_if_t::value, void> +Node::on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, bool useCapture) { + CallbackID unusedID{0}; + on(type, callback, target, unusedID, useCapture); +} + +template +std::enable_if_t::value, void> +Node::on(const CallbacksInvoker::KeyType &type, LambdaType &&callback, bool useCapture) { + CallbackID unusedID{0}; + on(type, callback, unusedID, useCapture); +} +template +void Node::once(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture) { + _eventProcessor->once(type, memberFn, target, useCapture); +} +template +void Node::once(const CallbacksInvoker::KeyType &type, std::function &&callback, CallbackID &cbID, bool useCapture) { + _eventProcessor->once(type, callback, cbID, useCapture); +} + +template +void Node::once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, CallbackID &cbID, bool useCapture) { + _eventProcessor->once(type, std::forward>(callback), target, cbID, useCapture); +} + +template +std::enable_if_t::value, void> +Node::once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, CallbackID &cbID, bool useCapture) { + _eventProcessor->once(type, callback, cbID, useCapture); +} + +template +std::enable_if_t::value, void> +Node::once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, CallbackID &cbID, bool useCapture) { + _eventProcessor->once(type, callback, target, cbID, useCapture); +} + +template +void Node::once(const CallbacksInvoker::KeyType &type, std::function &&callback, bool useCapture) { + CallbackID unusedID{0}; + once(type, callback, unusedID, useCapture); +} + +template +void Node::once(const CallbacksInvoker::KeyType &type, std::function &&callback, Target *target, bool useCapture) { + CallbackID unusedID{0}; + once(type, callback, target, unusedID, useCapture); +} + +template +std::enable_if_t::value, void> +Node::once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, bool useCapture) { + CallbackID unusedID{0}; + once(type, callback, unusedID, useCapture); +} + +template +std::enable_if_t::value, void> +Node::once(const CallbacksInvoker::KeyType &type, LambdaType &&callback, Target *target, bool useCapture) { + CallbackID unusedID{0}; + once(type, callback, target, unusedID, useCapture); +} + +template +void Node::off(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target, bool useCapture) { + _eventProcessor->off(type, memberFn, target, useCapture); + bool hasListeners = _eventProcessor->hasEventListener(type); + if (!hasListeners) { + if (type == NodeEventType::TRANSFORM_CHANGED) { + _eventMask &= ~TRANSFORM_ON; + } + } +} + +template +bool Node::hasEventListener(const CallbacksInvoker::KeyType &type, void (Target::*memberFn)(Args...), Target *target) const { + return _eventProcessor->hasEventListener(type, memberFn, target); +} + +} // namespace cc diff --git a/3.6.3/native/engine/lcc-ui-sorting-group-native/readme.txt b/3.6.3/native/engine/lcc-ui-sorting-group-native/readme.txt new file mode 100644 index 0000000..f648d66 --- /dev/null +++ b/3.6.3/native/engine/lcc-ui-sorting-group-native/readme.txt @@ -0,0 +1,7 @@ +当前版本: cocos creator 3.6.3 + +涉及源文件: +cocos/2d/renderer/Batcher2d.h +cocos/2d/renderer/Batcher2d.cpp +cocos/2d/renderer/RenderEntity.h +cocos/2d/renderer/RenderEntity.cpp